示例#1
0
        //Нажали на кнопку "Отправить сообщение"
        private void buttonSendMsg_Click(object sender, EventArgs e)
        {
            if (tbxMsgMode == 1)
            {
                //Если текстбокс в "не рабочем режиме" то ничего не делать
                //Иначе делать
            }
            else
            {
                String[] userQuestion = TextBoxSendMsg.Text.Split(new String[] { "\r\n" },
                                                                  StringSplitOptions.RemoveEmptyEntries);

                string message = userQuestion[0]; // для отправки боту

                userQuestion[0] = userQuestion[0].Insert(0,
                                                         "[" + DateTime.Now.ToString("HH:mm") + "] " + bot.UserName + ": ");

                bot.AddToHistory(userQuestion);

                TextBoxChat.AppendText(userQuestion[0] + "\r\n");
                TextBoxSendMsg.Text = "";
                string[] botAnswer = new string[] { bot.Answer(message) };
                botAnswer[0] = botAnswer[0].Insert(0, "Бот: ");
                TextBoxChat.AppendText(botAnswer[0] + Environment.NewLine);

                bot.AddToHistory(botAnswer);
            }
        }