]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_cban.cpp
m_spanningtree Remove unneeded #includes
[user/henk/code/inspircd.git] / src / modules / m_cban.cpp
index 92f97158ecf123758a39f992d41293d2eed2ccc0..1ecb7f9d40c4feb4a73f568839304258027c34ae 100644 (file)
@@ -38,10 +38,6 @@ public:
                this->matchtext = ch.c_str();
        }
 
-       ~CBan()
-       {
-       }
-
        // XXX I shouldn't have to define this
        bool Matches(User *u)
        {
@@ -55,12 +51,6 @@ public:
                return false;
        }
 
-       void DisplayExpiry()
-       {
-               ServerInstance->SNO->WriteToSnoMask('x',"Removing expired CBan %s (set by %s %ld seconds ago)",
-                       this->matchtext.c_str(), this->source.c_str(), (long int)(ServerInstance->Time() - this->set_time));
-       }
-
        const char* Displayable()
        {
                return matchtext.c_str();
@@ -118,7 +108,7 @@ class CommandCBan : public Command
                else
                {
                        // Adding - XXX todo make this respect <insane> tag perhaps..
-                       long duration = ServerInstance->Duration(parameters[1]);
+                       unsigned long duration = InspIRCd::Duration(parameters[1]);
                        const char *reason = (parameters.size() > 2) ? parameters[2].c_str() : "No reason supplied";
                        CBan* r = new CBan(ServerInstance->Time(), duration, user->nick.c_str(), reason, parameters[0].c_str());
 
@@ -131,7 +121,8 @@ class CommandCBan : public Command
                                else
                                {
                                        time_t c_requires_crap = duration + ServerInstance->Time();
-                                       ServerInstance->SNO->WriteGlobalSno('x', "%s added timed CBan for %s, expires on %s: %s", user->nick.c_str(), parameters[0].c_str(), ServerInstance->TimeString(c_requires_crap).c_str(), reason);
+                                       std::string timestr = ServerInstance->TimeString(c_requires_crap);
+                                       ServerInstance->SNO->WriteGlobalSno('x', "%s added timed CBan for %s, expires on %s: %s", user->nick.c_str(), parameters[0].c_str(), timestr.c_str(), reason);
                                }
                        }
                        else
@@ -146,7 +137,10 @@ class CommandCBan : public Command
 
        RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters)
        {
-               return ROUTE_LOCALONLY;
+               if (IS_LOCAL(user))
+                       return ROUTE_LOCALONLY; // spanningtree will send ADDLINE
+
+               return ROUTE_BROADCAST;
        }
 };
 
@@ -157,12 +151,16 @@ class ModuleCBan : public Module
 
  public:
        ModuleCBan() : mycommand(this)
+       {
+       }
+
+       void init()
        {
                ServerInstance->XLines->RegisterFactory(&f);
 
-               ServerInstance->AddCommand(&mycommand);
+               ServerInstance->Modules->AddService(mycommand);
                Implementation eventlist[] = { I_OnUserPreJoin, I_OnStats };
-               ServerInstance->Modules->Attach(eventlist, this, 2);
+               ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
        }
 
        virtual ~ModuleCBan()
@@ -180,16 +178,16 @@ class ModuleCBan : public Module
                return MOD_RES_DENY;
        }
 
-       virtual ModResult OnUserPreJoin(User *user, Channel *chan, const char *cname, std::string &privs, const std::string &keygiven)
+       ModResult OnUserPreJoin(User* user, Channel* chan, const std::string& cname, std::string& privs, const std::string& keygiven)
        {
                XLine *rl = ServerInstance->XLines->MatchesLine("CBAN", cname);
 
                if (rl)
                {
                        // Channel is banned.
-                       user->WriteServ( "384 %s %s :Cannot join channel, CBANed (%s)", user->nick.c_str(), cname, rl->reason.c_str());
+                       user->WriteServ( "384 %s %s :Cannot join channel, CBANed (%s)", user->nick.c_str(), cname.c_str(), rl->reason.c_str());
                        ServerInstance->SNO->WriteGlobalSno('a', "%s tried to join %s which is CBANed (%s)",
-                                user->nick.c_str(), cname, rl->reason.c_str());
+                                user->nick.c_str(), cname.c_str(), rl->reason.c_str());
                        return MOD_RES_DENY;
                }
 
@@ -203,4 +201,3 @@ class ModuleCBan : public Module
 };
 
 MODULE_INIT(ModuleCBan)
-