]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_messageflood.cpp
Properly cull TreeServer objects when quitting several of them
[user/henk/code/inspircd.git] / src / modules / m_messageflood.cpp
index 542aedd41acf8b9ddc80e0cbaf4168b7e7479645..5fceee19c29d2c45cc9d2d565f37c147aa312a43 100644 (file)
 
 /** Holds flood settings and state for mode +f
  */
-class floodsettings : public classbase
+class floodsettings
 {
- private:
-       InspIRCd *ServerInstance;
  public:
        bool ban;
        int secs;
@@ -80,15 +78,6 @@ class MsgFlood : public ModeHandler
        MsgFlood(Module* Creator) : ModeHandler(Creator, "flood", 'f', PARAM_SETONLY, MODETYPE_CHANNEL),
                ext("messageflood", Creator) { }
 
-       ModePair ModeSet(User* source, User* dest, Channel* channel, const std::string &parameter)
-       {
-               floodsettings* x = ext.get(channel);
-               if (x)
-                       return std::make_pair(true, (x->ban ? "*" : "")+ConvToStr(x->lines)+":"+ConvToStr(x->secs));
-               else
-                       return std::make_pair(false, parameter);
-       }
-
        ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding)
        {
                floodsettings *f = ext.get(channel);
@@ -200,17 +189,17 @@ class ModuleMsgFlood : public Module
        {
                if (!ServerInstance->Modes->AddMode(&mf))
                        throw ModuleException("Could not add new modes!");
-               Extensible::Register(&mf.ext);
+               ServerInstance->Extensions.Register(&mf.ext);
                Implementation eventlist[] = { I_OnUserPreNotice, I_OnUserPreMessage };
                ServerInstance->Modules->Attach(eventlist, this, 2);
        }
 
        ModResult ProcessMessages(User* user,Channel* dest, const std::string &text)
        {
-               if (!IS_LOCAL(user) || (CHANOPS_EXEMPT('f') && dest->GetPrefixValue(user) == OP_VALUE))
-               {
+               ModResult res;
+               FIRST_MOD_RESULT(OnChannelRestrictionApply, res, (user,dest,"flood"));
+               if (!IS_LOCAL(user) || res == MOD_RES_ALLOW)
                        return MOD_RES_PASSTHRU;
-               }
 
                floodsettings *f = mf.ext.get(dest);
                if (f)
@@ -234,10 +223,7 @@ class ModuleMsgFlood : public Module
                                char kickmessage[MAXBUF];
                                snprintf(kickmessage, MAXBUF, "Channel flood triggered (limit is %d lines in %d secs)", f->lines, f->secs);
 
-                               if (!dest->ServerKickUser(user, kickmessage))
-                               {
-                                       delete dest;
-                               }
+                               dest->KickUser(ServerInstance->FakeClient, user, kickmessage);
 
                                return MOD_RES_DENY;
                        }
@@ -268,7 +254,7 @@ class ModuleMsgFlood : public Module
 
        Version GetVersion()
        {
-               return Version("Provides channel mode +f (message flood protection)", VF_COMMON | VF_VENDOR, API_VERSION);
+               return Version("Provides channel mode +f (message flood protection)", VF_COMMON | VF_VENDOR);
        }
 };