]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_operjoin.cpp
Convert more modules
[user/henk/code/inspircd.git] / src / modules / m_operjoin.cpp
index 7150c5b837b2665037e598b63bafddd7506a49ed..5576fd3f9afdbd9f6860eb07a0094052838d80cd 100644 (file)
  * ---------------------------------------------------
  */
 
+#include "inspircd.h"
 #include "users.h"
 #include "channels.h"
 #include "modules.h"
-#include "inspircd.h"
 
 /* $ModDesc: Forces opers to join the specified channel(s) on oper-up */
 
@@ -22,8 +22,7 @@ class ModuleOperjoin : public Module
 {
        private:
                std::string operChan;
-               ConfigReader* conf;
-               
+               std::vector<std::string> operChans;             
 
                int tokenize(const string &str, std::vector<std::string> &tokens)
                {
@@ -45,12 +44,9 @@ class ModuleOperjoin : public Module
                }
 
        public:
-               ModuleOperjoin(InspIRCd* Me)
-                       : Module::Module(Me)
+               ModuleOperjoin(InspIRCd* Me) : Module(Me)
                {
-                       
-                       conf = new ConfigReader(ServerInstance);
-                       operChan = conf->ReadValue("operjoin", "channel", 0);
+                       OnRehash(NULL, "");
                }
 
                void Implements(char* List)
@@ -60,13 +56,18 @@ class ModuleOperjoin : public Module
 
                virtual void OnRehash(userrec* user, const std::string &parameter)
                {
+                       ConfigReader* conf = new ConfigReader(ServerInstance);
+
+                       operChan = conf->ReadValue("operjoin", "channel", 0);
+                       operChans.clear();
+                       if (!operChan.empty())
+                               tokenize(operChan,operChans);
+
                        DELETE(conf);
-                       conf = new ConfigReader(ServerInstance);
                }
 
                virtual ~ModuleOperjoin()
                {
-                       DELETE(conf);
                }
 
                virtual Version GetVersion()
@@ -79,14 +80,9 @@ class ModuleOperjoin : public Module
                        if (!IS_LOCAL(user))
                                return;
 
-                       if (!operChan.empty())
-                       {
-                               std::vector<std::string> operChans;
-                               tokenize(operChan,operChans);
-                               for(std::vector<std::string>::iterator it = operChans.begin(); it != operChans.end(); it++)
-                                       chanrec::JoinUser(ServerInstance, user, it->c_str(), false);
-                       }
-
+                       for(std::vector<std::string>::iterator it = operChans.begin(); it != operChans.end(); it++)
+                               if (ServerInstance->IsChannel(it->c_str()))
+                                       chanrec::JoinUser(ServerInstance, user, it->c_str(), false, "", ServerInstance->Time(true));
                }
 
 };
@@ -108,7 +104,7 @@ class ModuleOperjoinFactory : public ModuleFactory
                }
 };
 
-extern "C" void * init_module( void )
+extern "C" DllExport void * init_module( void )
 {
        return new ModuleOperjoinFactory;
 }