private void SendButton_MouseUp(object sender, MouseEventArgs e) { if (SendText.Text.Trim() != "") { String[] userQuestion = SendText.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); // добавляем вопрос в файл ChatText.AppendText(userQuestion[0] + "\r\n"); SendText.Text = ""; // очищаем поле отправки string[] botAnswer = new string[] { bot.Answer(message) }; botAnswer[0] = botAnswer[0].Insert(0, "[" + DateTime.Now.ToString("HH:mm") + "] Бот: "); ChatText.AppendText(botAnswer[0] + Environment.NewLine); bot.AddToHistory(botAnswer); // добавляем ответ бота в файл } }
private void SendButton_Click(object sender, EventArgs e) { if (QuestionText.Text != "") { String[] userQuestion = QuestionText.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); ChatText.AppendText(userQuestion[0] + "\r\n"); QuestionText.Text = ""; string[] botAnswer = new string[] { bot.Answer(message) }; botAnswer[0] = botAnswer[0].Insert(0, "Бот: "); ChatText.AppendText(botAnswer[0] + Environment.NewLine); bot.AddToHistory(botAnswer); } }