2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2009 John Brooks <john.brooks@dereferenced.net>
5 * Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
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/>.
25 class CommandSakick : public Command
28 CommandSakick(Module* Creator) : Command(Creator,"SAKICK", 2, 3)
30 flags_needed = 'o'; Penalty = 0; syntax = "<channel> <nick> [reason]";
31 TRANSLATE3(TR_TEXT, TR_NICK, TR_TEXT);
34 CmdResult Handle (const std::vector<std::string>& parameters, User *user)
36 User* dest = ServerInstance->FindNick(parameters[1]);
37 Channel* channel = ServerInstance->FindChan(parameters[0]);
38 const char* reason = "";
40 if ((dest) && (dest->registered == REG_ALL) && (channel))
42 if (parameters.size() > 2)
44 reason = parameters[2].c_str();
48 reason = dest->nick.c_str();
51 if (ServerInstance->ULine(dest->server))
53 user->WriteNumeric(ERR_NOPRIVILEGES, ":Cannot use an SA command on a u-lined client");
57 if (!channel->HasUser(dest))
59 user->WriteNotice("*** " + dest->nick + " is not on " + channel->name);
63 /* For local clients, directly kick them. For remote clients,
64 * just return CMD_SUCCESS knowing the protocol module will route the SAKICK to the user's
65 * local server and that will kick them instead.
69 // Target is on this server, kick them and send the snotice
70 channel->KickUser(ServerInstance->FakeClient, dest, reason);
71 ServerInstance->SNO->WriteGlobalSno('a', user->nick + " SAKICKed " + dest->nick + " on " + channel->name);
78 user->WriteNotice("*** Invalid nickname or channel");
84 RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters)
86 User* dest = ServerInstance->FindNick(parameters[1]);
88 return ROUTE_OPT_UCAST(dest->server);
89 return ROUTE_LOCALONLY;
93 class ModuleSakick : public Module
102 Version GetVersion() CXX11_OVERRIDE
104 return Version("Provides a SAKICK command", VF_OPTCOMMON|VF_VENDOR);
108 MODULE_INIT(ModuleSakick)