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