]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_chanfilter.cpp
Update the cloaks of connected users when their IP address changes.
[user/henk/code/inspircd.git] / src / modules / m_chanfilter.cpp
index dd11cb5144e8c358a2440050e11120593cc446d2..42f43a76792d5c38d8f1bedb68497b1f685cca65 100644 (file)
 #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
@@ -46,7 +38,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;
@@ -54,21 +46,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 +53,7 @@ class ModuleChanFilter : public Module
        CheckExemption::EventProvider exemptionprov;
        ChanFilter cf;
        bool hidemask;
+       bool notifyuser;
 
  public:
 
@@ -89,7 +67,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 +91,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;
                                }
                        }