]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_denychans.cpp
(Bigger than it looks, i did this with perl inplace edit) -- commands now take an...
[user/henk/code/inspircd.git] / src / modules / m_denychans.cpp
index 709a285a05f54287a884c2ed98d5d62b40fff215..c823b9c1e835f4a9d4f91d1c0dca95f0a21693db 100644 (file)
@@ -19,6 +19,7 @@
 #include "modules.h"
 #include "hashcomp.h"
 #include "helperfuncs.h"
+#include "inspircd.h"
 
 /* $ModDesc: Implements config tags which allow blocking of joins to channels */
 
@@ -26,25 +27,25 @@ class ModuleDenyChannels : public Module
 {
  private:
 
-       Server *Srv;
+       
        ConfigReader *Conf;
 
  public:
-       ModuleDenyChannels(Server* Me) : Module::Module(Me)
+       ModuleDenyChannels(InspIRCd* Me) : Module::Module(Me)
        {
-               Srv = Me;
+               
                Conf = new ConfigReader;
        }
        
-       virtual void OnRehash(std::string param)
+       virtual void OnRehash(const std::string &param)
        {
-               delete Conf;
+               DELETE(Conf);
                Conf = new ConfigReader;
        }
        
        virtual ~ModuleDenyChannels()
        {
-               delete Conf;
+               DELETE(Conf);
        }
        
        virtual Version GetVersion()
@@ -57,30 +58,28 @@ class ModuleDenyChannels : public Module
                List[I_OnUserPreJoin] = List[I_OnRehash] = 1;
        }
 
-        virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname)
-        {
-               bool isoper = strchr(user->modes,'o') ? true : false;
-
+       virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname)
+       {
                for (int j =0; j < Conf->Enumerate("badchan"); j++)
                {
                        irc::string cn = Conf->ReadValue("badchan","name",j).c_str();
                        irc::string thischan = cname;
                        if (thischan == cn)
                        {
-                               if ((Conf->ReadFlag("badchan","allowopers",j)) && isoper == true)
+                               if ((Conf->ReadFlag("badchan","allowopers",j)) && *user->oper)
                                {
                                        return 0;
                                }
                                else
                                {
                                        std::string reason = Conf->ReadValue("badchan","reason",j);
-                                       WriteServ(user->fd,"926 %s %s :Channel %s is forbidden: %s",user->nick,cname,cname,reason.c_str());
+                                       user->WriteServ("926 %s %s :Channel %s is forbidden: %s",user->nick,cname,cname,reason.c_str());
                                        return 1;
                                }
                        }
                }
                return 0;
-        }
+       }
 };
 
 // stuff down here is the module-factory stuff. For basic modules you can ignore this.
@@ -96,7 +95,7 @@ class ModuleDenyChannelsFactory : public ModuleFactory
        {
        }
        
-       virtual Module * CreateModule(Server* Me)
+       virtual Module * CreateModule(InspIRCd* Me)
        {
                return new ModuleDenyChannels(Me);
        }