X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_sakick.cpp;h=8fc6e741be1fab8d66fdd9e25063978111ff6b23;hb=da29af8cba49d51e53d6e68237ccbf6370b6dd1f;hp=d1c0f6e9257ad6c256bdff05128fa434a08eae80;hpb=ac7defcd3e52695dcf5e5150e9fe3e1624205e64;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_sakick.cpp b/src/modules/m_sakick.cpp index d1c0f6e92..8fc6e741b 100644 --- a/src/modules/m_sakick.cpp +++ b/src/modules/m_sakick.cpp @@ -20,8 +20,6 @@ #include "inspircd.h" -/* $ModDesc: Provides a SAKICK command */ - /** Handle /SAKICK */ class CommandSakick : public Command @@ -30,29 +28,27 @@ class CommandSakick : public Command CommandSakick(Module* Creator) : Command(Creator,"SAKICK", 2, 3) { flags_needed = 'o'; Penalty = 0; syntax = " [reason]"; - TRANSLATE4(TR_TEXT, TR_NICK, TR_TEXT, TR_END); + TRANSLATE3(TR_TEXT, TR_NICK, TR_TEXT); } CmdResult Handle (const std::vector& parameters, User *user) { User* dest = ServerInstance->FindNick(parameters[1]); Channel* channel = ServerInstance->FindChan(parameters[0]); - const char* reason = ""; - if (dest && channel) + if ((dest) && (dest->registered == REG_ALL) && (channel)) { - if (parameters.size() > 2) - { - reason = parameters[2].c_str(); - } - else + const std::string& reason = (parameters.size() > 2) ? parameters[2] : dest->nick; + + if (dest->server->IsULine()) { - reason = dest->nick.c_str(); + user->WriteNumeric(ERR_NOPRIVILEGES, "Cannot use an SA command on a u-lined client"); + return CMD_FAILURE; } - if (ServerInstance->ULine(dest->server)) + if (!channel->HasUser(dest)) { - user->WriteNumeric(ERR_NOPRIVILEGES, "%s :Cannot use an SA command on a u-lined client", user->nick.c_str()); + user->WriteNotice("*** " + dest->nick + " is not on " + channel->name); return CMD_FAILURE; } @@ -62,28 +58,16 @@ class CommandSakick : public Command */ if (IS_LOCAL(dest)) { + // Target is on this server, kick them and send the snotice channel->KickUser(ServerInstance->FakeClient, dest, reason); - - Channel *n = ServerInstance->FindChan(parameters[1]); - if (n && n->HasUser(dest)) - { - /* Sort-of-bug: If the command was issued remotely, this message won't be sent */ - user->WriteServ("NOTICE %s :*** Unable to kick %s from %s", user->nick.c_str(), dest->nick.c_str(), parameters[0].c_str()); - return CMD_FAILURE; - } - } - - if (IS_LOCAL(user)) - { - /* Locally issued command; send the snomasks */ - ServerInstance->SNO->WriteGlobalSno('a', user->nick + " SAKICKed " + dest->nick + " on " + parameters[0]); + ServerInstance->SNO->WriteGlobalSno('a', user->nick + " SAKICKed " + dest->nick + " on " + channel->name); } return CMD_SUCCESS; } else { - user->WriteServ("NOTICE %s :*** Invalid nickname or channel", user->nick.c_str()); + user->WriteNotice("*** Invalid nickname or channel"); } return CMD_FAILURE; @@ -107,21 +91,10 @@ class ModuleSakick : public Module { } - void init() - { - ServerInstance->AddCommand(&cmd); - } - - virtual ~ModuleSakick() - { - } - - virtual Version GetVersion() + Version GetVersion() CXX11_OVERRIDE { return Version("Provides a SAKICK command", VF_OPTCOMMON|VF_VENDOR); } - }; MODULE_INIT(ModuleSakick) -