]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_restrictchans.cpp
Added <oper:swhois> to m_swhois, which will override <type:swhois> if specified
[user/henk/code/inspircd.git] / src / modules / m_restrictchans.cpp
index 0ca0dd921602c8dd77d7056ae0f928f645c2cdc9..abfb6f580ac80eacc2303f47ed6eb59a81ec54af 100644 (file)
@@ -21,20 +21,20 @@ using namespace std;
 #include "users.h"
 #include "channels.h"
 #include "modules.h"
-#include "helperfuncs.h"
+
+#include "inspircd.h"
 
 /* $ModDesc: Only opers may create new channels if this module is loaded */
 
-Server *Srv;
-        
 class ModuleRestrictChans : public Module
 {
+       
 
        std::map<irc::string,int> allowchans;
 
        void ReadConfig()
        {
-               ConfigReader* MyConf = new ConfigReader();
+               ConfigReader* MyConf = new ConfigReader(ServerInstance);
                allowchans.clear();
                for (int i = 0; i < MyConf->Enumerate("allowchannel"); i++)
                {
@@ -43,18 +43,18 @@ class ModuleRestrictChans : public Module
                        irc::string channel = txt.c_str();
                        allowchans[channel] = 1;
                }
-               delete MyConf;
+               DELETE(MyConf);
        }
 
  public:
-       ModuleRestrictChans(Server* Me)
+       ModuleRestrictChans(InspIRCd* Me)
                : Module::Module(Me)
        {
-               Srv = Me;
+               
                ReadConfig();
        }
 
-       virtual void OnRehash(std::string parameter)
+       virtual void OnRehash(const std::string &parameter)
        {
                ReadConfig();
        }
@@ -64,16 +64,16 @@ class ModuleRestrictChans : public Module
                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, std::string &privs)
        {
                irc::string x = cname;
                // user is not an oper and its not in the allow list
-               if ((!strchr(user->modes,'o')) && (allowchans.find(x) == allowchans.end()))
+               if ((!*user->oper) && (allowchans.find(x) == allowchans.end()))
                {
                        // channel does not yet exist (record is null, about to be created IF we were to allow it)
                        if (!chan)
                        {
-                               WriteServ(user->fd,"530 %s %s :Only IRC operators may create new channels",user->nick,cname,cname);
+                               user->WriteServ("530 %s %s :Only IRC operators may create new channels",user->nick,cname,cname);
                                return 1;
                        }
                }
@@ -86,7 +86,7 @@ class ModuleRestrictChans : public Module
        
        virtual Version GetVersion()
        {
-               return Version(1,0,0,1,VF_VENDOR);
+               return Version(1,1,0,1,VF_VENDOR,API_VERSION);
        }
 };
 
@@ -102,7 +102,7 @@ class ModuleRestrictChansFactory : public ModuleFactory
        {
        }
        
-       virtual Module * CreateModule(Server* Me)
+       virtual Module * CreateModule(InspIRCd* Me)
        {
                return new ModuleRestrictChans(Me);
        }