]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_globalload.cpp
Send SVSNICKs during nick collision to prevent servers that do not fully implement...
[user/henk/code/inspircd.git] / src / modules / m_globalload.cpp
index aa0aab748742a5e6312f3cc02897eb3d8114af86..470ac1098a4d41f610b0f7b883aaf88bf467ae55 100644 (file)
@@ -2,7 +2,7 @@
  *       | Inspire Internet Relay Chat Daemon |
  *       +------------------------------------+
  *
- *  InspIRCd: (C) 2002-2007 InspIRCd Development Team
+ *  InspIRCd: (C) 2002-2009 InspIRCd Development Team
  * See: http://www.inspircd.org/wiki/index.php/Credits
  *
  * This program is free but copyrighted software; see
 class CommandGloadmodule : public Command
 {
  public:
-       CommandGloadmodule (InspIRCd* Instance) : Command(Instance,"GLOADMODULE", 'o', 1)
+       CommandGloadmodule (InspIRCd* Instance) : Command(Instance,"GLOADMODULE", "o", 1)
        {
                this->source = "m_globalload.so";
                syntax = "<modulename> [servermask]";
                TRANSLATE3(TR_TEXT, TR_TEXT, TR_END);
        }
 
-       CmdResult Handle (const char** parameters, int pcnt, User *user)
+       CmdResult Handle (const std::vector<std::string> &parameters, User *user)
        {
-               std::string servername = pcnt > 1 ? parameters[1] : "*";
+               std::string servername = parameters.size() > 1 ? parameters[1] : "*";
 
-               if (ServerInstance->MatchText(ServerInstance->Config->ServerName, servername))
+               if (InspIRCd::Match(ServerInstance->Config->ServerName, servername))
                {
-                       if (ServerInstance->Modules->Load(parameters[0]))
+                       if (ServerInstance->Modules->Load(parameters[0].c_str()))
                        {
-                               ServerInstance->WriteOpers("*** NEW MODULE '%s' GLOBALLY LOADED BY '%s'",parameters[0],user->nick);
-                               user->WriteServ("975 %s %s :Module successfully loaded.",user->nick, parameters[0]);
+                               ServerInstance->SNO->WriteToSnoMask('A', "NEW MODULE '%s' GLOBALLY LOADED BY '%s'",parameters[0].c_str(), user->nick.c_str());
+                               user->WriteNumeric(975, "%s %s :Module successfully loaded.",user->nick.c_str(), parameters[0].c_str());
                        }
                        else
                        {
-                               user->WriteServ("974 %s %s :%s",user->nick, parameters[0],ServerInstance->Modules->LastError().c_str());
+                               user->WriteNumeric(974, "%s %s :%s",user->nick.c_str(), parameters[0].c_str(), ServerInstance->Modules->LastError().c_str());
                        }
                }
                else
-                       ServerInstance->WriteOpers("*** MODULE '%s' GLOBAL LOAD BY '%s' (not loaded here)",parameters[0],user->nick);
+                       ServerInstance->SNO->WriteToSnoMask('A', "MODULE '%s' GLOBAL LOAD BY '%s' (not loaded here)",parameters[0].c_str(), user->nick.c_str());
 
                return CMD_SUCCESS;
        }
@@ -55,30 +55,30 @@ class CommandGloadmodule : public Command
 class CommandGunloadmodule : public Command
 {
  public:
-       CommandGunloadmodule (InspIRCd* Instance) : Command(Instance,"GUNLOADMODULE", 'o', 1)
+       CommandGunloadmodule (InspIRCd* Instance) : Command(Instance,"GUNLOADMODULE", "o", 1)
        {
                this->source = "m_globalload.so";
                syntax = "<modulename> [servermask]";
        }
 
-       CmdResult Handle (const char** parameters, int pcnt, User *user)
+       CmdResult Handle (const std::vector<std::string> &parameters, User *user)
        {
-               std::string servername = pcnt > 1 ? parameters[1] : "*";
+               std::string servername = parameters.size() > 1 ? parameters[1] : "*";
 
-               if (ServerInstance->MatchText(ServerInstance->Config->ServerName, servername))
+               if (InspIRCd::Match(ServerInstance->Config->ServerName, servername))
                {
-                       if (ServerInstance->Modules->Unload(parameters[0]))
+                       if (ServerInstance->Modules->Unload(parameters[0].c_str()))
                        {
-                               ServerInstance->WriteOpers("*** MODULE '%s' GLOBALLY UNLOADED BY '%s'",parameters[0],user->nick);
-                               user->WriteServ("973 %s %s :Module successfully unloaded.",user->nick, parameters[0]);
+                               ServerInstance->SNO->WriteToSnoMask('A', "MODULE '%s' GLOBALLY UNLOADED BY '%s'",parameters[0].c_str(), user->nick.c_str());
+                               user->WriteNumeric(973, "%s %s :Module successfully unloaded.",user->nick.c_str(), parameters[0].c_str());
                        }
                        else
                        {
-                               user->WriteServ("972 %s %s :%s",user->nick, parameters[0],ServerInstance->Modules->LastError().c_str());
+                               user->WriteNumeric(972, "%s %s :%s",user->nick.c_str(), parameters[0].c_str(), ServerInstance->Modules->LastError().c_str());
                        }
                }
                else
-                       ServerInstance->WriteOpers("*** MODULE '%s' GLOBAL UNLOAD BY '%s' (not unloaded here)",parameters[0],user->nick);
+                       ServerInstance->SNO->WriteToSnoMask('A', "MODULE '%s' GLOBAL UNLOAD BY '%s' (not unloaded here)",parameters[0].c_str(), user->nick.c_str());
 
                return CMD_SUCCESS;
        }
@@ -89,31 +89,31 @@ class CommandGunloadmodule : public Command
 class CommandGreloadmodule : public Command
 {
  public:
-       CommandGreloadmodule (InspIRCd* Instance) : Command(Instance, "GRELOADMODULE", 'o', 1)
+       CommandGreloadmodule (InspIRCd* Instance) : Command(Instance, "GRELOADMODULE", "o", 1)
        {
                this->source = "m_globalload.so";
                syntax = "<modulename> [servermask]";
        }
 
-       CmdResult Handle(const char** parameters, int pcnt, User *user)
+       CmdResult Handle(const std::vector<std::string> &parameters, User *user)
        {
-               std::string servername = pcnt > 1 ? parameters[1] : "*";
+               std::string servername = parameters.size() > 1 ? parameters[1] : "*";
 
-               if (ServerInstance->MatchText(ServerInstance->Config->ServerName, servername))
+               if (InspIRCd::Match(ServerInstance->Config->ServerName, servername))
                {
-                       if (!ServerInstance->Modules->Unload(parameters[0]))
+                       if (!ServerInstance->Modules->Unload(parameters[0].c_str()))
                        {
-                               user->WriteServ("972 %s %s :Failed to unload module: %s",user->nick, parameters[0],ServerInstance->Modules->LastError());
+                               user->WriteNumeric(972, "%s %s :%s",user->nick.c_str(), parameters[0].c_str(), ServerInstance->Modules->LastError().c_str());
                        }
-                       if (!ServerInstance->Modules->Load(parameters[0]))
+                       if (!ServerInstance->Modules->Load(parameters[0].c_str()))
                        {
-                               user->WriteServ("974 %s %s :%s",user->nick, parameters[0],ServerInstance->Modules->LastError().c_str());
+                               user->WriteNumeric(974, "%s %s :%s",user->nick.c_str(), parameters[0].c_str(), ServerInstance->Modules->LastError().c_str());
                        }
-                       ServerInstance->WriteOpers("*** MODULE '%s' GLOBALLY RELOADED BY '%s'",parameters[0],user->nick);
-                       user->WriteServ("975 %s %s :Module successfully loaded.",user->nick, parameters[0]);
+                       ServerInstance->SNO->WriteToSnoMask('A', "MODULE '%s' GLOBALLY RELOADED BY '%s'",parameters[0].c_str(), user->nick.c_str());
+                       user->WriteNumeric(975, "%s %s :Module successfully loaded.",user->nick.c_str(), parameters[0].c_str());
                }
                else
-                       ServerInstance->WriteOpers("*** MODULE '%s' GLOBAL RELOAD BY '%s' (not reloaded here)",parameters[0],user->nick);
+                       ServerInstance->SNO->WriteToSnoMask('A', "MODULE '%s' GLOBAL RELOAD BY '%s' (not reloaded here)",parameters[0].c_str(), user->nick.c_str());
 
                return CMD_SUCCESS;
        }
@@ -124,11 +124,11 @@ class ModuleGlobalLoad : public Module
        CommandGloadmodule *mycommand;
        CommandGunloadmodule *mycommand2;
        CommandGreloadmodule *mycommand3;
-       
+
  public:
        ModuleGlobalLoad(InspIRCd* Me) : Module(Me)
        {
-               
+
                mycommand = new CommandGloadmodule(ServerInstance);
                mycommand2 = new CommandGunloadmodule(ServerInstance);
                mycommand3 = new CommandGreloadmodule(ServerInstance);
@@ -137,14 +137,14 @@ class ModuleGlobalLoad : public Module
                ServerInstance->AddCommand(mycommand3);
 
        }
-       
+
        virtual ~ModuleGlobalLoad()
        {
        }
-       
+
        virtual Version GetVersion()
        {
-               return Version(1, 1, 0, 0, VF_COMMON | VF_VENDOR, API_VERSION);
+               return Version("$Id$", VF_COMMON | VF_VENDOR, API_VERSION);
        }
 };