]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_setname.cpp
Remove unnecessary header traffic
[user/henk/code/inspircd.git] / src / modules / m_setname.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2007 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 cmd_setname : public command_t
21 {
22  public:
23         cmd_setname (InspIRCd* Instance) : command_t(Instance,"SETNAME", 0, 1)
24         {
25                 this->source = "m_setname.so";
26                 syntax = "<new-gecos>";
27         }
28
29         CmdResult Handle (const char** parameters, int pcnt, userrec *user)
30         {
31                 if (!*parameters[0])
32                 {
33                         user->WriteServ("NOTICE %s :*** SETNAME: GECOS must be specified", user->nick);
34                         return CMD_FAILURE;
35                 }
36                 
37                 if (strlen(parameters[0]) > MAXGECOS)
38                 {
39                         user->WriteServ("NOTICE %s :*** SETNAME: GECOS too long", user->nick);
40                         return CMD_FAILURE;
41                 }
42                 
43                 if (user->ChangeName(parameters[0]))
44                 {
45                         ServerInstance->WriteOpers("%s used SETNAME to change their GECOS to %s", user->nick, parameters[0]);
46                         return CMD_SUCCESS;
47                 }
48
49                 return CMD_SUCCESS;
50         }
51 };
52
53
54 class ModuleSetName : public Module
55 {
56         cmd_setname*    mycommand;
57  public:
58         ModuleSetName(InspIRCd* Me)
59                 : Module(Me)
60         {
61                 
62                 mycommand = new cmd_setname(ServerInstance);
63                 ServerInstance->AddCommand(mycommand);
64         }
65         
66         virtual ~ModuleSetName()
67         {
68         }
69         
70         virtual Version GetVersion()
71         {
72                 return Version(1, 1, 0, 1, VF_COMMON | VF_VENDOR, API_VERSION);
73         }
74         
75 };
76
77 MODULE_INIT(ModuleSetName)