2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
5 * Copyright (C) 2007 Robin Burchell <robin+git@viroteck.net>
7 * This file is part of InspIRCd. InspIRCd is free software: you can
8 * redistribute it and/or modify it under the terms of the GNU General Public
9 * License as published by the Free Software Foundation, version 2.
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
23 class CommandReloadmodule : public Command
26 /** Constructor for reloadmodule.
28 CommandReloadmodule ( Module* parent) : Command( parent, "RELOADMODULE",1) { flags_needed = 'o'; syntax = "<modulename>"; }
30 * @param parameters The parameters to the comamnd
31 * @param pcnt The number of parameters passed to teh command
32 * @param user The user issuing the command
33 * @return A value from CmdResult to indicate command success or failure.
35 CmdResult Handle(const std::vector<std::string>& parameters, User *user);
38 class ReloadModuleWorker : public HandlerBase1<void, bool>
41 const std::string name;
42 const std::string uid;
43 ReloadModuleWorker(const std::string& uuid, const std::string& modn)
44 : name(modn), uid(uuid) {}
45 void Call(bool result)
47 ServerInstance->SNO->WriteGlobalSno('a', "RELOAD MODULE: %s %ssuccessfully reloaded",
48 name.c_str(), result ? "" : "un");
49 User* user = ServerInstance->FindNick(uid);
51 user->WriteNumeric(975, "%s %s :Module %ssuccessfully reloaded.",
52 user->nick.c_str(), name.c_str(), result ? "" : "un");
53 ServerInstance->GlobalCulls.AddItem(this);
57 CmdResult CommandReloadmodule::Handle (const std::vector<std::string>& parameters, User *user)
59 if (parameters[0] == "cmd_reloadmodule.so")
61 user->WriteNumeric(975, "%s %s :You cannot reload cmd_reloadmodule.so (unload and load it)",
62 user->nick.c_str(), parameters[0].c_str());
66 Module* m = ServerInstance->Modules->Find(parameters[0]);
69 ServerInstance->Modules->Reload(m, new ReloadModuleWorker(user->uuid, parameters[0]));
74 user->WriteNumeric(975, "%s %s :Could not find module by that name", user->nick.c_str(), parameters[0].c_str());
79 COMMAND_INIT(CommandReloadmodule)