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