public void Session_OnMessageReceived(object sender, MessageReceivedEventArgs e) { // execute the command using (var container = new WindsorContainer()) { container.Install(Configuration.FromAppConfig()); var agent = container.Resolve<IAutoBotAgent>(); agent.ProcessMessage(e.Message, e.Response); } }
public void OnMessageReceived(ChatMessage chatmessage) { // take a local copy of the event so we don't get a race condition on the next line var handler = this.MessageReceived; if (handler != null) { // extract the chat text if (chatmessage.Body == null) { return; } var commandText = chatmessage.Body.Trim(); // build the chat message and response to pass to the event handler var message = new SkypeMessage(chatmessage.Body, commandText); var response = new SkypeResponse(chatmessage.Chat); var args = new MessageReceivedEventArgs(message, response); // call the event handler handler(this, args); } }
private void OnMessageReceived(Message message) { // take a local copy of the event so we don't get a race condition further down var handler = this.MessageReceived; if (handler == null) { return; } // skip blank messages if (message.Body == null && message.X == null) { return; } // skip messages from the bot if (message.From.Resource == this.NickName) { return; } // extract the chat text var commandText = (message.Body == null) ? message.X.InnerText.Trim() : message.Body.Trim(); if ((message.Type == MessageType.groupchat) && commandText.StartsWith(this.MentionName)) { commandText = this.RemoveMentionsFromMessage(commandText); } // build the chat message and response to pass to the event handler var chatMessage = new HipChatMessage(message.Type, message.Body, commandText); var responseJid = new JID(message.From.User, message.From.Server, message.From.Resource); var chatResponse = new HipChatResponse(this, responseJid, message.Type); var args = new MessageReceivedEventArgs(chatMessage, chatResponse); // call the event handler handler(this, args); }