mirror of https://github.com/SeanOMik/znc-push.git
Implemented configurable highlight terms
This commit is contained in:
parent
74c813a656
commit
06fac8b254
25
README.md
25
README.md
|
@ -115,6 +115,31 @@ Configuration
|
||||||
Notifications will only be sent if the number of connected IRC clients is less than this
|
Notifications will only be sent if the number of connected IRC clients is less than this
|
||||||
value. A value of 0 (zero) will disable this condition.
|
value. A value of 0 (zero) will disable this condition.
|
||||||
|
|
||||||
|
* `highlight = ""`
|
||||||
|
|
||||||
|
Space-separated list of highlight strings to match against channel messages 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:
|
||||||
|
|
||||||
|
* `-` (hypen) to negate the match, which makes the string act as a filter rather than
|
||||||
|
a search
|
||||||
|
|
||||||
|
* `_` (underscore) to trigger a "whole-word" match, where it must be surrounded by
|
||||||
|
whitespace to match the value
|
||||||
|
|
||||||
|
* `*` (asterisk) to match highlight strings that start with any of the above prefixes
|
||||||
|
|
||||||
|
As an example, a highlight value of "-pinto car" will trigger notification on the
|
||||||
|
message "I like cars", but will prevent notifications for "My favorite car is the Pinto"
|
||||||
|
*and* "I like pinto beans". Conversely, a highlight value of "car -pinto" will trigger
|
||||||
|
notifications for the first two messages, and only prevent notification of the last one.
|
||||||
|
|
||||||
|
As another example, a value of "_car" will trigger notification for the message "my car
|
||||||
|
is awesome", but will not match the message "I like cars".
|
||||||
|
|
||||||
* `idle = 0`
|
* `idle = 0`
|
||||||
|
|
||||||
Time in seconds since the last activity by the user on any channel or query window,
|
Time in seconds since the last activity by the user on any channel or query window,
|
||||||
|
|
30
notifo.cpp
30
notifo.cpp
|
@ -85,6 +85,7 @@ class CNotifoMod : public CModule
|
||||||
defaults["away_only"] = "no";
|
defaults["away_only"] = "no";
|
||||||
#endif
|
#endif
|
||||||
defaults["client_count_less_than"] = "0";
|
defaults["client_count_less_than"] = "0";
|
||||||
|
defaults["highlight"] = "";
|
||||||
defaults["idle"] = "0";
|
defaults["idle"] = "0";
|
||||||
defaults["last_active"] = "180";
|
defaults["last_active"] = "180";
|
||||||
defaults["last_notification"] = "300";
|
defaults["last_notification"] = "300";
|
||||||
|
@ -212,6 +213,35 @@ class CNotifoMod : public CModule
|
||||||
*/
|
*/
|
||||||
bool highlight(const CString& message)
|
bool highlight(const CString& message)
|
||||||
{
|
{
|
||||||
|
CString msg = " " + message.AsLower() + " ";
|
||||||
|
|
||||||
|
VCString values;
|
||||||
|
options["highlight"].Split(" ", values, false);
|
||||||
|
|
||||||
|
for (VCString::iterator i = values.begin(); i != values.end(); i++)
|
||||||
|
{
|
||||||
|
CString value = i->AsLower();
|
||||||
|
char prefix = value[0];
|
||||||
|
bool notify = true;
|
||||||
|
|
||||||
|
if (prefix == '-')
|
||||||
|
{
|
||||||
|
notify = false;
|
||||||
|
value.LeftChomp(1);
|
||||||
|
}
|
||||||
|
else if (prefix == '_')
|
||||||
|
{
|
||||||
|
value = " " + value.LeftChomp_n(1) + " ";
|
||||||
|
}
|
||||||
|
|
||||||
|
value = "*" + value + "*";
|
||||||
|
|
||||||
|
if (msg.WildCmp(value))
|
||||||
|
{
|
||||||
|
return notify;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
CNick nick = user->GetIRCNick();
|
CNick nick = user->GetIRCNick();
|
||||||
|
|
||||||
if (message.find(nick.GetNick()) != string::npos)
|
if (message.find(nick.GetNick()) != string::npos)
|
||||||
|
|
Loading…
Reference in New Issue