]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_chanfilter.cpp
Rename the spanningtree module header to server.
[user/henk/code/inspircd.git] / src / modules / m_chanfilter.cpp
index 53428a5a871af08f19274155a4a7ebb31ba810bb..133c5180dd10338730378e333d20b0e0438053fb 100644 (file)
@@ -25,6 +25,7 @@
 
 #include "inspircd.h"
 #include "listmode.h"
+#include "modules/exemption.h"
 
 /** Handles channel mode +g
  */
@@ -33,42 +34,43 @@ class ChanFilter : public ListModeBase
  public:
        ChanFilter(Module* Creator) : ListModeBase(Creator, "filter", 'g', "End of channel spamfilter list", 941, 940, false, "chanfilter") { }
 
-       bool ValidateParam(User* user, Channel* chan, std::string &word)
-       {
+       bool ValidateParam(User* user, Channel* chan, std::string& word) CXX11_OVERRIDE {
                if (word.length() > 35)
                {
-                       user->WriteNumeric(935, "%s %s :word is too long for censor list", chan->name.c_str(), word.c_str());
+                       user->WriteNumeric(935, chan->name, word, "%word is too long for censor list");
                        return false;
                }
 
                return true;
        }
 
-       void TellListTooLong(User* user, Channel* chan, std::string &word)
+       void TellListTooLong(User* user, Channel* chan, std::string& word) CXX11_OVERRIDE
        {
-               user->WriteNumeric(939, "%s %s :Channel spamfilter list is full", chan->name.c_str(), word.c_str());
+               user->WriteNumeric(939, chan->name, word, "Channel spamfilter list is full");
        }
 
-       void TellAlreadyOnList(User* user, Channel* chan, std::string &word)
+       void TellAlreadyOnList(User* user, Channel* chan, std::string& word) CXX11_OVERRIDE
        {
-               user->WriteNumeric(937, "%s :The word %s is already on the spamfilter list", chan->name.c_str(), word.c_str());
+               user->WriteNumeric(937, 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)
+       void TellNotSet(User* user, Channel* chan, std::string& word) CXX11_OVERRIDE
        {
-               user->WriteNumeric(938, "%s :No such spamfilter word is set", chan->name.c_str());
+               user->WriteNumeric(938, chan->name, "No such spamfilter word is set");
        }
 };
 
 class ModuleChanFilter : public Module
 {
+       CheckExemption::EventProvider exemptionprov;
        ChanFilter cf;
        bool hidemask;
 
  public:
 
        ModuleChanFilter()
-               : cf(this)
+               : exemptionprov(this)
+               , cf(this)
        {
        }
 
@@ -84,7 +86,7 @@ class ModuleChanFilter : public Module
                        return MOD_RES_PASSTHRU;
 
                Channel* chan = static_cast<Channel*>(dest);
-               ModResult res = ServerInstance->OnCheckExemption(user,chan,"filter");
+               ModResult res = CheckExemption::Call(exemptionprov, user, chan, "filter");
 
                if (!IS_LOCAL(user) || res == MOD_RES_ALLOW)
                        return MOD_RES_PASSTHRU;
@@ -98,9 +100,9 @@ class ModuleChanFilter : public Module
                                if (InspIRCd::Match(text, i->mask))
                                {
                                        if (hidemask)
-                                               user->WriteNumeric(ERR_CANNOTSENDTOCHAN, "%s :Cannot send to channel (your message contained a censored word)", chan->name.c_str());
+                                               user->WriteNumeric(ERR_CANNOTSENDTOCHAN, chan->name, "Cannot send to channel (your message contained a censored word)");
                                        else
-                                               user->WriteNumeric(ERR_CANNOTSENDTOCHAN, "%s %s :Cannot send to channel (your message contained a censored word)", chan->name.c_str(), i->mask.c_str());
+                                               user->WriteNumeric(ERR_CANNOTSENDTOCHAN, chan->name, i->mask, "Cannot send to channel (your message contained a censored word)");
                                        return MOD_RES_DENY;
                                }
                        }