]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_saquit.cpp
Merge insp20
[user/henk/code/inspircd.git] / src / modules / m_saquit.cpp
1 /*
2  * InspIRCd -- Internet Relay Chat Daemon
3  *
4  *   Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
5  *   Copyright (C) 2006-2007 Robin Burchell <robin+git@viroteck.net>
6  *   Copyright (C) 2004-2005 Craig Edwards <craigedwards@brainbox.cc>
7  *
8  * This file is part of InspIRCd.  InspIRCd is free software: you can
9  * redistribute it and/or modify it under the terms of the GNU General Public
10  * License as published by the Free Software Foundation, version 2.
11  *
12  * This program is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
15  * details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
19  */
20
21
22 #include "inspircd.h"
23
24 /** Handle /SAQUIT
25  */
26 class CommandSaquit : public Command
27 {
28  public:
29         CommandSaquit(Module* Creator) : Command(Creator, "SAQUIT", 2, 2)
30         {
31                 flags_needed = 'o'; Penalty = 0; syntax = "<nick> <reason>";
32                 TRANSLATE2(TR_NICK, TR_TEXT);
33         }
34
35         CmdResult Handle (const std::vector<std::string>& parameters, User *user)
36         {
37                 User* dest = ServerInstance->FindNick(parameters[0]);
38                 if ((dest) && (!IS_SERVER(dest)) && (dest->registered == REG_ALL))
39                 {
40                         if (dest->server->IsULine())
41                         {
42                                 user->WriteNumeric(ERR_NOPRIVILEGES, ":Cannot use an SA command on a u-lined client");
43                                 return CMD_FAILURE;
44                         }
45
46                         // Pass the command on, so the client's server can quit it properly.
47                         if (!IS_LOCAL(dest))
48                                 return CMD_SUCCESS;
49
50                         ServerInstance->SNO->WriteGlobalSno('a', user->nick+" used SAQUIT to make "+dest->nick+" quit with a reason of "+parameters[1]);
51
52                         ServerInstance->Users->QuitUser(dest, parameters[1]);
53                         return CMD_SUCCESS;
54                 }
55                 else
56                 {
57                         user->WriteNotice("*** Invalid nickname '" + parameters[0] + "'");
58                         return CMD_FAILURE;
59                 }
60         }
61
62         RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters)
63         {
64                 User* dest = ServerInstance->FindNick(parameters[0]);
65                 if (dest)
66                         return ROUTE_OPT_UCAST(dest->server);
67                 return ROUTE_LOCALONLY;
68         }
69 };
70
71 class ModuleSaquit : public Module
72 {
73         CommandSaquit cmd;
74  public:
75         ModuleSaquit()
76                 : cmd(this)
77         {
78         }
79
80         Version GetVersion() CXX11_OVERRIDE
81         {
82                 return Version("Provides support for an SAQUIT command, exits user with a reason", VF_OPTCOMMON | VF_VENDOR);
83         }
84 };
85
86 MODULE_INIT(ModuleSaquit)