]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_shun.cpp
Use consistent numerics when a mode already exists or doesn't exist.
[user/henk/code/inspircd.git] / src / modules / m_shun.cpp
index d68f58dd463657d3d27a3057bfb5f5accaec4afc..da090e4f870af5b3e3c2ff5b81b083a6b4867865 100644 (file)
 
 #include "inspircd.h"
 #include "xline.h"
+#include "modules/shun.h"
+#include "modules/stats.h"
 
-class Shun : public XLine
-{
-public:
-       std::string matchtext;
-
-       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)
-       {
-       }
-
-       bool Matches(User* u) CXX11_OVERRIDE
-       {
-               // E: overrides shun
-               LocalUser* lu = IS_LOCAL(u);
-               if (lu && lu->exempt)
-                       return false;
-
-               if (InspIRCd::Match(u->GetFullHost(), matchtext) || InspIRCd::Match(u->GetFullRealHost(), matchtext) || InspIRCd::Match(u->nick+"!"+u->ident+"@"+u->GetIPString(), matchtext))
-                       return true;
-
-               if (InspIRCd::MatchCIDR(u->GetIPString(), matchtext, ascii_case_insensitive_map))
-                       return true;
-
-               return false;
-       }
-
-       bool Matches(const std::string& s) CXX11_OVERRIDE
-       {
-               if (matchtext == s)
-                       return true;
-               return false;
-       }
-
-       const std::string& Displayable() CXX11_OVERRIDE
-       {
-               return matchtext;
-       }
-};
 
 /** An XLineFactory specialized to generate shun pointers
  */
@@ -93,7 +56,7 @@ class CommandShun : public Command
                flags_needed = 'o'; this->syntax = "<nick!user@hostmask> [<shun-duration>] :<reason>";
        }
 
-       CmdResult Handle(const std::vector<std::string>& parameters, User* user) CXX11_OVERRIDE
+       CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE
        {
                /* syntax: SHUN nick!user@host time :reason goes here */
                /* 'time' is a human-readable timestring, like 2d3h2s. */
@@ -162,7 +125,7 @@ class CommandShun : public Command
                return CMD_SUCCESS;
        }
 
-       RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters) CXX11_OVERRIDE
+       RouteDescriptor GetRouting(User* user, const Params& parameters) CXX11_OVERRIDE
        {
                if (IS_LOCAL(user))
                        return ROUTE_LOCALONLY; // spanningtree will send ADDLINE
@@ -171,7 +134,7 @@ class CommandShun : public Command
        }
 };
 
-class ModuleShun : public Module
+class ModuleShun : public Module, public Stats::EventListener
 {
        CommandShun cmd;
        ShunFactory f;
@@ -180,7 +143,9 @@ class ModuleShun : public Module
        bool affectopers;
 
  public:
-       ModuleShun() : cmd(this)
+       ModuleShun()
+               : Stats::EventListener(this)
+               , cmd(this)
        {
        }
 
@@ -233,7 +198,7 @@ class ModuleShun : public Module
                affectopers = tag->getBool("affectopers", false);
        }
 
-       ModResult OnPreCommand(std::string &command, std::vector<std::string>& parameters, LocalUser* user, bool validated, const std::string &original_line) CXX11_OVERRIDE
+       ModResult OnPreCommand(std::string& command, CommandBase::Params& parameters, LocalUser* user, bool validated) CXX11_OVERRIDE
        {
                if (validated)
                        return MOD_RES_PASSTHRU;
@@ -265,7 +230,7 @@ class ModuleShun : public Module
                else if ((command == "PART") && (parameters.size() > 1))
                {
                        /* same for PART */
-                       parameters[1].clear();
+                       parameters.pop_back();
                }
 
                /* if we're here, allow the command. */