X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_sakick.cpp;h=4938d5936ddfa858ba147d78f0b2eeb87cc45f2a;hb=80e81e3b81b779901fd9d67f8ae030ee30c0bcec;hp=d171abe57cfa037ff6d4f295cf5f65b017959374;hpb=15e6efe1aec69a0d134a8dcfbd6ea8220428b0cb;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_sakick.cpp b/src/modules/m_sakick.cpp index d171abe57..4938d5936 100644 --- a/src/modules/m_sakick.cpp +++ b/src/modules/m_sakick.cpp @@ -1,53 +1,59 @@ -/* +------------------------------------+ - * | Inspire Internet Relay Chat Daemon | - * +------------------------------------+ +/* + * InspIRCd -- Internet Relay Chat Daemon * - * InspIRCd: (C) 2002-2009 InspIRCd Development Team - * See: http://wiki.inspircd.org/Credits + * Copyright (C) 2013, 2018, 2020 Sadie Powell + * Copyright (C) 2012-2014, 2016 Attila Molnar + * Copyright (C) 2012, 2019 Robby + * Copyright (C) 2010 Craig Edwards + * Copyright (C) 2009 John Brooks + * Copyright (C) 2009 Daniel De Graaf * - * This program is free but copyrighted software; see - * the file COPYING for details. + * This file is part of InspIRCd. InspIRCd is free software: you can + * redistribute it and/or modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation, version 2. * - * --------------------------------------------------- + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ -#include "inspircd.h" -/* $ModDesc: Provides a SAKICK command */ +#include "inspircd.h" /** Handle /SAKICK */ class CommandSakick : public Command { public: - CommandSakick (InspIRCd* Instance) : Command(Instance,"SAKICK", "o", 2, 3, false, 0) + CommandSakick(Module* Creator) : Command(Creator,"SAKICK", 2, 3) { - this->source = "m_sakick.so"; - syntax = " [reason]"; - TRANSLATE4(TR_TEXT, TR_NICK, TR_TEXT, TR_END); + flags_needed = 'o'; + syntax = " [:]"; + TRANSLATE3(TR_TEXT, TR_NICK, TR_TEXT); } - CmdResult Handle (const std::vector& 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 = ""; - const char* servername = NULL; - 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; } @@ -57,58 +63,40 @@ class CommandSakick : public Command */ if (IS_LOCAL(dest)) { - if (!channel->ServerKickUser(dest, reason, servername)) - delete channel; - - 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', std::string(user->nick) + " SAKICKed " + dest->nick + " on " + parameters[0]); + // Target is on this server, kick them and send the snotice + channel->KickUser(ServerInstance->FakeClient, dest, reason); + 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; } + + RouteDescriptor GetRouting(User* user, const Params& parameters) CXX11_OVERRIDE + { + return ROUTE_OPT_UCAST(parameters[1]); + } }; class ModuleSakick : public Module { - CommandSakick* mycommand; + CommandSakick cmd; public: - ModuleSakick(InspIRCd* Me) - : Module(Me) - { - - mycommand = new CommandSakick(ServerInstance); - ServerInstance->AddCommand(mycommand); - - } - - virtual ~ModuleSakick() + ModuleSakick() + : cmd(this) { } - virtual Version GetVersion() + Version GetVersion() CXX11_OVERRIDE { - return Version("$Id$", VF_COMMON|VF_VENDOR, API_VERSION); + 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); } - }; MODULE_INIT(ModuleSakick) -