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