]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_chgname.cpp
Remove unnecessary header traffic
[user/henk/code/inspircd.git] / src / modules / m_chgname.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 CHGNAME command */
17
18 /** Handle /CHGNAME
19  */
20 class cmd_chgname : public command_t
21 {
22  public:
23         cmd_chgname (InspIRCd* Instance) : command_t(Instance,"CHGNAME", 'o', 2)
24         {
25                 this->source = "m_chgname.so";
26                 syntax = "<nick> <newname>";
27         }
28         
29         CmdResult Handle(const char** parameters, int pcnt, userrec *user)
30         {
31                 userrec* dest = ServerInstance->FindNick(parameters[0]);
32
33                 if (!dest)
34                 {
35                         user->WriteServ("401 %s %s :No such nick/channel", user->nick, parameters[0]);
36                         return CMD_FAILURE;
37                 }
38                 
39                 if (!*parameters[1])
40                 {
41                         user->WriteServ("NOTICE %s :*** GECOS must be specified", user->nick);
42                         return CMD_FAILURE;
43                 }
44                 
45                 if (strlen(parameters[1]) > MAXGECOS)
46                 {
47                         user->WriteServ("NOTICE %s :*** GECOS too long", user->nick);
48                         return CMD_FAILURE;
49                 }
50                 
51                 if (IS_LOCAL(dest))
52                 {
53                         dest->ChangeName(parameters[1]);
54                         ServerInstance->WriteOpers("%s used CHGNAME to change %s's real name to '%s'", user->nick, dest->nick, dest->fullname);
55                         return CMD_LOCALONLY; /* name change routed by FNAME in spanningtree now */
56                 }
57
58                 /* route it! */
59                 return CMD_SUCCESS;
60         }
61 };
62
63
64 class ModuleChgName : public Module
65 {
66         cmd_chgname* mycommand;
67         
68         
69 public:
70         ModuleChgName(InspIRCd* Me) : Module(Me)
71         {
72                 mycommand = new cmd_chgname(ServerInstance);
73                 ServerInstance->AddCommand(mycommand);
74         }
75         
76         virtual ~ModuleChgName()
77         {
78         }
79         
80         virtual Version GetVersion()
81         {
82                 return Version(1, 1, 0, 0, VF_COMMON | VF_VENDOR, API_VERSION);
83         }
84         
85 };
86
87 MODULE_INIT(ModuleChgName)