]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_saquit.cpp
0c6ca949d7ca7cdd873faa5f9d65875db1a72809
[user/henk/code/inspircd.git] / src / modules / m_saquit.cpp
1 /*
2  * SAQUIT module for InspIRCd
3  *  Author: w00t
4  *  Version: 1.0.0.0
5  *
6  *  Syntax: /SAQUIT <user> [reason]
7  *  Makes it appear as though <user> has /quit with [reason]
8  *  
9  */
10
11 #include <stdio.h>
12 #include <string>
13 #include "users.h"
14 #include "channels.h"
15 #include "modules.h"
16
17 /* $ModDesc: Provides support for an SAQUIT command, exits user with a reason */
18
19 Server *Srv;
20          
21 void handle_saquit(char **parameters, int pcnt, userrec *user)
22 {
23         userrec* dest = Srv->FindNick(std::string(parameters[0]));
24         if (dest)
25         {
26                 std::string line = "";
27                 for (int i = 1; i < pcnt - 1; i++)
28                 {
29                         line = line + std::string(parameters[i]) + " ";
30                 }
31                 line = line + std::string(parameters[pcnt-1]);
32         
33                 Srv->SendOpers(std::string(user->nick)+" used SAQUIT to make "+std::string(dest->nick)+" quit with a reason of "+line);
34                 Srv->QuitUser(dest, line);
35         }
36 }
37
38
39 class ModuleSaquit : public Module
40 {
41  public:
42         ModuleSaquit()
43         {
44                 Srv = new Server;
45                 Srv->AddCommand("SAQUIT",handle_saquit,'o',2);
46         }
47         
48         virtual ~ModuleSaquit()
49         {
50                 delete Srv;
51         }
52         
53         virtual Version GetVersion()
54         {
55                 return Version(1,0,0,0);
56         }
57         
58 };
59
60 // stuff down here is the module-factory stuff. For basic modules you can ignore this.
61
62 class ModuleSaquitFactory : public ModuleFactory
63 {
64  public:
65         ModuleSaquitFactory()
66         {
67         }
68         
69         ~ModuleSaquitFactory()
70         {
71         }
72         
73         virtual Module * CreateModule()
74         {
75                 return new ModuleSaquit;
76         }
77         
78 };
79
80
81 extern "C" void * init_module( void )
82 {
83         return new ModuleSaquitFactory;
84 }
85