]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_globalload.cpp
a1fb4308663be233246ed62e2b667fe5b0f7fbfb
[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
31 Server *Srv;
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_gloadmodule () : 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  public:
83         ModuleGlobalLoad(Server* Me) : Module::Module(Me)
84         {
85                 Srv = Me;
86                 mycommand = new cmd_gloadmodule();
87                 mycommand2 = new cmd_gunloadmodule();
88                 Srv->AddCommand(mycommand);
89                 Srv->AddCommand(mycommand2);
90         }
91         
92         virtual ~ModuleGlobalLoad()
93         {
94         }
95         
96         virtual Version GetVersion()
97         {
98                 return Version(1, 0, 0, 0, VF_VENDOR);
99         }
100 };
101
102
103 class ModuleGlobalLoadFactory : public ModuleFactory
104 {
105  public:
106         ModuleGlobalLoadFactory()
107         {
108         }
109         
110         ~ModuleGlobalLoadFactory()
111         {
112         }
113         
114         virtual Module * CreateModule(Server* Me)
115         {
116                 return new ModuleGlobalLoad(Me);
117         }
118         
119 };
120
121
122 extern "C" void * init_module( void )
123 {
124         return new ModuleGlobalLoadFactory;
125 }