]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_messageflood.cpp
Add initial query support to m_mysql [patch by Athenon]
[user/henk/code/inspircd.git] / src / modules / m_messageflood.cpp
index 2342870b8e55cde20be5e190cd7d65f99c35bd65..da1038512ccbb63d4ed159553ceb49eab9d6fe53 100644 (file)
@@ -76,7 +76,7 @@ class floodsettings : public classbase
 class MsgFlood : public ModeHandler
 {
  public:
-       MsgFlood(InspIRCd* Instance) : ModeHandler(Instance, 'f', 1, 0, false, MODETYPE_CHANNEL, false) { }
+       MsgFlood(InspIRCd* Instance, Module* Creator) : ModeHandler(Instance, Creator, 'f', 1, 0, false, MODETYPE_CHANNEL, false) { }
 
        ModePair ModeSet(User* source, User* dest, Channel* channel, const std::string &parameter)
        {
@@ -87,13 +87,7 @@ class MsgFlood : public ModeHandler
                        return std::make_pair(false, parameter);
        }
 
-       bool CheckTimeStamp(time_t theirs, time_t ours, const std::string &their_param, const std::string &our_param, Channel* channel)
-       {
-               /* When TS is equal, the alphabetically later one wins */
-               return (their_param < our_param);
-       }
-
-       ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding, bool)
+       ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string &parameter, bool adding)
        {
                floodsettings *f;
 
@@ -198,27 +192,24 @@ class MsgFlood : public ModeHandler
 
 class ModuleMsgFlood : public Module
 {
-
-       MsgFlood* mf;
+       MsgFlood mf;
 
  public:
 
        ModuleMsgFlood(InspIRCd* Me)
-               : Module(Me)
+               : Module(Me), mf(Me, this)
        {
-
-               mf = new MsgFlood(ServerInstance);
-               if (!ServerInstance->Modes->AddMode(mf))
+               if (!ServerInstance->Modes->AddMode(&mf))
                        throw ModuleException("Could not add new modes!");
                Implementation eventlist[] = { I_OnChannelDelete, I_OnUserPreNotice, I_OnUserPreMessage };
                ServerInstance->Modules->Attach(eventlist, this, 3);
        }
 
-       int ProcessMessages(User* user,Channel* dest, const std::string &text)
+       ModResult ProcessMessages(User* user,Channel* dest, const std::string &text)
        {
                if (!IS_LOCAL(user) || (CHANOPS_EXEMPT(ServerInstance, 'f') && dest->GetStatus(user) == STATUS_OP))
                {
-                       return 0;
+                       return MOD_RES_PASSTHRU;
                }
 
                floodsettings *f;
@@ -248,27 +239,27 @@ class ModuleMsgFlood : public Module
                                        delete dest;
                                }
 
-                               return 1;
+                               return MOD_RES_DENY;
                        }
                }
 
-               return 0;
+               return MOD_RES_PASSTHRU;
        }
 
-       virtual int OnUserPreMessage(User *user, void *dest, int target_type, std::string &text, char status, CUList &exempt_list)
+       virtual ModResult OnUserPreMessage(User *user, void *dest, int target_type, std::string &text, char status, CUList &exempt_list)
        {
                if (target_type == TYPE_CHANNEL)
                        return ProcessMessages(user,(Channel*)dest,text);
 
-               return 0;
+               return MOD_RES_PASSTHRU;
        }
 
-       virtual int OnUserPreNotice(User *user, void *dest, int target_type, std::string &text, char status, CUList &exempt_list)
+       virtual ModResult OnUserPreNotice(User *user, void *dest, int target_type, std::string &text, char status, CUList &exempt_list)
        {
                if (target_type == TYPE_CHANNEL)
                        return ProcessMessages(user,(Channel*)dest,text);
 
-               return 0;
+               return MOD_RES_PASSTHRU;
        }
 
        void OnChannelDelete(Channel* chan)
@@ -284,8 +275,7 @@ class ModuleMsgFlood : public Module
 
        virtual ~ModuleMsgFlood()
        {
-               ServerInstance->Modes->DelMode(mf);
-               delete mf;
+               ServerInstance->Modes->DelMode(&mf);
        }
 
        virtual Version GetVersion()