]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_setname.cpp
Added checks for empty ident/host/gecos in the chg* and set* commands. Patch by Stskeeps
[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                 std::string line;
35                 for (int i = 0; i < pcnt-1; i++)
36                 {
37                         line = line + std::string(parameters[i]) + " ";
38                 }
39                 
40                 line = line + std::string(parameters[pcnt-1]);
41                 if (line.length() == 0)
42                 {
43                         user->WriteServ("NOTICE %s :*** GECOS too short", user->nick);
44                         return CMD_FAILURE;
45                 }
46                 user->ChangeName(line.c_str());
47
48                 return CMD_SUCCESS;
49         }
50 };
51
52
53 class ModuleSetName : public Module
54 {
55         cmd_setname*    mycommand;
56  public:
57         ModuleSetName(InspIRCd* Me)
58                 : Module(Me)
59         {
60                 
61                 mycommand = new cmd_setname(ServerInstance);
62                 ServerInstance->AddCommand(mycommand);
63         }
64         
65         virtual ~ModuleSetName()
66         {
67         }
68         
69         virtual Version GetVersion()
70         {
71                 return Version(1,1,0,1,VF_VENDOR,API_VERSION);
72         }
73         
74 };
75
76 MODULE_INIT(ModuleSetName);