1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2008 InspIRCd Development Team
6 * See: http://www.inspircd.org/wiki/index.php/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
14 /* $ModDesc: Allows global loading of a module. */
18 /** Handle /GLOADMODULE
20 class CommandGloadmodule : public Command
23 CommandGloadmodule (InspIRCd* Instance) : Command(Instance,"GLOADMODULE", "o", 1)
25 this->source = "m_globalload.so";
26 syntax = "<modulename> [servermask]";
27 TRANSLATE3(TR_TEXT, TR_TEXT, TR_END);
30 CmdResult Handle (const std::vector<std::string> ¶meters, User *user)
32 std::string servername = parameters.size() > 1 ? parameters[1] : "*";
34 if (InspIRCd::Match(ServerInstance->Config->ServerName, servername))
36 if (ServerInstance->Modules->Load(parameters[0].c_str()))
38 ServerInstance->SNO->WriteToSnoMask('A', "NEW MODULE '%s' GLOBALLY LOADED BY '%s'",parameters[0].c_str(), user->nick.c_str());
39 user->WriteNumeric(975, "%s %s :Module successfully loaded.",user->nick.c_str(), parameters[0].c_str());
43 user->WriteNumeric(974, "%s %s :%s",user->nick.c_str(), parameters[0].c_str(), ServerInstance->Modules->LastError().c_str());
47 ServerInstance->SNO->WriteToSnoMask('A', "MODULE '%s' GLOBAL LOAD BY '%s' (not loaded here)",parameters[0].c_str(), user->nick.c_str());
53 /** Handle /GUNLOADMODULE
55 class CommandGunloadmodule : public Command
58 CommandGunloadmodule (InspIRCd* Instance) : Command(Instance,"GUNLOADMODULE", "o", 1)
60 this->source = "m_globalload.so";
61 syntax = "<modulename> [servermask]";
64 CmdResult Handle (const std::vector<std::string> ¶meters, User *user)
66 std::string servername = parameters.size() > 1 ? parameters[1] : "*";
68 if (InspIRCd::Match(ServerInstance->Config->ServerName, servername))
70 if (ServerInstance->Modules->Unload(parameters[0].c_str()))
72 ServerInstance->SNO->WriteToSnoMask('A', "MODULE '%s' GLOBALLY UNLOADED BY '%s'",parameters[0].c_str(), user->nick.c_str());
73 user->WriteNumeric(973, "%s %s :Module successfully unloaded.",user->nick.c_str(), parameters[0].c_str());
77 user->WriteNumeric(972, "%s %s :%s",user->nick.c_str(), parameters[0].c_str(), ServerInstance->Modules->LastError().c_str());
81 ServerInstance->SNO->WriteToSnoMask('A', "MODULE '%s' GLOBAL UNLOAD BY '%s' (not unloaded here)",parameters[0].c_str(), user->nick.c_str());
87 /** Handle /GRELOADMODULE
89 class CommandGreloadmodule : public Command
92 CommandGreloadmodule (InspIRCd* Instance) : Command(Instance, "GRELOADMODULE", "o", 1)
94 this->source = "m_globalload.so";
95 syntax = "<modulename> [servermask]";
98 CmdResult Handle(const std::vector<std::string> ¶meters, User *user)
100 std::string servername = parameters.size() > 1 ? parameters[1] : "*";
102 if (InspIRCd::Match(ServerInstance->Config->ServerName, servername))
104 if (!ServerInstance->Modules->Unload(parameters[0].c_str()))
106 user->WriteNumeric(972, "%s %s :%s",user->nick.c_str(), parameters[0].c_str(), ServerInstance->Modules->LastError().c_str());
108 if (!ServerInstance->Modules->Load(parameters[0].c_str()))
110 user->WriteNumeric(974, "%s %s :%s",user->nick.c_str(), parameters[0].c_str(), ServerInstance->Modules->LastError().c_str());
112 ServerInstance->SNO->WriteToSnoMask('A', "MODULE '%s' GLOBALLY RELOADED BY '%s'",parameters[0].c_str(), user->nick.c_str());
113 user->WriteNumeric(975, "%s %s :Module successfully loaded.",user->nick.c_str(), parameters[0].c_str());
116 ServerInstance->SNO->WriteToSnoMask('A', "MODULE '%s' GLOBAL RELOAD BY '%s' (not reloaded here)",parameters[0].c_str(), user->nick.c_str());
122 class ModuleGlobalLoad : public Module
124 CommandGloadmodule *mycommand;
125 CommandGunloadmodule *mycommand2;
126 CommandGreloadmodule *mycommand3;
129 ModuleGlobalLoad(InspIRCd* Me) : Module(Me)
132 mycommand = new CommandGloadmodule(ServerInstance);
133 mycommand2 = new CommandGunloadmodule(ServerInstance);
134 mycommand3 = new CommandGreloadmodule(ServerInstance);
135 ServerInstance->AddCommand(mycommand);
136 ServerInstance->AddCommand(mycommand2);
137 ServerInstance->AddCommand(mycommand3);
141 virtual ~ModuleGlobalLoad()
145 virtual Version GetVersion()
147 return Version("$Id$", VF_COMMON | VF_VENDOR, API_VERSION);
151 MODULE_INIT(ModuleGlobalLoad)