mirror of https://github.com/SeanOMik/znc-push.git
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.
This commit is contained in:
parent
f5590832cc
commit
5c12abe602
44
notifo.cpp
44
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 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";
|
return true;
|
||||||
CString msg = "From " + nick.GetNick();
|
|
||||||
msg += ": " + message;
|
|
||||||
|
|
||||||
send_message(msg, title);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
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 nick Nick that sent the message
|
||||||
* @param message Message contents
|
* @param message Message contents
|
||||||
*/
|
*/
|
||||||
EModRet OnPrivMsg(CNick& nick, CString& message)
|
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;
|
return CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue