]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_setname.cpp
Add VF_COMMON to a lot modules which require it. Reported by danielg in bug #369...
[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 #include "users.h"
16 #include "channels.h"
17 #include "modules.h"
18
19 /* $ModDesc: Provides support for the SETNAME command */
20
21
22
23 class cmd_setname : public command_t
24 {
25  public:
26         cmd_setname (InspIRCd* Instance) : command_t(Instance,"SETNAME", 0, 1)
27         {
28                 this->source = "m_setname.so";
29                 syntax = "<new-gecos>";
30         }
31
32         CmdResult Handle (const char** parameters, int pcnt, userrec *user)
33         {
34                 if (!*parameters[0])
35                 {
36                         user->WriteServ("NOTICE %s :*** SETNAME: GECOS must be specified", user->nick);
37                         return CMD_FAILURE;
38                 }
39                 
40                 if (strlen(parameters[0]) > MAXGECOS)
41                 {
42                         user->WriteServ("NOTICE %s :*** SETNAME: GECOS too long", user->nick);
43                         return CMD_FAILURE;
44                 }
45                 
46                 if (user->ChangeName(parameters[0]))
47                 {
48                         ServerInstance->WriteOpers("%s used SETNAME to change their GECOS to %s", user->nick, parameters[0]);
49                         return CMD_SUCCESS;
50                 }
51
52                 return CMD_SUCCESS;
53         }
54 };
55
56
57 class ModuleSetName : public Module
58 {
59         cmd_setname*    mycommand;
60  public:
61         ModuleSetName(InspIRCd* Me)
62                 : Module(Me)
63         {
64                 
65                 mycommand = new cmd_setname(ServerInstance);
66                 ServerInstance->AddCommand(mycommand);
67         }
68         
69         virtual ~ModuleSetName()
70         {
71         }
72         
73         virtual Version GetVersion()
74         {
75                 return Version(1, 1, 0, 1, VF_COMMON | VF_VENDOR, API_VERSION);
76         }
77         
78 };
79
80 MODULE_INIT(ModuleSetName)