]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_chanprotect.cpp
Fix all typos (not as fun as 'kill all humans' but meh, beggers cant be choosers)
[user/henk/code/inspircd.git] / src / modules / m_chanprotect.cpp
index 8e23190376ebaa95d10210a0cda5ce250b7aaf14..0839a48e41e42f718d2c5770ff14e818b33c296b 100644 (file)
@@ -59,43 +59,29 @@ class ModuleChanProtect : public Module
                List[I_On005Numeric] = List[I_OnUserKick] = List[I_OnUserPart] = List[I_OnRehash] = List[I_OnUserJoin] = List[I_OnAccessCheck] = List[I_OnExtendedMode] = List[I_OnSendList] = List[I_OnSyncChannel] = 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=")
-                        {
-                                // append the chanmode to the end
-                                temp1 = temp1.substr(10,temp1.length());
-                                temp1 = "CHANMODES=qa" + temp1;
-                        }
-                        temp2 = temp2 + temp1 + " ";
-                }
-               if (temp2.length())
-                       output = temp2.substr(0,temp2.length()-1);
-        }
+       virtual void On005Numeric(std::string &output)
+       {
+               InsertMode(output,"qa",1);
+       }
 
-       virtual void OnUserKick(userrec* source, userrec* user, chanrec* chan, std::string reason)
+       virtual void OnUserKick(userrec* source, userrec* user, chanrec* chan, const std::string &reason)
        {
                // FIX: when someone gets kicked from a channel we must remove their Extensibles!
                user->Shrink("cm_founder_"+std::string(chan->name));
                user->Shrink("cm_protect_"+std::string(chan->name));
        }
 
-       virtual void OnUserPart(userrec* user, chanrec* channel, std::string partreason)
+       virtual void OnUserPart(userrec* user, chanrec* channel, const std::string &partreason)
        {
                // FIX: when someone parts a channel we must remove their Extensibles!
                user->Shrink("cm_founder_"+std::string(channel->name));
                user->Shrink("cm_protect_"+std::string(channel->name));
        }
 
-       virtual void OnRehash(std::string parameter)
+       virtual void OnRehash(const std::string &parameter)
        {
                // on a rehash we delete our classes for good measure and create them again.
-               delete Conf;
+               DELETE(Conf);
                Conf = new ConfigReader;
                // re-read our config options on a rehash
                FirstInGetsFounder = Conf->ReadFlag("options","noservices",0);
@@ -223,7 +209,7 @@ class ModuleChanProtect : public Module
                                return -1;
                        
                        // given user isnt even on the channel, eat the mode change
-                       if (!Srv->IsOnChannel(theuser,chan))
+                       if (!chan->HasUser(theuser))
                                return -1;
                        
                        // source is a server, or ulined, we'll let them +-q the user.
@@ -266,7 +252,7 @@ class ModuleChanProtect : public Module
                                return -1;
                        
                        // given user isnt even on the channel, eat the mode change
-                       if (!Srv->IsOnChannel(theuser,chan))
+                       if (!chan->HasUser(theuser))
                                return -1;
 
                        // source has +q, is a server, or ulined, we'll let them +-a the user.
@@ -315,24 +301,24 @@ class ModuleChanProtect : public Module
                        }
                        WriteServ(user->fd,"387 %s %s :End of channel founder list",user->nick, channel->name);
                }
-                if (mode == 'a')
-                {
-                        chanuserlist cl = Srv->GetUsers(channel);
-                        for (unsigned int i = 0; i < cl.size(); i++)
-                        {
-                                if (cl[i]->GetExt("cm_protect_"+std::string(channel->name)))
-                                {
-                                        WriteServ(user->fd,"388 %s %s %s",user->nick, channel->name,cl[i]->nick);
-                                }
-                        }
+               if (mode == 'a')
+               {
+                       chanuserlist cl = Srv->GetUsers(channel);
+                       for (unsigned int i = 0; i < cl.size(); i++)
+                       {
+                               if (cl[i]->GetExt("cm_protect_"+std::string(channel->name)))
+                               {
+                                       WriteServ(user->fd,"388 %s %s %s",user->nick, channel->name,cl[i]->nick);
+                               }
+                       }
                        WriteServ(user->fd,"389 %s %s :End of channel protected user list",user->nick, channel->name);
-                }
+               }
 
        }
        
        virtual ~ModuleChanProtect()
        {
-               delete Conf;
+               DELETE(Conf);
        }
        
        virtual Version GetVersion()