阻止键盘输入聊天机器人

时间:2017-09-18 09:57:37

标签: c# asp.net visual-studio chatbot

我正在使用C#和Visual Studio构建一个ChatBot。我想要做的是在对ChatBot进行一些查询之后,用户再也不能使用键盘,我已经看到一些网站解释如何做,但我不太了解,所以如果有人可以帮助我

这个想法是在else块中放入一些阻止用户写入ChatBot的东西,所以如果他想写下他输入的东西不会出现在屏幕上。这是我的代码:

private int NombreDeMessages;
protected override async Task MessageReceived(IDialogContext context, IAwaitable<IMessageActivity> item)
{
    var message = await item;
    NombreDeMessages += 1;
    string code = EndOfConversationCodes.CompletedSuccessfully;
    CancellationToken cancellationToken = default(CancellationToken);


    if (message.Text != null && NombreDeMessages < 3)
    {
        await base.MessageReceived(context, item);
    }
    else if (message.Text != null && NombreDeMessages == 3)
    {
        AdaptiveCard card = new AdaptiveCard();
        card.Body.Add(new TextBlock()
        {
            Text = "STOP FLOODING",
            Weight = TextWeight.Bolder,
            IsSubtle = true,
            Wrap = true,
            Size = TextSize.Large
        });

        card.Body.Add(new TextBlock()
        {
            Text = "You have reach the limit of queries",
            IsSubtle = false,
            Wrap = true,
            Size = TextSize.Normal
        });

        card.Body.Add(new Image()
        {
            Url = "http://images.roadtrafficsigns.com/img/dp/lg/traffic-stop-sign.png",

            HorizontalAlignment = AdaptiveCards.HorizontalAlignment.Center,
            Size = ImageSize.Stretch
        });

        Attachment attachment = new Attachment()
        {
            ContentType = AdaptiveCard.ContentType,
            Content = card
        };
        var flood = context.MakeMessage();
        flood.Attachments.Add(attachment);

        await context.PostAsync(flood);
    }
    else
    {
        var reply = context.MakeMessage();

        reply.Type = ActivityTypes.EndOfConversation;
        reply.AsEndOfConversationActivity().Code = code;

        await context.PostAsync(reply, cancellationToken);
    }
}

是的我想阻止Web应用程序的输入,我没有C#应用程序。我的HTML代码就是这个:

<!DOCTYPE html>
<html>
<body style="width:100%;height:100%;">
    <script>
(function () {
        var div = document.createElement("div");
        document.getElementsByTagName('body')[0].appendChild(div);
        div.outerHTML = "<div id='botDiv' style='height: 38px; position: fixed; bottom: 0; z-index: 1000; background-color: #fff'><div id='botTitleBar' style='height: 38px; width: 400px; position:fixed; cursor: pointer;'></div><iframe width='400' height='600' src='https://webchat.botframework.com/embed/supportbotv2?s=4mHD9MekOvU.cwA.8ZU.Pn31pCpv8kyq7UQCr3y4bM-99W4eHxUt-LlhBnCp9JY'></iframe></div>";

        document.querySelector('body').addEventListener('click', function (e) {
            e.target.matches = e.target.matches || e.target.msMatchesSelector;
            if (e.target.matches('#botTitleBar')) {
                var botDiv = document.querySelector('#botDiv');
                botDiv.style.height = botDiv.style.height == '600px' ? '38px' : '600px';
            };
        });
    }());</script>
</body>
</html>

1 个答案:

答案 0 :(得分:1)

禁用控制键盘输入的位置有什么问题?例如:

this.textBox1.enabled = false