]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_saquit.cpp
Added remote rehash (even to a mask)
[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 void handle_saquit(char **parameters, int pcnt, userrec *user)
40 {
41         userrec* dest = Srv->FindNick(std::string(parameters[0]));
42         if (dest)
43         {
44                 std::string line = "";
45                 for (int i = 1; i < pcnt - 1; i++)
46                 {
47                         line = line + std::string(parameters[i]) + " ";
48                 }
49                 line = line + std::string(parameters[pcnt-1]);
50         
51                 Srv->SendOpers(std::string(user->nick)+" used SAQUIT to make "+std::string(dest->nick)+" quit with a reason of "+line);
52                 Srv->QuitUser(dest, line);
53         }
54 }
55
56
57 class ModuleSaquit : public Module
58 {
59  public:
60         ModuleSaquit()
61         {
62                 Srv = new Server;
63                 Srv->AddCommand("SAQUIT",handle_saquit,'o',2,"m_saquit.so");
64         }
65         
66         virtual ~ModuleSaquit()
67         {
68                 delete Srv;
69         }
70         
71         virtual Version GetVersion()
72         {
73                 return Version(1,0,0,1,VF_VENDOR);
74         }
75         
76 };
77
78 // stuff down here is the module-factory stuff. For basic modules you can ignore this.
79
80 class ModuleSaquitFactory : public ModuleFactory
81 {
82  public:
83         ModuleSaquitFactory()
84         {
85         }
86         
87         ~ModuleSaquitFactory()
88         {
89         }
90         
91         virtual Module * CreateModule()
92         {
93                 return new ModuleSaquit;
94         }
95         
96 };
97
98
99 extern "C" void * init_module( void )
100 {
101         return new ModuleSaquitFactory;
102 }
103