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