]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_sakick.cpp
Fix the cloaking module on C++98 compilers.
[user/henk/code/inspircd.git] / src / modules / m_sakick.cpp
index baf755b4897559f0a60c86271e3bee9fa7def79a..4938d5936ddfa858ba147d78f0b2eeb87cc45f2a 100644 (file)
@@ -1,7 +1,11 @@
 /*
  * InspIRCd -- Internet Relay Chat Daemon
  *
- *   Copyright (C) 2009 John Brooks <john.brooks@dereferenced.net>
+ *   Copyright (C) 2013, 2018, 2020 Sadie Powell <sadie@witchery.services>
+ *   Copyright (C) 2012-2014, 2016 Attila Molnar <attilamolnar@hush.com>
+ *   Copyright (C) 2012, 2019 Robby <robby@chatbelgie.be>
+ *   Copyright (C) 2010 Craig Edwards <brain@inspircd.org>
+ *   Copyright (C) 2009 John Brooks <special@inspircd.org>
  *   Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
  *
  * This file is part of InspIRCd.  InspIRCd is free software: you can
@@ -20,8 +24,6 @@
 
 #include "inspircd.h"
 
-/* $ModDesc: Provides a SAKICK command */
-
 /** Handle /SAKICK
  */
 class CommandSakick : public Command
@@ -29,30 +31,29 @@ class CommandSakick : public Command
  public:
        CommandSakick(Module* Creator) : Command(Creator,"SAKICK", 2, 3)
        {
-               flags_needed = 'o'; Penalty = 0; syntax = "<channel> <nick> [reason]";
-               TRANSLATE4(TR_TEXT, TR_NICK, TR_TEXT, TR_END);
+               flags_needed = 'o';
+               syntax = "<channel> <nick> [:<reason>]";
+               TRANSLATE3(TR_TEXT, TR_NICK, TR_TEXT);
        }
 
-       CmdResult Handle (const std::vector<std::string>& parameters, User *user)
+       CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE
        {
                User* dest = ServerInstance->FindNick(parameters[1]);
                Channel* channel = ServerInstance->FindChan(parameters[0]);
-               const char* reason = "";
 
                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,21 +63,9 @@ 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->WriteNotice("*** Unable to kick " + dest->nick + " from " + parameters[0]);
-                                       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;
@@ -89,12 +78,9 @@ class CommandSakick : public Command
                return CMD_FAILURE;
        }
 
-       RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters)
+       RouteDescriptor GetRouting(User* user, const Params& parameters) CXX11_OVERRIDE
        {
-               User* dest = ServerInstance->FindNick(parameters[1]);
-               if (dest)
-                       return ROUTE_OPT_UCAST(dest->server);
-               return ROUTE_LOCALONLY;
+               return ROUTE_OPT_UCAST(parameters[1]);
        }
 };
 
@@ -107,14 +93,9 @@ class ModuleSakick : public Module
        {
        }
 
-       void init()
-       {
-               ServerInstance->Modules->AddService(cmd);
-       }
-
-       virtual Version GetVersion()
+       Version GetVersion() CXX11_OVERRIDE
        {
-               return Version("Provides a SAKICK command", VF_OPTCOMMON|VF_VENDOR);
+               return Version("Adds the /SAKICK command which allows server operators to kick users from a channel without having any privileges in the channel.", VF_OPTCOMMON|VF_VENDOR);
        }
 };