]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/commands/cmd_modules.cpp
Tidier /modules generation. faster for non-opers, neater for all, and doesnt use...
[user/henk/code/inspircd.git] / src / commands / cmd_modules.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2008 InspIRCd Development Team
6  * See: http://www.inspircd.org/wiki/index.php/Credits
7  *
8  * This program is free but copyrighted software; see
9  *            the file COPYING for details.
10  *
11  * ---------------------------------------------------
12  */
13
14 #include "inspircd.h"
15 #include "commands/cmd_modules.h"
16
17 extern "C" DllExport Command* init_command(InspIRCd* Instance)
18 {
19         return new CommandModules(Instance);
20 }
21
22 /** Handle /MODULES
23  */
24 CmdResult CommandModules::Handle (const std::vector<std::string>&, User *user)
25 {
26         std::vector<std::string> module_names = ServerInstance->Modules->GetAllModuleNames(0);
27
28         for (unsigned int i = 0; i < module_names.size(); i++)
29         {
30                 Module* m = ServerInstance->Modules->Find(module_names[i]);
31                 Version V = m->GetVersion();
32
33                 if (IS_OPER(user))
34                 {
35                         std::string flags("Svsc");
36                         int pos = 0;
37                         for (int mult = 1; mult <= VF_SERVICEPROVIDER; mult *= 2, ++pos)
38                                 if (!(V.Flags & mult))
39                                         flags[pos] = '-';
40
41                         user->WriteNumeric(702, "%s :0x%08lx %s %s :%s", user->nick.c_str(), (unsigned long)m, module_names[i].c_str(), flags.c_str(), V.version.c_str());
42                 }
43                 else
44                 {
45                         user->WriteNumeric(702, "%s :%s",user->nick.c_str(), module_names[i].c_str());
46                 }
47         }
48         user->WriteNumeric(703, "%s :End of MODULES list",user->nick.c_str());
49
50         return CMD_SUCCESS;
51 }