]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_saquit.cpp
fixed some indentation and spacing in modules
[user/henk/code/inspircd.git] / src / modules / m_saquit.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2008 InspIRCd Development Team
6  * See: http://www.inspircd.org/wiki/index.php/Credits
7  *
8  * This program is free but copyrighted software; see
9  *            the file COPYING for details.
10  *
11  * ---------------------------------------------------
12  */
13
14 #include "inspircd.h"
15
16 /* $ModDesc: Provides support for an SAQUIT command, exits user with a reason */
17
18 /** Handle /SAQUIT
19  */
20 class CommandSaquit : public Command
21 {
22  public:
23         CommandSaquit (InspIRCd* Instance) : Command(Instance, "SAQUIT", "o", 2, false, 0)
24         {
25                 this->source = "m_saquit.so";
26                 syntax = "<nick> <reason>";
27                 TRANSLATE3(TR_NICK, TR_TEXT, TR_END);
28         }
29
30         CmdResult Handle (const std::vector<std::string>& parameters, User *user)
31         {
32                 User* dest = ServerInstance->FindNick(parameters[0]);
33                 if (dest)
34                 {
35                         if (ServerInstance->ULine(dest->server))
36                         {
37                                 user->WriteNumeric(990, "%s :Cannot use an SA command on a u-lined client",user->nick.c_str());
38                                 return CMD_FAILURE;
39                         }
40
41                         ServerInstance->SNO->WriteToSnoMask('A', std::string(user->nick)+" used SAQUIT to make "+std::string(dest->nick)+" quit with a reason of "+parameters[1]);
42
43                         // Pass the command on, so the client's server can quit it properly.
44                         if (!IS_LOCAL(dest))
45                                 return CMD_SUCCESS;
46
47                         ServerInstance->Users->QuitUser(dest, parameters[1]);
48                         return CMD_LOCALONLY;
49                 }
50                 else
51                 {
52                         user->WriteServ("NOTICE %s :*** Invalid nickname '%s'", user->nick.c_str(), parameters[0].c_str());
53                 }
54
55                 return CMD_FAILURE;
56         }
57 };
58
59 class ModuleSaquit : public Module
60 {
61         CommandSaquit*  mycommand;
62  public:
63         ModuleSaquit(InspIRCd* Me)
64                 : Module(Me)
65         {
66
67                 mycommand = new CommandSaquit(ServerInstance);
68                 ServerInstance->AddCommand(mycommand);
69
70         }
71
72         virtual ~ModuleSaquit()
73         {
74         }
75
76         virtual Version GetVersion()
77         {
78                 return Version(1, 2, 0, 0, VF_COMMON | VF_VENDOR, API_VERSION);
79         }
80
81 };
82
83 MODULE_INIT(ModuleSaquit)