]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_shun.cpp
Merge branch 'master+listmode'
[user/henk/code/inspircd.git] / src / modules / m_shun.cpp
index e7dc3086dd079b78569b66895a3d8525e64d0aca..7ea16b5b038e8c8fbabe6eb349ed49cba37f84c7 100644 (file)
 #include "inspircd.h"
 #include "xline.h"
 
-/* $ModDesc: Provides the /SHUN command, which stops a user from executing all except configured commands. */
-
 class Shun : public XLine
 {
 public:
        std::string matchtext;
 
-       Shun(time_t s_time, long d, std::string src, std::string re, std::string shunmask)
+       Shun(time_t s_time, long d, const std::string& src, const std::string& re, const std::string& shunmask)
                : XLine(s_time, d, src, re, "SHUN")
+               , matchtext(shunmask)
        {
-               this->matchtext = shunmask;
        }
 
        bool Matches(User *u)
@@ -56,9 +54,9 @@ public:
                return false;
        }
 
-       const char* Displayable()
+       const std::string& Displayable()
        {
-               return matchtext.c_str();
+               return matchtext;
        }
 };
 
@@ -142,7 +140,7 @@ class CommandShun : public Command
                                else
                                {
                                        time_t c_requires_crap = duration + ServerInstance->Time();
-                                       std::string timestr = ServerInstance->TimeString(c_requires_crap);
+                                       std::string timestr = InspIRCd::TimeString(c_requires_crap);
                                        ServerInstance->SNO->WriteToSnoMask('x', "%s added timed SHUN for %s to expire on %s: %s",
                                                user->nick.c_str(), target.c_str(), timestr.c_str(), expr.c_str());
                                }
@@ -170,7 +168,7 @@ class ModuleShun : public Module
 {
        CommandShun cmd;
        ShunFactory f;
-       std::set<std::string> ShunEnabledCommands;
+       insp::flat_set<std::string> ShunEnabledCommands;
        bool NotifyOfShun;
        bool affectopers;
 
@@ -182,11 +180,6 @@ class ModuleShun : public Module
        void init() CXX11_OVERRIDE
        {
                ServerInstance->XLines->RegisterFactory(&f);
-               ServerInstance->Modules->AddService(cmd);
-
-               Implementation eventlist[] = { I_OnStats, I_OnPreCommand, I_OnRehash };
-               ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
-               OnRehash(NULL);
        }
 
        ~ModuleShun()
@@ -210,7 +203,7 @@ class ModuleShun : public Module
                return MOD_RES_DENY;
        }
 
-       void OnRehash(User* user) CXX11_OVERRIDE
+       void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE
        {
                ConfigTag* tag = ServerInstance->Config->ConfValue("shun");
                std::string cmds = tag->getString("enabledcommands");
@@ -250,9 +243,7 @@ class ModuleShun : public Module
                        return MOD_RES_PASSTHRU;
                }
 
-               std::set<std::string>::iterator i = ShunEnabledCommands.find(command);
-
-               if (i == ShunEnabledCommands.end())
+               if (!ShunEnabledCommands.count(command))
                {
                        if (NotifyOfShun)
                                user->WriteNotice("*** Command " + command + " not processed, as you have been blocked from issuing commands (SHUN)");