1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2009 InspIRCd Development Team
6 * See: http://wiki.inspircd.org/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))
105 if (!ServerInstance->Modules->Unload(parameters[0].c_str()))
108 user->WriteNumeric(972, "%s %s :%s",user->nick.c_str(), parameters[0].c_str(), ServerInstance->Modules->LastError().c_str());
110 if (!ServerInstance->Modules->Load(parameters[0].c_str()))
113 user->WriteNumeric(974, "%s %s :%s",user->nick.c_str(), parameters[0].c_str(), ServerInstance->Modules->LastError().c_str());
115 ServerInstance->SNO->WriteToSnoMask('a', "MODULE '%s' GLOBALLY RELOADED BY '%s'",parameters[0].c_str(), user->nick.c_str());
117 user->WriteNumeric(975, "%s %s :Module successfully loaded.",user->nick.c_str(), parameters[0].c_str());
120 ServerInstance->SNO->WriteToSnoMask('a', "MODULE '%s' GLOBAL RELOAD BY '%s' (not reloaded here)",parameters[0].c_str(), user->nick.c_str());
126 class ModuleGlobalLoad : public Module
128 CommandGloadmodule *mycommand;
129 CommandGunloadmodule *mycommand2;
130 CommandGreloadmodule *mycommand3;
133 ModuleGlobalLoad(InspIRCd* Me) : Module(Me)
136 mycommand = new CommandGloadmodule(ServerInstance);
137 mycommand2 = new CommandGunloadmodule(ServerInstance);
138 mycommand3 = new CommandGreloadmodule(ServerInstance);
139 ServerInstance->AddCommand(mycommand);
140 ServerInstance->AddCommand(mycommand2);
141 ServerInstance->AddCommand(mycommand3);
145 virtual ~ModuleGlobalLoad()
149 virtual Version GetVersion()
151 return Version("$Id$", VF_COMMON | VF_VENDOR, API_VERSION);
155 MODULE_INIT(ModuleGlobalLoad)