From 5c12abe6028e5149fa06ef9c1778324fdfee3f04 Mon Sep 17 00:00:00 2001 From: John Reese Date: Thu, 13 Jan 2011 19:15:17 -0500 Subject: [PATCH] Make notify_pm() only decide on sending notification In order to better abstract and handle the difference between messages and actions, notify_pm() is changed to only determine whether a private message or action should send a notification to the user, and leave sending the notification to the calling method. This allows PM's and PA's to have different notification text formats, while still centralizing the logic to decide when to send them. TODO: Make notify_pm() actually use logic instead of blindly saying yes. --- notifo.cpp | 44 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/notifo.cpp b/notifo.cpp index 4f0f03b..cc24d5d 100644 --- a/notifo.cpp +++ b/notifo.cpp @@ -134,18 +134,14 @@ class CNotifoMod : public CModule } /** - * Notify the user of a private message. + * Determine when to notify the user of a private message. * * @param nick Nick that sent the message - * @param message Message contents + * @return Notification should be sent */ - void notify_pm(const CNick& nick, const CString& message) + bool notify_pm(const CNick& nick) { - CString title = "Private Message"; - CString msg = "From " + nick.GetNick(); - msg += ": " + message; - - send_message(msg, title); + return true; } protected: @@ -161,14 +157,42 @@ class CNotifoMod : public CModule } /** - * Handle a private message + * Handle a private message. * * @param nick Nick that sent the message * @param message Message contents */ EModRet OnPrivMsg(CNick& nick, CString& message) { - notify_pm(nick, message); + if (notify_pm(nick)) + { + CString title = "Private Message"; + CString msg = "From " + nick.GetNick(); + msg += ": " + message; + + send_message(msg, title); + } + + return CONTINUE; + } + + /** + * Handle a private action. + * + * @param nick Nick that sent the action + * @param message Message contents + */ + EModRet OnPrivAction(CNick& nick, CString& message) + { + if (notify_pm(nick)) + { + CString title = "Private Message"; + CString msg = "* " + nick.GetNick(); + msg += " " + message; + + send_message(msg, title); + } + return CONTINUE; }