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 (InspIRCd* Instance) : Command(Instance,"SAKICK", "o", 2, 3, false, 0)
25 this->source = "m_sakick.so";
26 syntax = "<channel> <nick> [reason]";
27 TRANSLATE4(TR_TEXT, TR_NICK, TR_TEXT, TR_END);
30 CmdResult Handle (const std::vector<std::string>& parameters, User *user)
32 User* dest = ServerInstance->FindNick(parameters[1]);
33 Channel* channel = ServerInstance->FindChan(parameters[0]);
34 const char* reason = "";
35 const char* servername = NULL;
39 if (parameters.size() > 2)
41 reason = parameters[2].c_str();
45 reason = dest->nick.c_str();
48 if (ServerInstance->ULine(dest->server))
50 user->WriteNumeric(ERR_NOPRIVILEGES, "%s :Cannot use an SA command on a u-lined client", user->nick.c_str());
54 /* For local clients, directly kick them. For remote clients,
55 * just return CMD_SUCCESS knowing the protocol module will route the SAKICK to the user's
56 * local server and that will kick them instead.
60 if (!channel->ServerKickUser(dest, reason, servername))
63 Channel *n = ServerInstance->FindChan(parameters[1]);
64 if (n && n->HasUser(dest))
66 /* Sort-of-bug: If the command was issued remotely, this message won't be sent */
67 user->WriteServ("NOTICE %s :*** Unable to kick %s from %s", user->nick.c_str(), dest->nick.c_str(), parameters[0].c_str());
74 /* Locally issued command; send the snomasks */
75 ServerInstance->SNO->WriteGlobalSno('a', std::string(user->nick) + " SAKICKed " + dest->nick + " on " + parameters[0]);
82 user->WriteServ("NOTICE %s :*** Invalid nickname or channel", user->nick.c_str());
89 class ModuleSakick : public Module
91 CommandSakick* mycommand;
93 ModuleSakick(InspIRCd* Me)
97 mycommand = new CommandSakick(ServerInstance);
98 ServerInstance->AddCommand(mycommand);
102 virtual ~ModuleSakick()
106 virtual Version GetVersion()
108 return Version("$Id$", VF_COMMON|VF_VENDOR, API_VERSION);
113 MODULE_INIT(ModuleSakick)