private void OnMessageReceived(object sender, SkypeMessageReceivedEventArgs e) { Console.WriteLine("{0}: {1}", e.FromDisplayName, e.Body); _bot.HandleMessage(e.Body, answer => SendMessage(answer, e.Chat), new SkypeData { FromName = e.FromDisplayName }); }
private static void OnMessageReceived(ChatMessage pMessage, TChatMessageStatus status) { Console.WriteLine(status + pMessage.Body); if (status == TChatMessageStatus.cmsReceived) { bot.HandleMessage(pMessage.Body, (answer, answerType) => SendMessage(answer, pMessage.Chat), new SkypeData(pMessage)); string fromChatId = pMessage.Chat.Name.Split(';').Last(); chatSyncer.HandleMessage(pMessage.Body, pMessage.FromDisplayName, fromChatId); } }
private void txtCommandSearchField_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { string question = txtCommandSearchField.Text; bool toBuffer = false; if (question.Trim().EndsWith(copyToBufferPostFix, StringComparison.InvariantCultureIgnoreCase)) { question = question.Substring(0, question.Length - copyToBufferPostFix.Length); toBuffer = true; } bot.HandleMessage(question, delegate(string answer, AnswerBehaviourType answerType) { if (toBuffer) { this.Invoke(new MethodInvoker(() => Clipboard.SetText(answer))); } else { if (answerType == AnswerBehaviourType.Link) { if (answer.StartsWith("http://") || answer.StartsWith("https://")) { Process.Start(answer); } } else if (answerType == AnswerBehaviourType.Text) { if (!string.IsNullOrEmpty(answer)) { MessageBox.Show(answer); } } } }, null); } }