]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_saquit.cpp
None of the modules use an extern InspIRCd* any more
[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
39
40
41 class cmd_saquit : public command_t
42 {
43  public:
44  cmd_saquit (InspIRCd* Instance) : command_t(Instance,"SAQUIT",'o',2)
45         {
46                 this->source = "m_saquit.so";
47                 syntax = "<nick> <reason>";
48         }
49
50         void Handle (const char** parameters, int pcnt, userrec *user)
51         {
52                 userrec* dest = ServerInstance->FindNick(parameters[0]);
53                 if (dest)
54                 {
55                         if (ServerInstance->IsUlined(dest->server))
56                         {
57                                 user->WriteServ("990 %s :Cannot use an SA command on a u-lined client",user->nick);
58                                 return;
59                         }
60                         std::string line = "";
61                         for (int i = 1; i < pcnt - 1; i++)
62                         {
63                                 line = line + std::string(parameters[i]) + " ";
64                         }
65                         line = line + std::string(parameters[pcnt-1]);
66                 
67                         ServerInstance->WriteOpers(std::string(user->nick)+" used SAQUIT to make "+std::string(dest->nick)+" quit with a reason of "+line);
68                         userrec::QuitUser(ServerInstance, dest, line);
69                 }
70         }
71 };
72
73 class ModuleSaquit : public Module
74 {
75         cmd_saquit*     mycommand;
76  public:
77         ModuleSaquit(InspIRCd* Me)
78                 : Module::Module(Me)
79         {
80                 
81                 mycommand = new cmd_saquit(ServerInstance);
82                 ServerInstance->AddCommand(mycommand);
83         }
84         
85         virtual ~ModuleSaquit()
86         {
87         }
88         
89         virtual Version GetVersion()
90         {
91                 return Version(1,0,0,1,VF_VENDOR);
92         }
93         
94 };
95
96 // stuff down here is the module-factory stuff. For basic modules you can ignore this.
97
98 class ModuleSaquitFactory : public ModuleFactory
99 {
100  public:
101         ModuleSaquitFactory()
102         {
103         }
104         
105         ~ModuleSaquitFactory()
106         {
107         }
108         
109         virtual Module * CreateModule(InspIRCd* Me)
110         {
111                 return new ModuleSaquit(Me);
112         }
113         
114 };
115
116
117 extern "C" void * init_module( void )
118 {
119         return new ModuleSaquitFactory;
120 }
121