]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_shun.cpp
Remove InspIRCd* parameters and fields
[user/henk/code/inspircd.git] / src / modules / m_shun.cpp
index 8a0ca2aa3b8634b86235ca1a1964093fbc175412..599d665a114eff445b31f0d97a14b63d7f5fe874 100644 (file)
@@ -21,8 +21,8 @@ class Shun : public XLine
 public:
        std::string matchtext;
 
-       Shun(InspIRCd* Instance, time_t s_time, long d, std::string src, std::string re, std::string shunmask)
-               : XLine(Instance, s_time, d, src, re, "SHUN")
+       Shun(time_t s_time, long d, std::string src, std::string re, std::string shunmask)
+               : XLine(s_time, d, src, re, "SHUN")
        {
                this->matchtext = shunmask;
        }
@@ -72,13 +72,13 @@ public:
 class ShunFactory : public XLineFactory
 {
  public:
-       ShunFactory(InspIRCd* Instance) : XLineFactory(Instance, "SHUN") { }
+       ShunFactory() : XLineFactory("SHUN") { }
 
        /** Generate a shun
        */
        XLine* Generate(time_t set_time, long duration, std::string source, std::string reason, std::string xline_specific_mask)
        {
-               return new Shun(ServerInstance, set_time, duration, source, reason, xline_specific_mask);
+               return new Shun(set_time, duration, source, reason, xline_specific_mask);
        }
 };
 
@@ -87,10 +87,9 @@ class ShunFactory : public XLineFactory
 class CommandShun : public Command
 {
  public:
-       CommandShun(InspIRCd* Me) : Command(Me, "SHUN", "o", 1, 3)
+       CommandShun(Module* Creator) : Command(Creator, "SHUN", 1, 3)
        {
-               this->source = "m_shun.so";
-               this->syntax = "<nick!user@hostmask> [<shun-duration>] :<reason>";
+               flags_needed = 'o'; this->syntax = "<nick!user@hostmask> [<shun-duration>] :<reason>";
        }
 
        CmdResult Handle(const std::vector<std::string>& parameters, User *user)
@@ -108,7 +107,7 @@ class CommandShun : public Command
                {
                        if (ServerInstance->XLines->DelLine(target.c_str(), "SHUN", user))
                        {
-                               ServerInstance->SNO->WriteToSnoMask('x',"%s Removed shun on %s.",user->nick.c_str(),target.c_str());
+                               ServerInstance->SNO->WriteToSnoMask('x',"%s removed SHUN on %s",user->nick.c_str(),target.c_str());
                        }
                        else
                        {
@@ -137,7 +136,7 @@ class CommandShun : public Command
 
                        try
                        {
-                               r = new Shun(ServerInstance, ServerInstance->Time(), duration, user->nick.c_str(), expr.c_str(), target.c_str());
+                               r = new Shun(ServerInstance->Time(), duration, user->nick.c_str(), expr.c_str(), target.c_str());
                        }
                        catch (...)
                        {
@@ -150,13 +149,13 @@ class CommandShun : public Command
                                {
                                        if (!duration)
                                        {
-                                               ServerInstance->SNO->WriteToSnoMask('x',"%s added permanent shun for %s: %s",
+                                               ServerInstance->SNO->WriteToSnoMask('x',"%s added permanent SHUN for %s: %s",
                                                        user->nick.c_str(), target.c_str(), expr.c_str());
                                        }
                                        else
                                        {
                                                time_t c_requires_crap = duration + ServerInstance->Time();
-                                               ServerInstance->SNO->WriteToSnoMask('x', "%s added timed shun for %s, expires on %s: %s",
+                                               ServerInstance->SNO->WriteToSnoMask('x', "%s added timed SHUN for %s to expire on %s: %s",
                                                        user->nick.c_str(), target.c_str(), ServerInstance->TimeString(c_requires_crap).c_str(), expr.c_str());
                                        }
 
@@ -172,6 +171,11 @@ class CommandShun : public Command
 
                return CMD_FAILURE;
        }
+
+       RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters)
+       {
+               return ROUTE_BROADCAST;
+       }
 };
 
 class ModuleShun : public Module
@@ -183,7 +187,7 @@ class ModuleShun : public Module
        bool affectopers;
 
  public:
-       ModuleShun(InspIRCd* Me) : Module(Me), cmd(Me), f(Me)
+       ModuleShun() : cmd(this)
        {
                ServerInstance->XLines->RegisterFactory(&f);
                ServerInstance->AddCommand(&cmd);
@@ -199,18 +203,18 @@ class ModuleShun : public Module
                ServerInstance->XLines->UnregisterFactory(&f);
        }
 
-       virtual int OnStats(char symbol, User* user, string_list& out)
+       virtual ModResult OnStats(char symbol, User* user, string_list& out)
        {
                if (symbol != 'S')
-                       return 0;
+                       return MOD_RES_PASSTHRU;
 
                ServerInstance->XLines->InvokeStats("SHUN", 223, user, out);
-               return 1;
+               return MOD_RES_DENY;
        }
 
        virtual void OnRehash(User* user)
        {
-               ConfigReader MyConf(ServerInstance);
+               ConfigReader MyConf;
                std::string cmds = MyConf.ReadValue("shun", "enabledcommands", 0);
 
                if (cmds.empty())
@@ -247,21 +251,21 @@ class ModuleShun : public Module
                }
        }
 
-       virtual int OnPreCommand(std::string &command, std::vector<std::string>& parameters, User* user, bool validated, const std::string &original_line)
+       virtual ModResult OnPreCommand(std::string &command, std::vector<std::string>& parameters, User* user, bool validated, const std::string &original_line)
        {
                if (validated)
-                       return 0;
+                       return MOD_RES_PASSTHRU;
 
                if (!ServerInstance->XLines->MatchesLine("SHUN", user))
                {
                        /* Not shunned, don't touch. */
-                       return 0;
+                       return MOD_RES_PASSTHRU;
                }
 
                if (!affectopers && IS_OPER(user))
                {
                        /* Don't do anything if the user is an operator and affectopers isn't set */
-                       return 0;
+                       return MOD_RES_PASSTHRU;
                }
 
                std::set<std::string>::iterator i = ShunEnabledCommands.find(command);
@@ -270,7 +274,7 @@ class ModuleShun : public Module
                {
                        if (NotifyOfShun)
                                user->WriteServ("NOTICE %s :*** Command %s not processed, as you have been blocked from issuing commands (SHUN)", user->nick.c_str(), command.c_str());
-                       return 1;
+                       return MOD_RES_DENY;
                }
 
                if (command == "QUIT")
@@ -285,12 +289,12 @@ class ModuleShun : public Module
                }
 
                /* if we're here, allow the command. */
-               return 0;
+               return MOD_RES_PASSTHRU;
        }
 
        virtual Version GetVersion()
        {
-               return Version("$Id$",VF_VENDOR|VF_COMMON,API_VERSION);
+               return Version("Provides the /shun command, which stops a user executing all commands except PING and PONG.",VF_VENDOR|VF_COMMON,API_VERSION);
        }
 };