mirror of https://github.com/SeanOMik/znc-push.git
Implemented nick_blacklist condition
Space-separated list of nicks. Applies to both channel mentions and query windows. Notifications will only be sent for messages from nicks that are not present in this list, using a case-insensitive comparison. Note that wildcard patterns can be used to match multiple nicks with a single blacklist entry. For example, `set nick_blacklist *bot` will not send notifications from nicks like "channelbot", "FooBot", or "Robot". Care must be used to not accidentally blacklist legitimate nicks with wildcards.
This commit is contained in:
parent
6fb80cff1f
commit
16f28cb04a
13
README.md
13
README.md
|
@ -100,6 +100,17 @@ Configuration
|
|||
query window separately, so a recent PM from Joe will not affect a notification sent
|
||||
from channel #foo.
|
||||
|
||||
* `nick_blacklist = ""`
|
||||
|
||||
Space-separated list of nicks. Applies to both channel mentions and query windows.
|
||||
Notifications will only be sent for messages from nicks that are not present in this
|
||||
list, using a case-insensitive comparison.
|
||||
|
||||
Note that wildcard patterns can be used to match multiple nicks with a single blacklist
|
||||
entry. For example, `set nick_blacklist *bot` will not send notifications from nicks
|
||||
like "channelbot", "FooBot", or "Robot". Care must be used to not accidentally
|
||||
blacklist legitimate nicks with wildcards.
|
||||
|
||||
|
||||
### Notifications
|
||||
|
||||
|
@ -129,8 +140,6 @@ Roadmap
|
|||
* Highlights: Strings to trigger a channel notification, in addition to the default
|
||||
highlight when your nick is mentioned.
|
||||
|
||||
* Nick blacklist: List of nicks to never send notifications from, e.g. channel bots.
|
||||
|
||||
### Settings
|
||||
|
||||
* Customizable notification titles and message formats.
|
||||
|
|
33
notifo.cpp
33
notifo.cpp
|
@ -70,6 +70,7 @@ class CNotifoMod : public CModule
|
|||
|
||||
// Notification conditions
|
||||
defaults["away_only"] = "no";
|
||||
defaults["nick_blacklist"] = "";
|
||||
defaults["client_count_less_than"] = "0";
|
||||
defaults["last_notification"] = "300";
|
||||
|
||||
|
@ -216,6 +217,30 @@ class CNotifoMod : public CModule
|
|||
|| last_notification_time[context] + value < now;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the nick_blacklist condition is met.
|
||||
*
|
||||
* @param nick Nick that sent the message
|
||||
* @return True if nick is not in the blacklist
|
||||
*/
|
||||
bool nick_blacklist(const CNick& nick)
|
||||
{
|
||||
VCString blacklist;
|
||||
options["nick_blacklist"].Split(" ", blacklist, false);
|
||||
|
||||
CString name = nick.GetNick().AsLower();
|
||||
|
||||
for (VCString::iterator i = blacklist.begin(); i != blacklist.end(); i++)
|
||||
{
|
||||
if (name.WildCmp(i->AsLower()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine when to notify the user of a channel message.
|
||||
*
|
||||
|
@ -229,7 +254,9 @@ class CNotifoMod : public CModule
|
|||
return away_only()
|
||||
&& client_count_less_than()
|
||||
&& highlight(message)
|
||||
&& last_notification(channel.GetName());
|
||||
&& last_notification(channel.GetName())
|
||||
&& nick_blacklist(nick)
|
||||
&& true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -241,7 +268,9 @@ class CNotifoMod : public CModule
|
|||
bool notify_pm(const CNick& nick)
|
||||
{
|
||||
return away_only()
|
||||
&& last_notification(nick.GetNick());
|
||||
&& last_notification(nick.GetNick())
|
||||
&& nick_blacklist(nick)
|
||||
&& true;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
|
Loading…
Reference in New Issue