]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_saquit.cpp
ef7c543582df2b7efe3adb4ca4313b492df0b23a
[user/henk/code/inspircd.git] / src / modules / m_saquit.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
6  *                     E-mail:
7  *              <brain@chatspike.net>
8  *                <Craig@chatspike.net>
9  *     
10  * Written by Craig Edwards, Craig McLure, and others.
11  * This program is free but copyrighted software; see
12  *          the file COPYING for details.
13  *
14  * ---------------------------------------------------
15  */
16
17 using namespace std;
18
19 /*
20  * SAQUIT module for InspIRCd
21  *  Author: w00t
22  *  Version: 1.0.0.0
23  *
24  *  Syntax: /SAQUIT <user> [reason]
25  *  Makes it appear as though <user> has /quit with [reason]
26  *  
27  */
28
29 #include <stdio.h>
30 #include <string>
31 #include "users.h"
32 #include "channels.h"
33 #include "modules.h"
34 #include "inspircd.h"
35
36 /* $ModDesc: Provides support for an SAQUIT command, exits user with a reason */
37
38 /** Handle /SAQUIT
39  */
40 class cmd_saquit : public command_t
41 {
42  public:
43  cmd_saquit (InspIRCd* Instance) : command_t(Instance,"SAQUIT",'o',2)
44         {
45                 this->source = "m_saquit.so";
46                 syntax = "<nick> <reason>";
47         }
48
49         CmdResult Handle (const char** parameters, int pcnt, userrec *user)
50         {
51                 userrec* dest = ServerInstance->FindNick(parameters[0]);
52                 if (dest)
53                 {
54                         if (ServerInstance->ULine(dest->server))
55                         {
56                                 user->WriteServ("990 %s :Cannot use an SA command on a u-lined client",user->nick);
57                                 return CMD_FAILURE;
58                         }
59                         irc::stringjoiner reason_join(" ", parameters, 1, pcnt - 1);
60                         std::string line = reason_join.GetJoined();
61
62                         ServerInstance->WriteOpers(std::string(user->nick)+" used SAQUIT to make "+std::string(dest->nick)+" quit with a reason of "+line);
63                         userrec::QuitUser(ServerInstance, dest, line);
64
65                         return CMD_SUCCESS;
66                 }
67                 else
68                 {
69                         user->WriteServ("NOTICE %s :*** Invalid nickname '%s'", user->nick, parameters[0]);
70                 }
71
72                 return CMD_FAILURE;
73         }
74 };
75
76 class ModuleSaquit : public Module
77 {
78         cmd_saquit*     mycommand;
79  public:
80         ModuleSaquit(InspIRCd* Me)
81                 : Module::Module(Me)
82         {
83                 
84                 mycommand = new cmd_saquit(ServerInstance);
85                 ServerInstance->AddCommand(mycommand);
86         }
87         
88         virtual ~ModuleSaquit()
89         {
90         }
91         
92         virtual Version GetVersion()
93         {
94                 return Version(1,1,0,1,VF_VENDOR,API_VERSION);
95         }
96         
97 };
98
99 // stuff down here is the module-factory stuff. For basic modules you can ignore this.
100
101 class ModuleSaquitFactory : public ModuleFactory
102 {
103  public:
104         ModuleSaquitFactory()
105         {
106         }
107         
108         ~ModuleSaquitFactory()
109         {
110         }
111         
112         virtual Module * CreateModule(InspIRCd* Me)
113         {
114                 return new ModuleSaquit(Me);
115         }
116         
117 };
118
119
120 extern "C" void * init_module( void )
121 {
122         return new ModuleSaquitFactory;
123 }
124