1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2009 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 = "";
34 const char* servername = NULL;
38 if (parameters.size() > 2)
40 reason = parameters[2].c_str();
44 reason = dest->nick.c_str();
47 if (ServerInstance->ULine(dest->server))
49 user->WriteNumeric(ERR_NOPRIVILEGES, "%s :Cannot use an SA command on a u-lined client", user->nick.c_str());
53 /* For local clients, directly kick them. For remote clients,
54 * just return CMD_SUCCESS knowing the protocol module will route the SAKICK to the user's
55 * local server and that will kick them instead.
59 if (!channel->ServerKickUser(dest, reason, servername))
62 Channel *n = ServerInstance->FindChan(parameters[1]);
63 if (n && n->HasUser(dest))
65 /* Sort-of-bug: If the command was issued remotely, this message won't be sent */
66 user->WriteServ("NOTICE %s :*** Unable to kick %s from %s", user->nick.c_str(), dest->nick.c_str(), parameters[0].c_str());
73 /* Locally issued command; send the snomasks */
74 ServerInstance->SNO->WriteGlobalSno('a', std::string(user->nick) + " SAKICKed " + dest->nick + " on " + parameters[0]);
81 user->WriteServ("NOTICE %s :*** Invalid nickname or channel", user->nick.c_str());
87 RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters)
89 User* dest = ServerInstance->FindNick(parameters[1]);
91 return ROUTE_OPT_UCAST(dest->server);
92 return ROUTE_LOCALONLY;
96 class ModuleSakick : public Module
103 ServerInstance->AddCommand(&cmd);
106 virtual ~ModuleSakick()
110 virtual Version GetVersion()
112 return Version("Provides a SAKICK command", VF_OPTCOMMON|VF_VENDOR);
117 MODULE_INIT(ModuleSakick)