From c4d47187095400c89496fa82b45169cdc10aa8f0 Mon Sep 17 00:00:00 2001 From: John Reese Date: Thu, 13 Jan 2011 20:39:08 -0500 Subject: [PATCH] Implemented handling of channel messages and actions --- notifo.cpp | 50 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/notifo.cpp b/notifo.cpp index 9c92eb3..59f6efb 100644 --- a/notifo.cpp +++ b/notifo.cpp @@ -136,12 +136,14 @@ class CNotifoMod : public CModule /** * Determine when to notify the user of a channel message. * + * @param nick Nick that sent the message * @param channel Channel the message was sent to + * @param message Message contents * @return Notification should be sent */ - bool notify_channel(const CChan& channel) + bool notify_channel(const CNick& nick, const CChan& channel, const CString& message) { - return true; + return false; } /** @@ -175,6 +177,50 @@ class CNotifoMod : public CModule return true; } + /** + * Handle channel messages. + * + * @param nick Nick that sent the message + * @param channel Channel the message was sent to + * @param message Message contents + */ + EModRet OnChanMsg(CNick& nick, CChan& channel, CString& message) + { + if (notify_channel(nick, channel, message)) + { + CString title = "Highlight"; + CString msg = channel.GetName(); + msg += ": <" + nick.GetNick(); + msg += "> " + message; + + send_message(msg, title); + } + + return CONTINUE; + } + + /** + * Handle channel actions. + * + * @param nick Nick that sent the action + * @param channel Channel the message was sent to + * @param message Message contents + */ + EModRet OnChanAction(CNick& nick, CChan& channel, CString& message) + { + if (notify_channel(nick, channel, message)) + { + CString title = "Highlight"; + CString msg = channel.GetName(); + msg += ": " + nick.GetNick(); + msg += " " + message; + + send_message(msg, title); + } + + return CONTINUE; + } + /** * Handle a private message. *