2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2013, 2018 Sadie Powell <sadie@witchery.services>
5 * Copyright (C) 2012-2014, 2016 Attila Molnar <attilamolnar@hush.com>
6 * Copyright (C) 2012, 2019 Robby <robby@chatbelgie.be>
7 * Copyright (C) 2010 Craig Edwards <brain@inspircd.org>
8 * Copyright (C) 2009-2010 Daniel De Graaf <danieldg@inspircd.org>
9 * Copyright (C) 2007-2008 Robin Burchell <robin+git@viroteck.net>
10 * Copyright (C) 2007, 2009 Dennis Friis <peavey@inspircd.org>
12 * This file is part of InspIRCd. InspIRCd is free software: you can
13 * redistribute it and/or modify it under the terms of the GNU General Public
14 * License as published by the Free Software Foundation, version 2.
16 * This program is distributed in the hope that it will be useful, but WITHOUT
17 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <http://www.gnu.org/licenses/>.
30 class CommandSanick : public Command
33 CommandSanick(Module* Creator) : Command(Creator,"SANICK", 2)
35 allow_empty_last_param = false;
36 flags_needed = 'o'; syntax = "<nick> <newnick>";
37 TRANSLATE2(TR_NICK, TR_TEXT);
40 CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE
42 User* target = ServerInstance->FindNick(parameters[0]);
44 /* Do local sanity checks and bails */
47 if (target && target->server->IsULine())
49 user->WriteNumeric(ERR_NOPRIVILEGES, "Cannot use an SA command on a U-lined client");
53 if ((!target) || (target->registered != REG_ALL))
55 user->WriteNotice("*** No such nickname: '" + parameters[0] + "'");
59 if (!ServerInstance->IsNick(parameters[1]))
61 user->WriteNotice("*** Invalid nickname: '" + parameters[1] + "'");
66 /* Have we hit target's server yet? */
67 if (target && IS_LOCAL(target))
69 std::string oldnick = user->nick;
70 std::string newnick = target->nick;
71 if (target->ChangeNick(parameters[1]))
73 ServerInstance->SNO->WriteGlobalSno('a', oldnick+" used SANICK to change "+newnick+" to "+parameters[1]);
77 ServerInstance->SNO->WriteGlobalSno('a', oldnick+" failed SANICK (from "+newnick+" to "+parameters[1]+")");
84 RouteDescriptor GetRouting(User* user, const Params& parameters) CXX11_OVERRIDE
86 return ROUTE_OPT_UCAST(parameters[0]);
91 class ModuleSanick : public Module
100 Version GetVersion() CXX11_OVERRIDE
102 return Version("Provides the SANICK command, allows opers to change the nicknames of users", VF_OPTCOMMON | VF_VENDOR);
106 MODULE_INIT(ModuleSanick)