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 command
31 * @param user The user issuing the command
32 * @return A value from CmdResult to indicate command success or failure.
34 CmdResult Handle(const std::vector<std::string>& parameters, User *user);
37 class ReloadModuleWorker : public HandlerBase1<void, bool>
40 const std::string name;
41 const std::string uid;
42 ReloadModuleWorker(const std::string& uuid, const std::string& modn)
43 : name(modn), uid(uuid) {}
44 void Call(bool result)
46 ServerInstance->SNO->WriteGlobalSno('a', "RELOAD MODULE: %s %ssuccessfully reloaded",
47 name.c_str(), result ? "" : "un");
48 User* user = ServerInstance->FindNick(uid);
50 user->WriteNumeric(RPL_LOADEDMODULE, "%s :Module %ssuccessfully reloaded.",
51 name.c_str(), result ? "" : "un");
52 ServerInstance->GlobalCulls.AddItem(this);
56 CmdResult CommandReloadmodule::Handle (const std::vector<std::string>& parameters, User *user)
58 Module* m = ServerInstance->Modules->Find(parameters[0]);
61 user->WriteNumeric(RPL_LOADEDMODULE, "%s :You cannot reload core_reloadmodule.so (unload and load it)",
62 parameters[0].c_str());
68 ServerInstance->Modules->Reload(m, (creator->dying ? NULL : new ReloadModuleWorker(user->uuid, parameters[0])));
73 user->WriteNumeric(RPL_LOADEDMODULE, "%s :Could not find module by that name", parameters[0].c_str());
78 COMMAND_INIT(CommandReloadmodule)