void SendMessage() { if (tabControl1.TabPages.Count != 0) { myUser usr = getCurrentUser(tabControl1.SelectedTab.Text, tabControl1.SelectedTab.Text, null); if (usr.chat != null) { usr.chat.SendMessage(textBox1.Text); textBox1.Text = String.Empty; } } }
//Will read from skype and update text box private void OnMessage(ChatMessage msg) { // check if we are on the main thread if (InvokeRequired) { Invoke((MethodInvoker) delegate { OnMessage(msg); }); return; } if (msg.Sender.Username != skype_botName) { myUser usr = getCurrentUser(msg.Sender.Username, msg.Sender.DisplayName, msg.Chat); usr.textBox.AppendText("\n\n" + msg.Sender.Username + ": " + msg.Body); string resp = chatbot.getResponse(msg.Body, usr.AIusr, label2); msg.Chat.SendMessage(resp); usr.textBox.AppendText("\n\nBot: " + resp); } }
private myUser getCurrentUser(string user, string userFullName, Chat chat) { myUser currentUsr = new myUser(); bool found = false; foreach (myUser usr in conversation_users) { if (usr.userName == user) { found = true; currentUsr = usr; break; } } if (!found && chat != null) { currentUsr = initUser(user, userFullName, chat); } return(currentUsr); }