]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/commands/cmd_stats.cpp
Remove channel argument from OnSendWhoLine, this information is already available...
[user/henk/code/inspircd.git] / src / commands / cmd_stats.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2010 InspIRCd Development Team
6  * See: http://wiki.inspircd.org/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 #ifndef WIN32
16         #include <sys/resource.h>
17         /* This is just to be completely certain that the change which fixed getrusage on RH7 doesn't break anything else -- Om */
18         #ifndef RUSAGE_SELF
19         #define RUSAGE_SELF 0
20         #endif
21 #else
22         #include <psapi.h>
23         #include "inspircd_win32wrapper.h"
24         #pragma comment(lib, "psapi.lib")
25 #endif
26
27 #include "xline.h"
28
29 /** Handle /STATS. These command handlers can be reloaded by the core,
30  * and handle basic RFC1459 commands. Commands within modules work
31  * the same way, however, they can be fully unloaded, where these
32  * may not.
33  */
34 class CommandStats : public Command
35 {
36  public:
37         /** Constructor for stats.
38          */
39         CommandStats ( Module* parent) : Command(parent,"STATS",1,2) { syntax = "<stats-symbol> [<servername>]"; }
40         /** Handle command.
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.
45          */
46         CmdResult Handle(const std::vector<std::string>& parameters, User *user);
47         RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters)
48         {
49                 if (parameters.size() > 1)
50                         return ROUTE_UNICAST(parameters[1]);
51                 return ROUTE_LOCALONLY;
52         }
53 };
54
55 CmdResult CommandStats::Handle (const std::vector<std::string>& parameters, User *user)
56 {
57         if (parameters.size() > 1 && parameters[1] != ServerInstance->Config->ServerName)
58                 return CMD_SUCCESS;
59         string_list values;
60         char search = parameters[0][0];
61         ServerInstance->DoStats(search, user, values);
62         for (size_t i = 0; i < values.size(); i++)
63                 user->SendText(":%s", values[i].c_str());
64
65         return CMD_SUCCESS;
66 }
67
68 COMMAND_INIT(CommandStats)