diff options
author | Robby <Robby-@users.noreply.github.com> | 2018-04-20 16:28:28 +0200 |
---|---|---|
committer | Peter Powell <petpow@saberuk.com> | 2018-04-20 15:28:28 +0100 |
commit | 46e71e2f509eb38166fafcc69931117f0f9b7798 (patch) | |
tree | 551fb4cc8463997e095b38fb4c9dcf35773cb598 | |
parent | 49c35af6af8c5207c7c7c0fe41c041b2134262d6 (diff) |
Optionally do not notify users if their messages are blocked by certain modules (#1134).
Closes #711.
-rw-r--r-- | docs/conf/modules.conf.example | 19 | ||||
-rw-r--r-- | src/modules/m_chanfilter.cpp | 10 | ||||
-rw-r--r-- | src/modules/m_filter.cpp | 27 | ||||
-rw-r--r-- | src/modules/m_muteban.cpp | 7 |
4 files changed, 50 insertions, 13 deletions
diff --git a/docs/conf/modules.conf.example b/docs/conf/modules.conf.example index d4b254134..da72775e9 100644 --- a/docs/conf/modules.conf.example +++ b/docs/conf/modules.conf.example @@ -402,7 +402,10 @@ # his/her message is blocked. # # If maxlen is set then it defines the maximum length of a filter entry. -#<chanfilter hidemask="yes" maxlen="50"> +# +# If notifyuser is set to no, the user will not be notified when +# his/her message is blocked. +#<chanfilter hidemask="yes" maxlen="50" notifyuser="yes"> #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-# # Channel history module: Displays the last 'X' lines of chat to a user @@ -785,14 +788,16 @@ # stdlib - stdlib regexps, provided via regex_stdlib, see comment # # at the <module> tag for info on availability. # # # -#<filteropts engine="glob"> # +# If notifyuser is set to no, the user will not be notified when # +# his/her message is blocked. # +#<filteropts engine="glob" notifyuser="yes"> +# # +# Your choice of regex engine must match on all servers network-wide. # # # -# Your choice of regex engine must match on all servers network-wide. -# # To learn more about the configuration of this module, read # # examples/filter.conf.example, which covers the various types of # # filters and shows how to add exemptions. # -# +# # #-#-#-#-#-#-#-#-#-#-#- FILTER CONFIGURATION -#-#-#-#-#-#-#-#-#-#-#-# # # # Optional - If you specify to use the filter module, then # @@ -1536,6 +1541,10 @@ # Muteban: Implements extended ban 'm', which stops anyone matching # a mask like +b m:nick!user@host from speaking on channel. #<module name="muteban"> +# +# If notifyuser is set to no, the user will not be notified when +# his/her message is blocked. +#<muteban notifyuser="yes"> #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-# # Random quote module: Provides a random quote on connect. diff --git a/src/modules/m_chanfilter.cpp b/src/modules/m_chanfilter.cpp index ce2387004..55b6d3d2f 100644 --- a/src/modules/m_chanfilter.cpp +++ b/src/modules/m_chanfilter.cpp @@ -46,7 +46,7 @@ class ChanFilter : public ListModeBase bool ValidateParam(User* user, Channel* chan, std::string& word) CXX11_OVERRIDE { - if (word.length() > maxlen) + if (word.length() > maxlen) { user->WriteNumeric(Numerics::InvalidModeParameter(chan, this, word, "Word is too long for the spamfilter list")); return false; @@ -76,6 +76,7 @@ class ModuleChanFilter : public Module CheckExemption::EventProvider exemptionprov; ChanFilter cf; bool hidemask; + bool notifyuser; public: @@ -90,6 +91,7 @@ class ModuleChanFilter : public Module ConfigTag* tag = ServerInstance->Config->ConfValue("chanfilter"); hidemask = tag->getBool("hidemask"); cf.maxlen = tag->getUInt("maxlen", 35, 10, 100); + notifyuser = tag->getBool("notifyuser", true); cf.DoRehash(); } @@ -112,6 +114,12 @@ class ModuleChanFilter : public Module { if (InspIRCd::Match(details.text, i->mask)) { + if (!notifyuser) + { + details.echooriginal = true; + return MOD_RES_DENY; + } + if (hidemask) user->WriteNumeric(ERR_CANNOTSENDTOCHAN, chan->name, "Cannot send to channel (your message contained a censored word)"); else diff --git a/src/modules/m_filter.cpp b/src/modules/m_filter.cpp index d3d3ef218..0d0b7ae60 100644 --- a/src/modules/m_filter.cpp +++ b/src/modules/m_filter.cpp @@ -166,6 +166,7 @@ class ModuleFilter : public Module, public ServerEventListener, public Stats::Ev typedef insp::flat_set<std::string, irc::insensitive_swo> ExemptTargetSet; bool initing; + bool notifyuser; RegexFactory* factory; void FreeFilters(); @@ -356,17 +357,27 @@ ModResult ModuleFilter::OnUserPreMessage(User* user, const MessageTarget& msgtar if (f->action == FA_BLOCK) { ServerInstance->SNO->WriteGlobalSno('a', "FILTER: "+user->nick+" had their message filtered, target was "+target+": "+f->reason); - if (msgtarget.type == MessageTarget::TYPE_CHANNEL) - user->WriteNumeric(ERR_CANNOTSENDTOCHAN, target, InspIRCd::Format("Message to channel blocked and opers notified (%s)", f->reason.c_str())); + if (notifyuser) + { + if (msgtarget.type == MessageTarget::TYPE_CHANNEL) + user->WriteNumeric(ERR_CANNOTSENDTOCHAN, target, InspIRCd::Format("Message to channel blocked and opers notified (%s)", f->reason.c_str())); + else + user->WriteNotice("Your message to "+target+" was blocked and opers notified: "+f->reason); + } else - user->WriteNotice("Your message to "+target+" was blocked and opers notified: "+f->reason); + details.echooriginal = true; } else if (f->action == FA_SILENT) { - if (msgtarget.type == MessageTarget::TYPE_CHANNEL) - user->WriteNumeric(ERR_CANNOTSENDTOCHAN, target, InspIRCd::Format("Message to channel blocked (%s)", f->reason.c_str())); + if (notifyuser) + { + if (msgtarget.type == MessageTarget::TYPE_CHANNEL) + user->WriteNumeric(ERR_CANNOTSENDTOCHAN, target, InspIRCd::Format("Message to channel blocked (%s)", f->reason.c_str())); + else + user->WriteNotice("Your message to "+target+" was blocked: "+f->reason); + } else - user->WriteNotice("Your message to "+target+" was blocked: "+f->reason); + details.echooriginal = true; } else if (f->action == FA_KILL) { @@ -508,7 +519,9 @@ void ModuleFilter::ReadConfig(ConfigStatus& status) } } - std::string newrxengine = ServerInstance->Config->ConfValue("filteropts")->getString("engine"); + ConfigTag* tag = ServerInstance->Config->ConfValue("filteropts"); + std::string newrxengine = tag->getString("engine"); + notifyuser = tag->getBool("notifyuser", true); factory = RegexEngine ? (RegexEngine.operator->()) : NULL; diff --git a/src/modules/m_muteban.cpp b/src/modules/m_muteban.cpp index 045666f89..aebc00462 100644 --- a/src/modules/m_muteban.cpp +++ b/src/modules/m_muteban.cpp @@ -36,6 +36,13 @@ class ModuleQuietBan : public Module Channel* chan = target.Get<Channel>(); if (chan->GetExtBanStatus(user, 'm') == MOD_RES_DENY && chan->GetPrefixValue(user) < VOICE_VALUE) { + bool notifyuser = ServerInstance->Config->ConfValue("muteban")->getBool("notifyuser", true); + if (!notifyuser) + { + details.echooriginal = true; + return MOD_RES_DENY; + } + user->WriteNumeric(ERR_CANNOTSENDTOCHAN, chan->name, "Cannot send to channel (you're muted)"); return MOD_RES_DENY; } |