2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2013, 2018, 2020 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 John Brooks <special@inspircd.org>
9 * Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
11 * This file is part of InspIRCd. InspIRCd is free software: you can
12 * redistribute it and/or modify it under the terms of the GNU General Public
13 * License as published by the Free Software Foundation, version 2.
15 * This program is distributed in the hope that it will be useful, but WITHOUT
16 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <http://www.gnu.org/licenses/>.
29 class CommandSakick : public Command
32 CommandSakick(Module* Creator) : Command(Creator,"SAKICK", 2, 3)
35 syntax = "<channel> <nick> [:<reason>]";
36 TRANSLATE3(TR_TEXT, TR_NICK, TR_TEXT);
39 CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE
41 User* dest = ServerInstance->FindNick(parameters[1]);
42 Channel* channel = ServerInstance->FindChan(parameters[0]);
44 if ((dest) && (dest->registered == REG_ALL) && (channel))
46 const std::string& reason = (parameters.size() > 2) ? parameters[2] : dest->nick;
48 if (dest->server->IsULine())
50 user->WriteNumeric(ERR_NOPRIVILEGES, "Cannot use an SA command on a U-lined client");
54 if (!channel->HasUser(dest))
56 user->WriteNotice("*** " + dest->nick + " is not on " + channel->name);
60 /* For local clients, directly kick them. For remote clients,
61 * just return CMD_SUCCESS knowing the protocol module will route the SAKICK to the user's
62 * local server and that will kick them instead.
66 // Target is on this server, kick them and send the snotice
67 channel->KickUser(ServerInstance->FakeClient, dest, reason);
68 ServerInstance->SNO->WriteGlobalSno('a', user->nick + " SAKICKed " + dest->nick + " on " + channel->name);
75 user->WriteNotice("*** Invalid nickname or channel");
81 RouteDescriptor GetRouting(User* user, const Params& parameters) CXX11_OVERRIDE
83 return ROUTE_OPT_UCAST(parameters[1]);
87 class ModuleSakick : public Module
96 Version GetVersion() CXX11_OVERRIDE
98 return Version("Adds the /SAKICK command which allows server operators to kick users from a channel without having any privileges in the channel.", VF_OPTCOMMON|VF_VENDOR);
102 MODULE_INIT(ModuleSakick)