]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_opermodes.cpp
Added <oper:swhois> to m_swhois, which will override <type:swhois> if specified
[user/henk/code/inspircd.git] / src / modules / m_opermodes.cpp
index b354abf0afe9ae2ae1a60ffd0593d8e4523af502..10176846cb0618b1be347f22e7086ff19c87e7fb 100644 (file)
@@ -17,6 +17,7 @@
 using namespace std;
 
 #include <stdio.h>
+#include <vector>
 #include "users.h"
 #include "channels.h"
 #include "inspircd.h"
@@ -36,7 +37,7 @@ class ModuleModesOnOper : public Module
                : Module::Module(Me)
        {
                
-               Conf = new ConfigReader;
+               Conf = new ConfigReader(ServerInstance);
        }
 
        void Implements(char* List)
@@ -47,7 +48,7 @@ class ModuleModesOnOper : public Module
        virtual void OnRehash(const std::string &parameter)
        {
                DELETE(Conf);
-               Conf = new ConfigReader;
+               Conf = new ConfigReader(ServerInstance);
        }
        
        virtual ~ModuleModesOnOper()
@@ -57,7 +58,7 @@ class ModuleModesOnOper : public Module
        
        virtual Version GetVersion()
        {
-               return Version(1,0,0,1,VF_VENDOR);
+               return Version(1,1,0,1,VF_VENDOR,API_VERSION);
        }
        
        virtual void OnPostOper(userrec* user, const std::string &opertype)
@@ -76,10 +77,34 @@ class ModuleModesOnOper : public Module
                                        ThisOpersModes = "+" + ThisOpersModes;
                                if (ThisOpersModes != "")
                                {
-                                       const char* modes[2];
+                                       std::string buf;
+                                       stringstream ss(ThisOpersModes);
+
+                                       vector<string> tokens;
+
+                                       // split ThisOperModes into modes and mode params
+                                       while (ss >> buf)
+                                               tokens.push_back(buf);
+
+                                       int size = tokens.size() + 1;
+                                       const char* modes[size];
                                        modes[0] = user->nick;
-                                       modes[1] = ThisOpersModes.c_str();
-                                       ServerInstance->SendMode(modes,2,user);
+                                       modes[1] = (char*)tokens[0].c_str();
+
+                                       if (tokens.size() > 1)
+                                       {
+                                               // process mode params
+                                               int i = 2;
+                                               for (unsigned int k = 1; k < tokens.size(); k++)
+                                               {
+                                                       modes[i] = (char*)tokens[k].c_str();
+                                                       ServerInstance->Log(DEBUG, "m_opermodes.so: got mode param: %s", modes[i]);
+                                                       i++;
+                                               }
+                                       }
+                                       
+                                       ServerInstance->Log(DEBUG, "m_opermodes.so: new modes for %s: %s", modes[0], modes[1]);
+                                       ServerInstance->SendMode(modes, size, user);
                                }
                                break;
                        }