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/>.
26 class CommandModules : public Command
29 /** Constructor for modules.
31 CommandModules(Module* parent) : Command(parent,"MODULES",0,0)
34 syntax = "[<servername>]";
38 * @param parameters The parameters to the command
39 * @param user The user issuing the command
40 * @return A value from CmdResult to indicate command success or failure.
42 CmdResult Handle(const std::vector<std::string>& parameters, User *user);
43 RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters)
45 if (parameters.size() >= 1)
46 return ROUTE_UNICAST(parameters[0]);
47 return ROUTE_LOCALONLY;
53 CmdResult CommandModules::Handle (const std::vector<std::string>& parameters, User *user)
55 // Don't ask remote servers about their modules unless the local user asking is an oper
56 // 2.0 asks anyway, so let's handle that the same way
57 bool for_us = (parameters.empty() || parameters[0] == ServerInstance->Config->ServerName);
58 if ((!for_us) || (!IS_LOCAL(user)))
62 user->WriteNotice("*** You cannot check what modules other servers have loaded.");
66 // From an oper and not for us, forward
71 const ModuleManager::ModuleMap& mods = ServerInstance->Modules->GetModules();
73 for (ModuleManager::ModuleMap::const_iterator i = mods.begin(); i != mods.end(); ++i)
75 Module* m = i->second;
76 Version V = m->GetVersion();
78 if (IS_LOCAL(user) && user->HasPrivPermission("servers/auspex"))
80 std::string flags("SvcC");
82 for (int mult = 1; mult <= VF_OPTCOMMON; mult *= 2, ++pos)
83 if (!(V.Flags & mult))
87 user->SendText(":%s 702 %s :%p %s %s :%s", ServerInstance->Config->ServerName.c_str(),
88 user->nick.c_str(), (void*)m, m->ModuleSourceFile.c_str(), flags.c_str(), V.description.c_str());
90 std::string srcrev = m->ModuleDLLManager->GetVersion();
91 user->SendText(":%s 702 %s :%p %s %s :%s - %s", ServerInstance->Config->ServerName.c_str(),
92 user->nick.c_str(), (void*)m, m->ModuleSourceFile.c_str(), flags.c_str(), V.description.c_str(), srcrev.c_str());
97 user->SendText(":%s 702 %s :%s %s", ServerInstance->Config->ServerName.c_str(),
98 user->nick.c_str(), m->ModuleSourceFile.c_str(), V.description.c_str());
101 user->SendText(":%s 703 %s :End of MODULES list", ServerInstance->Config->ServerName.c_str(), user->nick.c_str());
106 COMMAND_INIT(CommandModules)