]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_denychans.cpp
WHEEEEE!!!!!
[user/henk/code/inspircd.git] / src / modules / m_denychans.cpp
index 94e2efdb8b7f58bb67c1c645a08bfc150c1c02f5..300d13b4ab67d039949ca4cf6527ca2b3d5d4d47 100644 (file)
@@ -14,9 +14,6 @@
  * ---------------------------------------------------
  */
 
-using namespace std;
-
-#include <stdio.h>
 #include "users.h"
 #include "channels.h"
 #include "modules.h"
@@ -33,16 +30,21 @@ class ModuleDenyChannels : public Module
        ConfigReader *Conf;
 
  public:
-       ModuleDenyChannels(Server* Me)
-               : Module::Module(Me)
+       ModuleDenyChannels(Server* Me) : Module::Module(Me)
        {
                Srv = Me;
                Conf = new ConfigReader;
        }
        
+       virtual void OnRehash(const std::string &param)
+       {
+               DELETE(Conf);
+               Conf = new ConfigReader;
+       }
+       
        virtual ~ModuleDenyChannels()
        {
-               delete Conf;
+               DELETE(Conf);
        }
        
        virtual Version GetVersion()
@@ -52,31 +54,31 @@ class ModuleDenyChannels : public Module
 
        void Implements(char* List)
        {
-               List[I_OnUserPreJoin] = 1;
+               List[I_OnUserPreJoin] = List[I_OnRehash] = 1;
        }
 
-        virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname)
-        {
+       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)) && (strchr(user->modes,'o')))
+                               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.