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