]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/commands/cmd_admin.cpp
This fixes issue #39 reported by @attilamolnar.
[user/henk/code/inspircd.git] / src / commands / cmd_admin.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
16 /** Handle /ADMIN. These command handlers can be reloaded by the core,
17  * and handle basic RFC1459 commands. Commands within modules work
18  * the same way, however, they can be fully unloaded, where these
19  * may not.
20  */
21 class CommandAdmin : public Command
22 {
23  public:
24         /** Constructor for admin.
25          */
26         CommandAdmin(Module* parent) : Command(parent,"ADMIN",0,0) { syntax = "[<servername>]"; }
27         /** Handle command.
28          * @param parameters The parameters to the comamnd
29          * @param pcnt The number of parameters passed to teh command
30          * @param user The user issuing the command
31          * @return A value from CmdResult to indicate command success or failure.
32          */
33         CmdResult Handle(const std::vector<std::string>& parameters, User *user);
34         RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters)
35         {
36                 if (parameters.size() > 0)
37                         return ROUTE_UNICAST(parameters[0]);
38                 return ROUTE_LOCALONLY;
39         }
40 };
41
42 /** Handle /ADMIN
43  */
44 CmdResult CommandAdmin::Handle (const std::vector<std::string>& parameters, User *user)
45 {
46         if (parameters.size() > 0 && parameters[0] != ServerInstance->Config->ServerName)
47                 return CMD_SUCCESS;
48         user->SendText(":%s %03d %s :Administrative info for %s", ServerInstance->Config->ServerName.c_str(),
49                 RPL_ADMINME, user->nick.c_str(),ServerInstance->Config->ServerName.c_str());
50         if (!ServerInstance->Config->AdminName.empty())
51                 user->SendText(":%s %03d %s :Name     - %s", ServerInstance->Config->ServerName.c_str(),
52                         RPL_ADMINLOC1, user->nick.c_str(), ServerInstance->Config->AdminName.c_str());
53         user->SendText(":%s %03d %s :Nickname - %s", ServerInstance->Config->ServerName.c_str(),
54                 RPL_ADMINLOC2, user->nick.c_str(), ServerInstance->Config->AdminNick.c_str());
55         user->SendText(":%s %03d %s :E-Mail   - %s", ServerInstance->Config->ServerName.c_str(),
56                 RPL_ADMINEMAIL, user->nick.c_str(), ServerInstance->Config->AdminEmail.c_str());
57         return CMD_SUCCESS;
58 }
59
60 COMMAND_INIT(CommandAdmin)