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 /src/modules | |
parent | 49c35af6af8c5207c7c7c0fe41c041b2134262d6 (diff) |
Optionally do not notify users if their messages are blocked by certain modules (#1134).
Closes #711.
Diffstat (limited to 'src/modules')
-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 |
3 files changed, 36 insertions, 8 deletions
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; } |