]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_chgname.cpp
Update all wiki links to point to the new wiki. This was done automatically with...
[user/henk/code/inspircd.git] / src / modules / m_chgname.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2009 InspIRCd Development Team
6  * See: http://wiki.inspircd.org/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 CommandChgname : public Command
21 {
22  public:
23         CommandChgname (InspIRCd* Instance) : Command(Instance,"CHGNAME", "o", 2, 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 std::vector<std::string> &parameters, User *user)
31         {
32                 User* dest = ServerInstance->FindNick(parameters[0]);
33
34                 if (!dest)
35                 {
36                         user->WriteNumeric(ERR_NOSUCHNICK, "%s %s :No such nick/channel", user->nick.c_str(), parameters[0].c_str());
37                         return CMD_FAILURE;
38                 }
39
40                 if (parameters[1].empty())
41                 {
42                         user->WriteServ("NOTICE %s :*** GECOS must be specified", user->nick.c_str());
43                         return CMD_FAILURE;
44                 }
45
46                 if (parameters[1].length() > ServerInstance->Config->Limits.MaxGecos)
47                 {
48                         user->WriteServ("NOTICE %s :*** GECOS too long", user->nick.c_str());
49                         return CMD_FAILURE;
50                 }
51
52                 if (IS_LOCAL(dest))
53                 {
54                         dest->ChangeName(parameters[1].c_str());
55                         ServerInstance->SNO->WriteToSnoMask('A', "%s used CHGNAME to change %s's real name to '%s'", user->nick.c_str(), dest->nick.c_str(), dest->fullname.c_str());
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         CommandChgname* mycommand;
68
69
70 public:
71         ModuleChgName(InspIRCd* Me) : Module(Me)
72         {
73                 mycommand = new CommandChgname(ServerInstance);
74                 ServerInstance->AddCommand(mycommand);
75
76         }
77
78         virtual ~ModuleChgName()
79         {
80         }
81
82         virtual Version GetVersion()
83         {
84                 return Version("$Id$", VF_COMMON | VF_VENDOR, API_VERSION);
85         }
86
87 };
88
89 MODULE_INIT(ModuleChgName)