]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_globalload.cpp
18258e3baca6dfecdb767e8638cfb48fede31e08
[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 extern InspIRCd *ServerInstance;
33          
34 class cmd_gloadmodule : public command_t
35 {
36  public:
37         cmd_gloadmodule () : command_t("GLOADMODULE", 'o', 1)
38         {
39                 this->source = "m_globalload.so";
40         }
41
42         void Handle (char **parameters, int pcnt, userrec *user)
43         {
44                 if (ServerInstance->LoadModule(parameters[0]))
45                 {
46                         WriteOpers("*** NEW MODULE '%s' GLOBALLY LOADED BY '%s'",parameters[0],user->nick);
47                         WriteServ(user->fd,"975 %s %s :Module successfully loaded.",user->nick, parameters[0]);
48                 }
49                 else
50                 {
51                         WriteServ(user->fd,"974 %s %s :Failed to load module: %s",user->nick, parameters[0],ServerInstance->ModuleError());
52                 }
53         }
54 };
55
56 class cmd_gunloadmodule : public command_t
57 {
58  public:
59         cmd_gunloadmodule () : command_t("GUNLOADMODULE", 'o', 1)
60         {
61                 this->source = "m_globalload.so";
62         }
63
64         void Handle (char **parameters, int pcnt, userrec *user)
65         {
66                 if (ServerInstance->UnloadModule(parameters[0]))
67                 {
68                         WriteOpers("*** MODULE '%s' GLOBALLY UNLOADED BY '%s'",parameters[0],user->nick);
69                         WriteServ(user->fd,"973 %s %s :Module successfully unloaded.",user->nick, parameters[0]);
70                 }
71                 else
72                 {
73                         WriteServ(user->fd,"972 %s %s :Failed to unload module: %s",user->nick, parameters[0],ServerInstance->ModuleError());
74                 }
75         }
76 };
77
78 class ModuleGlobalLoad : public Module
79 {
80         cmd_gloadmodule *mycommand;
81         cmd_gunloadmodule *mycommand2;
82         Server *Srv;
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 }