1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2010 InspIRCd Development Team
6 * See: http://wiki.inspircd.org/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
16 /* $ModDesc: Provides a SAKICK command */
20 class CommandSakick : public Command
23 CommandSakick(Module* Creator) : Command(Creator,"SAKICK", 2, 3)
25 flags_needed = 'o'; Penalty = 0; syntax = "<channel> <nick> [reason]";
26 TRANSLATE4(TR_TEXT, TR_NICK, TR_TEXT, TR_END);
29 CmdResult Handle (const std::vector<std::string>& parameters, User *user)
31 User* dest = ServerInstance->FindNick(parameters[1]);
32 Channel* channel = ServerInstance->FindChan(parameters[0]);
33 const char* reason = "";
37 if (parameters.size() > 2)
39 reason = parameters[2].c_str();
43 reason = dest->nick.c_str();
46 if (ServerInstance->ULine(dest->server))
48 user->WriteNumeric(ERR_NOPRIVILEGES, "%s :Cannot use an SA command on a u-lined client", user->nick.c_str());
52 /* For local clients, directly kick them. For remote clients,
53 * just return CMD_SUCCESS knowing the protocol module will route the SAKICK to the user's
54 * local server and that will kick them instead.
58 channel->KickUser(ServerInstance->FakeClient, dest, reason);
60 Channel *n = ServerInstance->FindChan(parameters[1]);
61 if (n && n->HasUser(dest))
63 /* Sort-of-bug: If the command was issued remotely, this message won't be sent */
64 user->WriteServ("NOTICE %s :*** Unable to kick %s from %s", user->nick.c_str(), dest->nick.c_str(), parameters[0].c_str());
71 /* Locally issued command; send the snomasks */
72 ServerInstance->SNO->WriteGlobalSno('a', std::string(user->nick) + " SAKICKed " + dest->nick + " on " + parameters[0]);
79 user->WriteServ("NOTICE %s :*** Invalid nickname or channel", user->nick.c_str());
85 RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters)
87 User* dest = ServerInstance->FindNick(parameters[1]);
89 return ROUTE_OPT_UCAST(dest->server);
90 return ROUTE_LOCALONLY;
94 class ModuleSakick : public Module
101 ServerInstance->AddCommand(&cmd);
104 virtual ~ModuleSakick()
108 virtual Version GetVersion()
110 return Version("Provides a SAKICK command", VF_OPTCOMMON|VF_VENDOR);
115 MODULE_INIT(ModuleSakick)