]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_setname.cpp
Remove InspIRCd* parameters and fields
[user/henk/code/inspircd.git] / src / modules / m_setname.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2009 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 /* $ModDesc: Provides support for the SETNAME command */
17
18
19
20 class CommandSetname : public Command
21 {
22  public:
23         CommandSetname(Module* Creator) : Command(Creator,"SETNAME", 1, 1)
24         {
25                 syntax = "<new-gecos>";
26                 TRANSLATE2(TR_TEXT, TR_END);
27         }
28
29         CmdResult Handle (const std::vector<std::string>& parameters, User *user)
30         {
31                 if (parameters.size() == 0)
32                 {
33                         user->WriteServ("NOTICE %s :*** SETNAME: GECOS must be specified", user->nick.c_str());
34                         return CMD_FAILURE;
35                 }
36
37                 if (parameters[0].size() > ServerInstance->Config->Limits.MaxGecos)
38                 {
39                         user->WriteServ("NOTICE %s :*** SETNAME: GECOS too long", user->nick.c_str());
40                         return CMD_FAILURE;
41                 }
42
43                 if (user->ChangeName(parameters[0].c_str()))
44                 {
45                         ServerInstance->SNO->WriteGlobalSno('a', "%s used SETNAME to change their GECOS to %s", user->nick.c_str(), parameters[0].c_str());
46                         return CMD_SUCCESS;
47                 }
48
49                 return CMD_SUCCESS;
50         }
51 };
52
53
54 class ModuleSetName : public Module
55 {
56         CommandSetname cmd;
57  public:
58         ModuleSetName()
59                 : cmd(this)
60         {
61                 ServerInstance->AddCommand(&cmd);
62         }
63
64         virtual ~ModuleSetName()
65         {
66         }
67
68         virtual Version GetVersion()
69         {
70                 return Version("Provides support for the SETNAME command", VF_VENDOR, API_VERSION);
71         }
72 };
73
74 MODULE_INIT(ModuleSetName)