]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_globops.cpp
3d6e2d12e4c61ada817d1b62f0011be092cf2b60
[user/henk/code/inspircd.git] / src / modules / m_globops.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 // Globops and +g support module by C.J.Edwards
20
21 #include <stdio.h>
22 #include <string>
23 #include "users.h"
24 #include "channels.h"
25 #include "modules.h"
26
27 /* $ModDesc: Provides support for unreal-style GLOBOPS and umode +g */
28
29 Server *Srv;
30
31 class cmd_globops : public command_t
32 {
33  public:
34         cmd_globops () : command_t("GLOBOPS",'o',1)
35         {
36                 this->source = "m_globops.so";
37         }
38         
39         void Handle (char **parameters, int pcnt, userrec *user)
40         {
41                 std::string line = "*** GLOBOPS - From " + std::string(user->nick) + ": ";
42                 for (int i = 0; i < pcnt; i++)
43                 {
44                         line = line + std::string(parameters[i]) + " ";
45                 }
46                 Srv->SendToModeMask("og",WM_AND,line);
47         }
48 };
49
50
51 class ModuleGlobops : public Module
52 {
53         cmd_globops* mycommand;
54  public:
55         ModuleGlobops(Server* Me)
56                 : Module::Module(Me)
57         {
58                 Srv = Me;
59                 
60                 if (!Srv->AddExtendedMode('g',MT_CLIENT,true,0,0))
61                 {
62                         Srv->Log(DEFAULT,"*** m_globops: ERROR, failed to allocate user mode +g!");
63                         printf("Could not claim usermode +g for this module!");
64                         return;
65                 }
66                 else
67                 {
68                         mycommand = new cmd_globops();
69                         Srv->AddCommand(mycommand);
70                 }
71         }
72         
73         virtual ~ModuleGlobops()
74         {
75         }
76         
77         virtual Version GetVersion()
78         {
79                 return Version(1,0,0,1,VF_STATIC|VF_VENDOR);
80         }
81
82         void Implements(char* List)
83         {
84                 List[I_OnExtendedMode] = 1;
85         }
86         
87         virtual int OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list &params)
88         {
89                 // check if this is our mode character...
90                 if ((modechar == 'g') && (type == MT_CLIENT))
91                 {
92                         // we dont actually do anything with the mode in this module -
93                         // just tell the core its been claimed and is ok to give users.                         
94                         return 1;
95                 }
96                 else
97                 {
98                         // this mode isn't ours, we have to bail and return 0 to not handle it.
99                         return 0;
100                 }
101         }
102 };
103
104 // stuff down here is the module-factory stuff. For basic modules you can ignore this.
105
106 class ModuleGlobopsFactory : public ModuleFactory
107 {
108  public:
109         ModuleGlobopsFactory()
110         {
111         }
112         
113         ~ModuleGlobopsFactory()
114         {
115         }
116         
117         virtual Module * CreateModule(Server* Me)
118         {
119                 return new ModuleGlobops(Me);
120         }
121         
122 };
123
124
125 extern "C" void * init_module( void )
126 {
127         return new ModuleGlobopsFactory;
128 }
129