]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_chanfilter.cpp
New 'Implements' system
[user/henk/code/inspircd.git] / src / modules / m_chanfilter.cpp
index 1d10bcd08129e3c847f000eda7012ab87ee50234..112bcb5c4b7d94b33ae778a0816b142f29f1a609 100644 (file)
@@ -36,12 +36,15 @@ class ModuleChanFilter : public Module
        
  public:
  
-       ModuleChanFilter()
+       ModuleChanFilter(Server* Me)
+               : Module::Module(Me)
        {
-               Srv = new Server;
+               Srv = Me;
                Conf = new ConfigReader;
                Srv->AddExtendedListMode('g');
                MaxEntries = Conf->ReadInteger("chanfilter","maxsize",0,true);
+               if (MaxEntries == 0)
+                       MaxEntries = 32;
        }
        
         virtual void On005Numeric(std::string &output)
@@ -77,7 +80,7 @@ class ModuleChanFilter : public Module
                }
        }
 
-       virtual void OnRehash()
+       virtual void OnRehash(std::string parameter)
        {
                delete Conf;
                Conf = new ConfigReader;
@@ -89,14 +92,14 @@ class ModuleChanFilter : public Module
         {
                char buffer[MAXBUF];
                strlcpy(buffer,text.c_str(),MAXBUF);
-               for (int j = 0; j < strlen(buffer); j++)
+               for (unsigned int j = 0; j < strlen(buffer); j++)
                        buffer[j] = tolower(buffer[j]);
                SpamList* spamlist = (SpamList*)chan->GetExt("spam_list");
                if (spamlist)
                {
                        for (SpamList::iterator i = spamlist->begin(); i != spamlist->end(); i++)
                        {
-                               if (strstr(text.c_str(),i->c_str()))
+                               if (strstr(buffer,i->c_str()))
                                {
                                        WriteServ(user->fd,"936 %s %s :Your message contained a censored word, and was blocked",user->nick, chan->name);
                                        return 1;
@@ -130,7 +133,7 @@ class ModuleChanFilter : public Module
                {
                        chanrec* chan = (chanrec*)target;
 
-                       for (int j = 0; j < params[0].length(); j++)
+                       for (unsigned int j = 0; j < params[0].length(); j++)
                                params[0][j] = tolower(params[0][j]);
 
                        std::string param = params[0];
@@ -143,7 +146,7 @@ class ModuleChanFilter : public Module
                                        spamlist = new SpamList;
                                        chan->Extend("spam_list",(char*)spamlist);
                                }
-                               if (spamlist->size() < MaxEntries)
+                               if (spamlist->size() < (unsigned)MaxEntries)
                                {
                                        for (SpamList::iterator i = spamlist->begin(); i != spamlist->end(); i++)
                                        {
@@ -200,7 +203,6 @@ class ModuleChanFilter : public Module
        virtual ~ModuleChanFilter()
        {
                delete Conf;
-               delete Srv;
        }
        
        virtual Version GetVersion()
@@ -208,7 +210,7 @@ class ModuleChanFilter : public Module
                return Version(1,0,0,0,VF_STATIC|VF_VENDOR);
        }
        
-       virtual string_list OnChannelSync(chanrec* chan)
+       virtual void OnSyncChannel(chanrec* chan, Module* proto, void* opaque)
        {
                SpamList* spamlist = (SpamList*)chan->GetExt("spam_list");
                string_list commands;
@@ -216,10 +218,9 @@ class ModuleChanFilter : public Module
                {
                        for (SpamList::iterator i = spamlist->begin(); i != spamlist->end(); i++)
                        {
-                               commands.push_back("M "+std::string(chan->name)+" +g "+*i);
+                               proto->ProtoSendMode(opaque,TYPE_CHANNEL,chan,"+g "+*i);
                        }
                }
-               return commands;
        }
 
 };
@@ -236,9 +237,9 @@ class ModuleChanFilterFactory : public ModuleFactory
        {
        }
        
-       virtual Module * CreateModule()
+       virtual Module * CreateModule(Server* Me)
        {
-               return new ModuleChanFilter;
+               return new ModuleChanFilter(Me);
        }
        
 };