]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_saquit.cpp
e1db742e0577a5a5fb56b8c5cf5ce099d781d560
[user/henk/code/inspircd.git] / src / modules / m_saquit.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  Inspire is copyright (C) 2002-2004 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
35 /* $ModDesc: Provides support for an SAQUIT command, exits user with a reason */
36
37 Server *Srv;
38
39 class cmd_saquit : public command_t
40 {
41  public:
42         cmd_saquit () : command_t("SAQUIT",'o',2)
43         {
44                 this->source = "m_saquit.so";
45         }
46
47         void Handle (char **parameters, int pcnt, userrec *user)
48         {
49                 userrec* dest = Srv->FindNick(std::string(parameters[0]));
50                 if (dest)
51                 {
52                         std::string line = "";
53                         for (int i = 1; i < pcnt - 1; i++)
54                         {
55                                 line = line + std::string(parameters[i]) + " ";
56                         }
57                         line = line + std::string(parameters[pcnt-1]);
58                 
59                         Srv->SendOpers(std::string(user->nick)+" used SAQUIT to make "+std::string(dest->nick)+" quit with a reason of "+line);
60                         Srv->QuitUser(dest, line);
61                 }
62         }
63 };
64
65 class ModuleSaquit : public Module
66 {
67         cmd_saquit*     mycommand;
68  public:
69         ModuleSaquit(Server* Me)
70                 : Module::Module(Me)
71         {
72                 Srv = Me;
73                 mycommand = new cmd_saquit();
74                 Srv->AddCommand(mycommand);
75         }
76         
77         virtual ~ModuleSaquit()
78         {
79         }
80         
81         virtual Version GetVersion()
82         {
83                 return Version(1,0,0,1,VF_VENDOR);
84         }
85         
86 };
87
88 // stuff down here is the module-factory stuff. For basic modules you can ignore this.
89
90 class ModuleSaquitFactory : public ModuleFactory
91 {
92  public:
93         ModuleSaquitFactory()
94         {
95         }
96         
97         ~ModuleSaquitFactory()
98         {
99         }
100         
101         virtual Module * CreateModule(Server* Me)
102         {
103                 return new ModuleSaquit(Me);
104         }
105         
106 };
107
108
109 extern "C" void * init_module( void )
110 {
111         return new ModuleSaquitFactory;
112 }
113