2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
5 * Copyright (C) 2008 Craig Edwards <craigedwards@brainbox.cc>
6 * Copyright (C) 2007 Robin Burchell <robin+git@viroteck.net>
8 * This file is part of InspIRCd. InspIRCd is free software: you can
9 * redistribute it and/or modify it under the terms of the GNU General Public
10 * License as published by the Free Software Foundation, version 2.
12 * This program is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 /** Handle /MODULES. These command handlers can be reloaded by the core,
25 * and handle basic RFC1459 commands. Commands within modules work
26 * the same way, however, they can be fully unloaded, where these
29 class CommandModules : public Command
32 /** Constructor for modules.
34 CommandModules(Module* parent) : Command(parent,"MODULES",0,0)
37 syntax = "[<servername>]";
41 * @param parameters The parameters to the comamnd
42 * @param pcnt The number of parameters passed to teh command
43 * @param user The user issuing the command
44 * @return A value from CmdResult to indicate command success or failure.
46 CmdResult Handle(const std::vector<std::string>& parameters, User *user);
47 RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters)
49 if (parameters.size() >= 1)
50 return ROUTE_UNICAST(parameters[0]);
51 return ROUTE_LOCALONLY;
57 CmdResult CommandModules::Handle (const std::vector<std::string>& parameters, User *user)
59 if (parameters.size() >= 1 && parameters[0] != ServerInstance->Config->ServerName)
62 std::vector<std::string> module_names = ServerInstance->Modules->GetAllModuleNames(0);
64 for (unsigned int i = 0; i < module_names.size(); i++)
66 Module* m = ServerInstance->Modules->Find(module_names[i]);
67 Version V = m->GetVersion();
69 if (IS_LOCAL(user) && user->HasPrivPermission("servers/auspex"))
71 std::string flags("SvcC");
73 for (int mult = 1; mult <= VF_OPTCOMMON; mult *= 2, ++pos)
74 if (!(V.Flags & mult))
78 user->SendText(":%s 702 %s :%p %s %s :%s", ServerInstance->Config->ServerName.c_str(),
79 user->nick.c_str(), (void*)m, module_names[i].c_str(), flags.c_str(), V.description.c_str());
81 std::string srcrev = m->ModuleDLLManager->GetVersion();
82 user->SendText(":%s 702 %s :%p %s %s :%s - %s", ServerInstance->Config->ServerName.c_str(),
83 user->nick.c_str(), (void*)m, module_names[i].c_str(), flags.c_str(), V.description.c_str(), srcrev.c_str());
88 user->SendText(":%s 702 %s :%s %s", ServerInstance->Config->ServerName.c_str(),
89 user->nick.c_str(), module_names[i].c_str(), V.description.c_str());
92 user->SendText(":%s 703 %s :End of MODULES list", ServerInstance->Config->ServerName.c_str(), user->nick.c_str());
97 COMMAND_INIT(CommandModules)