From 18cbe2d61b84174c0aff110bdcbdf2a1b16f6cf5 Mon Sep 17 00:00:00 2001 From: Daniel Bugl Date: Sun, 5 Jul 2015 19:39:30 +0000 Subject: [PATCH] implement network_blacklist --- push.cpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/push.cpp b/push.cpp index a6ba360..8aa5181 100755 --- a/push.cpp +++ b/push.cpp @@ -145,6 +145,7 @@ class CPushMod : public CModule defaults["last_active"] = "180"; defaults["last_notification"] = "300"; defaults["nick_blacklist"] = ""; + defaults["network_blacklist"] = ""; defaults["replied"] = "yes"; defaults["context"] = "*"; @@ -755,6 +756,7 @@ class CPushMod : public CModule expr("last_active", last_active(context)) expr("last_notification", last_notification(context)) expr("nick_blacklist", nick_blacklist(nick)) + expr("network_blacklist", network_blacklist()) expr("replied", replied(context)) expr("context", context_filter(context)) @@ -973,6 +975,30 @@ class CPushMod : public CModule return true; } + + /** + * Check if the network_blacklist condition is met. + * + * @param network Network that the message was received on + * @return True if network is not in the blacklist + */ + bool network_blacklist() + { + VCString blacklist; + options["network_blacklist"].Split(" ", blacklist, false); + + CString name = (*m_pNetwork).GetName().AsLower(); + + for (VCString::iterator i = blacklist.begin(); i != blacklist.end(); i++) + { + if (name.WildCmp((*i).AsLower())) + { + return false; + } + } + + return true; + } /** * Check if the replied condition is met. @@ -1013,6 +1039,7 @@ class CPushMod : public CModule && last_active(context) && last_notification(context) && nick_blacklist(nick) + && network_blacklist() && replied(context) && context_filter(context) && true; @@ -1040,6 +1067,7 @@ class CPushMod : public CModule && last_active(context) && last_notification(context) && nick_blacklist(nick) + && network_blacklist() && replied(context) && true; } @@ -1564,6 +1592,11 @@ class CPushMod : public CModule table.AddRow(); table.SetCell("Condition", "idle"); table.SetCell("Status", CString(ago) + " seconds"); + + table.AddRow(); + table.SetCell("Condition", "network_blacklist"); + // network_blacklist() is True if the network is not in a blacklist + table.SetCell("Status", network_blacklist() ? "no" : "yes"); if (token_count > 1) {