mirror of https://github.com/SeanOMik/znc-push.git
Merge pull request #152 from ggrog/master
Add "context" notification filter; update docs
This commit is contained in:
commit
fa7723470e
31
README.md
31
README.md
|
@ -407,6 +407,27 @@ to something similar to "http://domain/#channel/2011-03-09 14:25:09", or
|
||||||
If set to `yes`, notifications will only be sent if you have replied to the channel or
|
If set to `yes`, notifications will only be sent if you have replied to the channel or
|
||||||
query window more recently than the last time a notification was sent for that context.
|
query window more recently than the last time a notification was sent for that context.
|
||||||
|
|
||||||
|
* `context` Default: `*`
|
||||||
|
|
||||||
|
Similar to `highlight`, this is a space-separated list of strings to match against message
|
||||||
|
contexts using case-insensitive, wildcard matching. Strings will be compared in order
|
||||||
|
they appear in the configuration value, and the first string to match will end the search,
|
||||||
|
meaning that earlier strings take priority over later values.
|
||||||
|
|
||||||
|
Individual strings may be prefixed with a `-` (hyphen) to negate the match, which makes
|
||||||
|
the string act as a filter rather than a search.
|
||||||
|
|
||||||
|
The wildcard `*` (the default) may be used to match any context.
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
* `#important` - Only messages from the #important channel that match all the other
|
||||||
|
conditions will be pushed
|
||||||
|
* `-#notimportant *` - Messages from #nonimportant will be ignored; everything else (`*`)
|
||||||
|
will be matched
|
||||||
|
* Set `channel_conditions` to `(highlight or context)` and `context` to `#iwantitall` -
|
||||||
|
Now you'll get notifications for every message in #iwantitall and messages that match your
|
||||||
|
highlight rules everywhere else.
|
||||||
|
|
||||||
### Proxy
|
### Proxy
|
||||||
|
|
||||||
|
@ -454,12 +475,20 @@ to something similar to "http://domain/#channel/2011-03-09 14:25:09", or
|
||||||
(last_active or last_notification or replied) and nick_blacklist` would send a
|
(last_active or last_notification or replied) and nick_blacklist` would send a
|
||||||
notification if any of the three conditions in the sub-expression are met, while still
|
notification if any of the three conditions in the sub-expression are met, while still
|
||||||
requiring all of the conditions outside of the parentheses to also be met.
|
requiring all of the conditions outside of the parentheses to also be met.
|
||||||
|
|
||||||
|
Specifying `all` is equivalent to:
|
||||||
|
|
||||||
|
* `away_only and client_count_less_than and highlight and idle and last_active and last_notification and nick_blacklist and replied and context`
|
||||||
|
|
||||||
* `query_conditions` Default: `all`
|
* `query_conditions` Default: `all`
|
||||||
|
|
||||||
This option is more or less identical to `channel_conditions`, except that it is used
|
This option is more or less identical to `channel_conditions`, except that it is used
|
||||||
to filter notifications for private messages.
|
to filter notifications for private messages.
|
||||||
|
|
||||||
|
Specifying `all` is equivalent to:
|
||||||
|
|
||||||
|
* `away_only and client_count_less_than and idle and last_active and last_notification and nick_blacklist and replied`
|
||||||
|
|
||||||
* `debug` Default: `off`
|
* `debug` Default: `off`
|
||||||
|
|
||||||
When set to `on`, this option enables debug output for various features, and is useful
|
When set to `on`, this option enables debug output for various features, and is useful
|
||||||
|
|
44
push.cpp
44
push.cpp
|
@ -146,6 +146,7 @@ class CPushMod : public CModule
|
||||||
defaults["last_notification"] = "300";
|
defaults["last_notification"] = "300";
|
||||||
defaults["nick_blacklist"] = "";
|
defaults["nick_blacklist"] = "";
|
||||||
defaults["replied"] = "yes";
|
defaults["replied"] = "yes";
|
||||||
|
defaults["context"] = "*";
|
||||||
|
|
||||||
// Proxy, for libcurl
|
// Proxy, for libcurl
|
||||||
defaults["proxy"] = "";
|
defaults["proxy"] = "";
|
||||||
|
@ -755,6 +756,7 @@ class CPushMod : public CModule
|
||||||
expr("last_notification", last_notification(context))
|
expr("last_notification", last_notification(context))
|
||||||
expr("nick_blacklist", nick_blacklist(nick))
|
expr("nick_blacklist", nick_blacklist(nick))
|
||||||
expr("replied", replied(context))
|
expr("replied", replied(context))
|
||||||
|
expr("context", context_filter(context))
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -852,6 +854,47 @@ class CPushMod : public CModule
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if the given context matches any context rules.
|
||||||
|
*
|
||||||
|
* @param context The context of a message
|
||||||
|
* @return True if context matches the filter
|
||||||
|
*/
|
||||||
|
bool context_filter(const CString& context)
|
||||||
|
{
|
||||||
|
if (context == "all" || context == "*")
|
||||||
|
return true;
|
||||||
|
|
||||||
|
VCString values;
|
||||||
|
options["context"].Split(" ", values, false);
|
||||||
|
|
||||||
|
for (VCString::iterator i = values.begin(); i != values.end(); i++)
|
||||||
|
{
|
||||||
|
CString value = i->AsLower();
|
||||||
|
char prefix = value[0];
|
||||||
|
bool push = true;
|
||||||
|
|
||||||
|
if (prefix == '-')
|
||||||
|
{
|
||||||
|
push = false;
|
||||||
|
value.LeftChomp(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (value != "*")
|
||||||
|
{
|
||||||
|
value = "*" + value.AsLower() + "*";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (context.WildCmp(value))
|
||||||
|
{
|
||||||
|
return push;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the idle condition is met.
|
* Check if the idle condition is met.
|
||||||
|
@ -971,6 +1014,7 @@ class CPushMod : public CModule
|
||||||
&& last_notification(context)
|
&& last_notification(context)
|
||||||
&& nick_blacklist(nick)
|
&& nick_blacklist(nick)
|
||||||
&& replied(context)
|
&& replied(context)
|
||||||
|
&& context_filter(context)
|
||||||
&& true;
|
&& true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue