]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_globalload.cpp
Moved timer stuff from OnBackgroundTimer to InspTimer derivative
[user/henk/code/inspircd.git] / src / modules / m_globalload.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  * DEVOICE module for InspIRCd
21  *  Syntax: /DEVOICE <#chan>
22  */
23
24 /* $ModDesc: Provides voiced users with the ability to devoice themselves. */
25
26 #include <stdio.h>
27 #include "users.h"
28 #include "channels.h"
29 #include "modules.h"
30 #include "inspircd.h"
31
32 Server *Srv;
33 extern InspIRCd *ServerInstance;
34          
35 class cmd_gloadmodule : public command_t
36 {
37  public:
38         cmd_gloadmodule () : command_t("GLOADMODULE", 'o', 1)
39         {
40                 this->source = "m_globalload.so";
41         }
42
43         void Handle (char **parameters, int pcnt, userrec *user)
44         {
45                 if (ServerInstance->LoadModule(parameters[0]))
46                 {
47                         WriteOpers("*** NEW MODULE '%s' GLOBALLY LOADED BY '%s'",parameters[0],user->nick);
48                         WriteServ(user->fd,"975 %s %s :Module successfully loaded.",user->nick, parameters[0]);
49                 }
50                 else
51                 {
52                         WriteServ(user->fd,"974 %s %s :Failed to load module: %s",user->nick, parameters[0],ServerInstance->ModuleError());
53                 }
54         }
55 };
56
57 class cmd_gunloadmodule : public command_t
58 {
59  public:
60         cmd_gunloadmodule () : command_t("GUNLOADMODULE", 'o', 1)
61         {
62                 this->source = "m_globalload.so";
63         }
64
65         void Handle (char **parameters, int pcnt, userrec *user)
66         {
67                 if (ServerInstance->UnloadModule(parameters[0]))
68                 {
69                         WriteOpers("*** MODULE '%s' GLOBALLY UNLOADED BY '%s'",parameters[0],user->nick);
70                         WriteServ(user->fd,"973 %s %s :Module successfully unloaded.",user->nick, parameters[0]);
71                 }
72                 else
73                 {
74                         WriteServ(user->fd,"972 %s %s :Failed to unload module: %s",user->nick, parameters[0],ServerInstance->ModuleError());
75                 }
76         }
77 };
78
79 class ModuleGlobalLoad : public Module
80 {
81         cmd_gloadmodule *mycommand;
82         cmd_gunloadmodule *mycommand2;
83  public:
84         ModuleGlobalLoad(Server* Me) : Module::Module(Me)
85         {
86                 Srv = Me;
87                 mycommand = new cmd_gloadmodule();
88                 mycommand2 = new cmd_gunloadmodule();
89                 Srv->AddCommand(mycommand);
90                 Srv->AddCommand(mycommand2);
91         }
92         
93         virtual ~ModuleGlobalLoad()
94         {
95         }
96         
97         virtual Version GetVersion()
98         {
99                 return Version(1, 0, 0, 0, VF_VENDOR);
100         }
101 };
102
103
104 class ModuleGlobalLoadFactory : public ModuleFactory
105 {
106  public:
107         ModuleGlobalLoadFactory()
108         {
109         }
110         
111         ~ModuleGlobalLoadFactory()
112         {
113         }
114         
115         virtual Module * CreateModule(Server* Me)
116         {
117                 return new ModuleGlobalLoad(Me);
118         }
119         
120 };
121
122
123 extern "C" void * init_module( void )
124 {
125         return new ModuleGlobalLoadFactory;
126 }