]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_sakick.cpp
Fix STATUSMSG tag messages not including the status in the target.
[user/henk/code/inspircd.git] / src / modules / m_sakick.cpp
1 /*
2  * InspIRCd -- Internet Relay Chat Daemon
3  *
4  *   Copyright (C) 2013, 2018 Sadie Powell <sadie@witchery.services>
5  *   Copyright (C) 2012-2014, 2016 Attila Molnar <attilamolnar@hush.com>
6  *   Copyright (C) 2012, 2019 Robby <robby@chatbelgie.be>
7  *   Copyright (C) 2010 Craig Edwards <brain@inspircd.org>
8  *   Copyright (C) 2009 John Brooks <special@inspircd.org>
9  *   Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
10  *
11  * This file is part of InspIRCd.  InspIRCd is free software: you can
12  * redistribute it and/or modify it under the terms of the GNU General Public
13  * License as published by the Free Software Foundation, version 2.
14  *
15  * This program is distributed in the hope that it will be useful, but WITHOUT
16  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
22  */
23
24
25 #include "inspircd.h"
26
27 /** Handle /SAKICK
28  */
29 class CommandSakick : public Command
30 {
31  public:
32         CommandSakick(Module* Creator) : Command(Creator,"SAKICK", 2, 3)
33         {
34                 flags_needed = 'o'; syntax = "<channel> <nick> [:<reason>]";
35                 TRANSLATE3(TR_TEXT, TR_NICK, TR_TEXT);
36         }
37
38         CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE
39         {
40                 User* dest = ServerInstance->FindNick(parameters[1]);
41                 Channel* channel = ServerInstance->FindChan(parameters[0]);
42
43                 if ((dest) && (dest->registered == REG_ALL) && (channel))
44                 {
45                         const std::string& reason = (parameters.size() > 2) ? parameters[2] : dest->nick;
46
47                         if (dest->server->IsULine())
48                         {
49                                 user->WriteNumeric(ERR_NOPRIVILEGES, "Cannot use an SA command on a U-lined client");
50                                 return CMD_FAILURE;
51                         }
52
53                         if (!channel->HasUser(dest))
54                         {
55                                 user->WriteNotice("*** " + dest->nick + " is not on " + channel->name);
56                                 return CMD_FAILURE;
57                         }
58
59                         /* For local clients, directly kick them. For remote clients,
60                          * just return CMD_SUCCESS knowing the protocol module will route the SAKICK to the user's
61                          * local server and that will kick them instead.
62                          */
63                         if (IS_LOCAL(dest))
64                         {
65                                 // Target is on this server, kick them and send the snotice
66                                 channel->KickUser(ServerInstance->FakeClient, dest, reason);
67                                 ServerInstance->SNO->WriteGlobalSno('a', user->nick + " SAKICKed " + dest->nick + " on " + channel->name);
68                         }
69
70                         return CMD_SUCCESS;
71                 }
72                 else
73                 {
74                         user->WriteNotice("*** Invalid nickname or channel");
75                 }
76
77                 return CMD_FAILURE;
78         }
79
80         RouteDescriptor GetRouting(User* user, const Params& parameters) CXX11_OVERRIDE
81         {
82                 return ROUTE_OPT_UCAST(parameters[1]);
83         }
84 };
85
86 class ModuleSakick : public Module
87 {
88         CommandSakick cmd;
89  public:
90         ModuleSakick()
91                 : cmd(this)
92         {
93         }
94
95         Version GetVersion() CXX11_OVERRIDE
96         {
97                 return Version("Provides the SAKICK command", VF_OPTCOMMON|VF_VENDOR);
98         }
99 };
100
101 MODULE_INIT(ModuleSakick)