]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_chgname.cpp
Some more text fixes and improvements (#1618).
[user/henk/code/inspircd.git] / src / modules / m_chgname.cpp
1 /*
2  * InspIRCd -- Internet Relay Chat Daemon
3  *
4  *   Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
5  *   Copyright (C) 2007 Robin Burchell <robin+git@viroteck.net>
6  *
7  * This file is part of InspIRCd.  InspIRCd is free software: you can
8  * redistribute it and/or modify it under the terms of the GNU General Public
9  * License as published by the Free Software Foundation, version 2.
10  *
11  * This program is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
14  * details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  */
19
20
21 #include "inspircd.h"
22
23 /** Handle /CHGNAME
24  */
25 class CommandChgname : public Command
26 {
27  public:
28         CommandChgname(Module* Creator) : Command(Creator,"CHGNAME", 2, 2)
29         {
30                 allow_empty_last_param = false;
31                 flags_needed = 'o';
32                 syntax = "<nick> :<realname>";
33                 TRANSLATE2(TR_NICK, TR_TEXT);
34         }
35
36         CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE
37         {
38                 User* dest = ServerInstance->FindNick(parameters[0]);
39
40                 if ((!dest) || (dest->registered != REG_ALL))
41                 {
42                         user->WriteNumeric(Numerics::NoSuchNick(parameters[0]));
43                         return CMD_FAILURE;
44                 }
45
46                 if (parameters[1].empty())
47                 {
48                         user->WriteNotice("*** CHGNAME: Real name must be specified");
49                         return CMD_FAILURE;
50                 }
51
52                 if (parameters[1].length() > ServerInstance->Config->Limits.MaxReal)
53                 {
54                         user->WriteNotice("*** CHGNAME: Real name is too long");
55                         return CMD_FAILURE;
56                 }
57
58                 if (IS_LOCAL(dest))
59                 {
60                         dest->ChangeRealName(parameters[1]);
61                         ServerInstance->SNO->WriteGlobalSno('a', "%s used CHGNAME to change %s's real name to '%s'", user->nick.c_str(), dest->nick.c_str(), dest->GetRealName().c_str());
62                 }
63
64                 return CMD_SUCCESS;
65         }
66
67         RouteDescriptor GetRouting(User* user, const Params& parameters) CXX11_OVERRIDE
68         {
69                 return ROUTE_OPT_UCAST(parameters[0]);
70         }
71 };
72
73 class ModuleChgName : public Module
74 {
75         CommandChgname cmd;
76
77 public:
78         ModuleChgName() : cmd(this)
79         {
80         }
81
82         Version GetVersion() CXX11_OVERRIDE
83         {
84                 return Version("Provides the CHGNAME command", VF_OPTCOMMON | VF_VENDOR);
85         }
86 };
87
88 MODULE_INIT(ModuleChgName)