]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_silence.cpp
Replace hardcoded mode letters passed to IsModeSet() and GetModeParameter() with...
[user/henk/code/inspircd.git] / src / modules / m_silence.cpp
index d1885269d04975ea035c302688338e4f5f8718fa..b0ce8f56c2b3a20ab050147f6f706cd98c204c67 100644 (file)
@@ -66,7 +66,7 @@ class CommandSVSSilence : public Command
        CommandSVSSilence(Module* Creator) : Command(Creator,"SVSSILENCE", 2)
        {
                syntax = "<target> {[+|-]<mask> <p|c|i|n|t|a|x>}";
-               TRANSLATE4(TR_NICK, TR_TEXT, TR_TEXT, TR_END); /* we watch for a nick. not a UID. */
+               TRANSLATE3(TR_NICK, TR_TEXT, TR_TEXT);
        }
 
        CmdResult Handle (const std::vector<std::string>& parameters, User *user)
@@ -112,7 +112,6 @@ class CommandSilence : public Command
        {
                allow_empty_last_param = false;
                syntax = "{[+|-]<mask> <p|c|i|n|t|a|x>}";
-               TRANSLATE3(TR_TEXT, TR_TEXT, TR_END);
        }
 
        CmdResult Handle (const std::vector<std::string>& parameters, User *user)
@@ -149,7 +148,7 @@ class CommandSilence : public Command
 
                        if (pattern == 0)
                        {
-                               user->WriteServ("NOTICE %s :Bad SILENCE pattern",user->nick.c_str());
+                               user->WriteNotice("Bad SILENCE pattern");
                                return CMD_INVALID;
                        }
 
@@ -302,25 +301,25 @@ class ModuleSilence : public Module
        {
        }
 
-       void init()
+       void init() CXX11_OVERRIDE
        {
                OnRehash(NULL);
                ServerInstance->Modules->AddService(cmdsilence);
                ServerInstance->Modules->AddService(cmdsvssilence);
                ServerInstance->Modules->AddService(cmdsilence.ext);
 
-               Implementation eventlist[] = { I_OnRehash, I_On005Numeric, I_OnUserPreNotice, I_OnUserPreMessage, I_OnUserPreInvite };
+               Implementation eventlist[] = { I_OnRehash, I_On005Numeric, I_OnUserPreMessage, I_OnUserPreInvite };
                ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
        }
 
-       void OnRehash(User* user)
+       void OnRehash(User* user) CXX11_OVERRIDE
        {
                maxsilence = ServerInstance->Config->ConfValue("showwhois")->getInt("maxentries", 32);
                if (!maxsilence)
                        maxsilence = 32;
        }
 
-       void On005Numeric(std::map<std::string, std::string>& tokens)
+       void On005Numeric(std::map<std::string, std::string>& tokens) CXX11_OVERRIDE
        {
                tokens["ESILENCE"];
                tokens["SILENCE"] = ConvToStr(maxsilence);
@@ -343,34 +342,24 @@ class ModuleSilence : public Module
                }
        }
 
-       ModResult PreText(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list, int silence_type)
+       ModResult OnUserPreMessage(User* user, void* dest, int target_type, std::string& text, char status, CUList& exempt_list, MessageType msgtype) CXX11_OVERRIDE
        {
                if (target_type == TYPE_USER && IS_LOCAL(((User*)dest)))
                {
-                       return MatchPattern((User*)dest, user, silence_type);
+                       return MatchPattern((User*)dest, user, ((msgtype == MSG_PRIVMSG) ? SILENCE_PRIVATE : SILENCE_NOTICE));
                }
                else if (target_type == TYPE_CHANNEL)
                {
                        Channel* chan = (Channel*)dest;
                        if (chan)
                        {
-                               this->OnBuildExemptList((silence_type == SILENCE_PRIVATE ? MSG_PRIVMSG : MSG_NOTICE), chan, user, status, exempt_list, "");
+                               this->OnBuildExemptList(msgtype, chan, user, status, exempt_list, "");
                        }
                }
                return MOD_RES_PASSTHRU;
        }
 
-       ModResult OnUserPreMessage(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
-       {
-               return PreText(user, dest, target_type, text, status, exempt_list, SILENCE_PRIVATE);
-       }
-
-       ModResult OnUserPreNotice(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
-       {
-               return PreText(user, dest, target_type, text, status, exempt_list, SILENCE_NOTICE);
-       }
-
-       ModResult OnUserPreInvite(User* source,User* dest,Channel* channel, time_t timeout)
+       ModResult OnUserPreInvite(User* source,User* dest,Channel* channel, time_t timeout) CXX11_OVERRIDE
        {
                return MatchPattern(dest, source, SILENCE_INVITE);
        }
@@ -393,7 +382,7 @@ class ModuleSilence : public Module
                return MOD_RES_PASSTHRU;
        }
 
-       Version GetVersion()
+       Version GetVersion() CXX11_OVERRIDE
        {
                return Version("Provides support for the /SILENCE command", VF_OPTCOMMON | VF_VENDOR);
        }