]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_joinflood.cpp
Decide that it wasn't quite appropriate :(
[user/henk/code/inspircd.git] / src / modules / m_joinflood.cpp
index 8d0716d224b47a84d44ffaadeb2a8a9765b844e6..b1dc5c657c0dc751b910eac78c8ba3f1943d0a2a 100644 (file)
@@ -23,7 +23,7 @@ using namespace std;
 #include "modules.h"
 #include "helperfuncs.h"
 
-/* $ModDesc: Provides channel mode +f (message flood protection) */
+/* $ModDesc: Provides channel mode +j (join flood protection) */
 
 class joinfloodsettings
 {
@@ -48,8 +48,10 @@ class joinfloodsettings
        void addjoin()
        {
                counter++;
+               log(DEBUG,"joinflood counter is %d",counter);
                if (time(NULL) > reset)
                {
+                       log(DEBUG,"joinflood counter reset");
                        counter = 0;
                        reset = time(NULL) + secs;
                }
@@ -62,6 +64,7 @@ class joinfloodsettings
 
        void clear()
        {
+               log(DEBUG,"joinflood counter clear");
                counter = 0;
        }
 
@@ -84,6 +87,7 @@ class joinfloodsettings
 
        void lock()
        {
+               log(DEBUG,"joinflood lock");
                locked = true;
                unlocktime = time(NULL) + 60;
        }
@@ -142,7 +146,7 @@ class ModuleJoinFlood : public Module
                                        {
                                                if (!c->GetExt("joinflood"))
                                                {
-                                                       joinfloodsettings *f = new joinfloodsettings(njoins,nsecs);
+                                                       joinfloodsettings *f = new joinfloodsettings(nsecs,njoins);
                                                        c->Extend("joinflood",(char*)f);
                                                }
                                        }
@@ -217,25 +221,10 @@ class ModuleJoinFlood : public Module
                List[I_On005Numeric] = List[I_OnExtendedMode] = List[I_OnChannelDelete] = List[I_OnUserPreJoin] = List[I_OnUserJoin] = 1;
        }
 
-        virtual void On005Numeric(std::string &output)
-        {
-                std::stringstream line(output);
-                std::string temp1, temp2;
-                while (!line.eof())
-                {
-                        line >> temp1;
-                        if (temp1.substr(0,10) == "CHANMODES=")
-                        {
-                               // By doing this we're *assuming* no other module has fucked up the CHANMODES=
-                               // section of the 005 numeric. If they have, we're going DOWN in a blaze of glory,
-                               // with a honking great EXCEPTION :)
-                               temp1.insert(temp1.find(",")+1,"j");
-                        }
-                        temp2 = temp2 + temp1 + " ";
-                }
-               if (temp2.length())
-                       output = temp2.substr(0,temp2.length()-1);
-        }
+       virtual void On005Numeric(std::string &output)
+       {
+               InsertMode(output, "j", 3);
+       }
 
        virtual ~ModuleJoinFlood()
        {