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