X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_chanfilter.cpp;h=051b8c60d0d9062f14f74c18d1749141c769b210;hb=d57cad7896a4e9f78565d998e3fbd98b0b32c94e;hp=dd11cb5144e8c358a2440050e11120593cc446d2;hpb=4132a44396d8fa3d23f87b5cbea5b928aa09769f;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_chanfilter.cpp b/src/modules/m_chanfilter.cpp index dd11cb514..051b8c60d 100644 --- a/src/modules/m_chanfilter.cpp +++ b/src/modules/m_chanfilter.cpp @@ -27,14 +27,6 @@ #include "listmode.h" #include "modules/exemption.h" -enum -{ - // InspIRCd-specific. - ERR_ALREADYCHANFILTERED = 937, - ERR_NOSUCHCHANFILTER = 938, - ERR_CHANFILTERFULL = 939 -}; - /** Handles channel mode +g */ class ChanFilter : public ListModeBase @@ -42,11 +34,14 @@ class ChanFilter : public ListModeBase public: unsigned long maxlen; - ChanFilter(Module* Creator) : ListModeBase(Creator, "filter", 'g', "End of channel spamfilter list", 941, 940, false, "chanfilter") { } + ChanFilter(Module* Creator) + : ListModeBase(Creator, "filter", 'g', "End of channel spamfilter list", 941, 940, false) + { + } 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; @@ -54,21 +49,6 @@ class ChanFilter : public ListModeBase return true; } - - void TellListTooLong(User* user, Channel* chan, std::string& word) CXX11_OVERRIDE - { - user->WriteNumeric(ERR_CHANFILTERFULL, chan->name, word, "Channel spamfilter list is full"); - } - - void TellAlreadyOnList(User* user, Channel* chan, std::string& word) CXX11_OVERRIDE - { - user->WriteNumeric(ERR_ALREADYCHANFILTERED, chan->name, InspIRCd::Format("The word %s is already on the spamfilter list", word.c_str())); - } - - void TellNotSet(User* user, Channel* chan, std::string& word) CXX11_OVERRIDE - { - user->WriteNumeric(ERR_NOSUCHCHANFILTER, chan->name, "No such spamfilter word is set"); - } }; class ModuleChanFilter : public Module @@ -76,6 +56,7 @@ class ModuleChanFilter : public Module CheckExemption::EventProvider exemptionprov; ChanFilter cf; bool hidemask; + bool notifyuser; public: @@ -89,7 +70,8 @@ class ModuleChanFilter : public Module { ConfigTag* tag = ServerInstance->Config->ConfValue("chanfilter"); hidemask = tag->getBool("hidemask"); - cf.maxlen = tag->getInt("maxlen", 35, 10, 100); + cf.maxlen = tag->getUInt("maxlen", 35, 10, 100); + notifyuser = tag->getBool("notifyuser", true); cf.DoRehash(); } @@ -112,10 +94,16 @@ class ModuleChanFilter : public Module { if (InspIRCd::Match(details.text, i->mask)) { + if (!notifyuser) + { + details.echo_original = true; + return MOD_RES_DENY; + } + if (hidemask) user->WriteNumeric(ERR_CANNOTSENDTOCHAN, chan->name, "Cannot send to channel (your message contained a censored word)"); else - user->WriteNumeric(ERR_CANNOTSENDTOCHAN, chan->name, i->mask, "Cannot send to channel (your message contained a censored word)"); + user->WriteNumeric(ERR_CANNOTSENDTOCHAN, chan->name, "Cannot send to channel (your message contained a censored word: " + i->mask + ")"); return MOD_RES_DENY; } }