2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
5 * Copyright (C) 2007 Robin Burchell <robin+git@viroteck.net>
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.
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
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/>.
23 /* $ModDesc: Provides support for the CHGNAME command */
27 class CommandChgname : public Command
30 CommandChgname(Module* Creator) : Command(Creator,"CHGNAME", 2, 2)
32 allow_empty_last_param = false;
34 syntax = "<nick> <newname>";
35 TRANSLATE3(TR_NICK, TR_TEXT, TR_END);
38 CmdResult Handle(const std::vector<std::string> ¶meters, User *user)
40 User* dest = ServerInstance->FindNick(parameters[0]);
42 if ((!dest) || (dest->registered != REG_ALL))
44 user->WriteNumeric(ERR_NOSUCHNICK, "%s %s :No such nick/channel", user->nick.c_str(), parameters[0].c_str());
48 if (parameters[1].empty())
50 user->WriteServ("NOTICE %s :*** CHGNAME: GECOS must be specified", user->nick.c_str());
54 if (parameters[1].length() > ServerInstance->Config->Limits.MaxGecos)
56 user->WriteServ("NOTICE %s :*** CHGNAME: GECOS too long", user->nick.c_str());
62 dest->ChangeName(parameters[1].c_str());
63 ServerInstance->SNO->WriteGlobalSno('a', "%s used CHGNAME to change %s's GECOS to '%s'", user->nick.c_str(), dest->nick.c_str(), dest->fullname.c_str());
69 RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters)
71 User* dest = ServerInstance->FindNick(parameters[0]);
73 return ROUTE_OPT_UCAST(dest->server);
74 return ROUTE_LOCALONLY;
79 class ModuleChgName : public Module
84 ModuleChgName() : cmd(this)
90 ServerInstance->Modules->AddService(cmd);
93 virtual ~ModuleChgName()
97 virtual Version GetVersion()
99 return Version("Provides support for the CHGNAME command", VF_OPTCOMMON | VF_VENDOR);
104 MODULE_INIT(ModuleChgName)