1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2010 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 * ---------------------------------------------------
16 class CommandReloadmodule : public Command
19 /** Constructor for reloadmodule.
21 CommandReloadmodule ( Module* parent) : Command( parent, "RELOADMODULE",1) { flags_needed = 'o'; syntax = "<modulename>"; }
23 * @param parameters The parameters to the comamnd
24 * @param pcnt The number of parameters passed to teh command
25 * @param user The user issuing the command
26 * @return A value from CmdResult to indicate command success or failure.
28 CmdResult Handle(const std::vector<std::string>& parameters, User *user);
31 class ReloadModuleWorker : public HandlerBase1<void, bool>
34 const std::string name;
35 const std::string uid;
36 ReloadModuleWorker(const std::string& uuid, const std::string& modn)
37 : name(modn), uid(uuid) {}
38 void Call(bool result)
40 ServerInstance->SNO->WriteGlobalSno('a', "RELOAD MODULE: %s %ssuccessfully reloaded",
41 name.c_str(), result ? "" : "un");
42 User* user = ServerInstance->FindNick(uid);
44 user->WriteNumeric(975, "%s %s :Module %ssuccessfully reloaded.",
45 user->nick.c_str(), name.c_str(), result ? "" : "un");
46 ServerInstance->GlobalCulls.AddItem(this);
50 CmdResult CommandReloadmodule::Handle (const std::vector<std::string>& parameters, User *user)
52 if (parameters[0] == "cmd_reloadmodule.so")
54 user->WriteNumeric(975, "%s %s :You cannot reload cmd_reloadmodule.so (unload and load it)",
55 user->nick.c_str(), parameters[0].c_str());
59 Module* m = ServerInstance->Modules->Find(parameters[0]);
62 ServerInstance->Modules->Reload(m, new ReloadModuleWorker(user->uuid, parameters[0]));
67 user->WriteNumeric(975, "%s %s :Could not find module by that name", user->nick.c_str(), parameters[0].c_str());
72 COMMAND_INIT(CommandReloadmodule)