]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_opermodes.cpp
Added ability to send and receive a challenge, dont do anything with it yet
[user/henk/code/inspircd.git] / src / modules / m_opermodes.cpp
index 4526b05d37e6f7501904e01ce5c975d5ba63a8c7..57eb8ae234ec1854bcb3cdea477a6bc8bbbc1733 100644 (file)
@@ -2,21 +2,17 @@
  *       | Inspire Internet Relay Chat Daemon |
  *       +------------------------------------+
  *
- *  InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
- *                       E-mail:
- *                <brain@chatspike.net>
- *               <Craig@chatspike.net>
- *     
- * Written by Craig Edwards, Craig McLure, and others.
+ *  InspIRCd: (C) 2002-2007 InspIRCd Development Team
+ * See: http://www.inspircd.org/wiki/index.php/Credits
+ *
  * This program is free but copyrighted software; see
  *            the file COPYING for details.
  *
  * ---------------------------------------------------
  */
 
-using namespace std;
-
 #include <stdio.h>
+#include <vector>
 #include "users.h"
 #include "channels.h"
 #include "inspircd.h"
@@ -44,7 +40,7 @@ class ModuleModesOnOper : public Module
                List[I_OnPostOper] = List[I_OnRehash] = 1;
        }
 
-       virtual void OnRehash(const std::string &parameter)
+       virtual void OnRehash(userrec* user, const std::string &parameter)
        {
                DELETE(Conf);
                Conf = new ConfigReader(ServerInstance);
@@ -57,7 +53,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 +72,40 @@ 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();
+                                                       i++;
+                                               }
+                                       }
+                                       std::deque<std::string> n;
+                                       Event rmode((char *)&n, NULL, "send_mode");
+                                       n.push_back(user->nick);
+                                       n.push_back(modes[0]);
+                                       for (unsigned int j = 1; j < tokens.size(); j++)
+                                       {
+                                               n.push_back(modes[j]);
+                                       }
+                                       rmode.Send(ServerInstance);
+                                       ServerInstance->SendMode(modes, size, user);
                                }
                                break;
                        }