]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_globops.cpp
Added remote rehash (even to a mask)
[user/henk/code/inspircd.git] / src / modules / m_globops.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  Inspire is copyright (C) 2002-2004 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 void handle_globops(char **parameters, int pcnt, userrec *user)
32 {
33         std::string line = "*** GLOBOPS - From " + std::string(user->nick) + ": ";
34         for (int i = 0; i < pcnt; i++)
35         {
36                 line = line + std::string(parameters[i]) + " ";
37         }
38         Srv->SendToModeMask("og",WM_AND,line);
39 }
40
41
42 class ModuleGlobops : public Module
43 {
44  public:
45         ModuleGlobops()
46         {
47                 Srv = new Server;
48                 
49                 if (!Srv->AddExtendedMode('g',MT_CLIENT,true,0,0))
50                 {
51                         Srv->Log(DEFAULT,"*** m_globops: ERROR, failed to allocate user mode +g!");
52                         printf("Could not claim usermode +g for this module!");
53                         return;
54                 }
55                 else Srv->AddCommand("GLOBOPS",handle_globops,'o',1,"m_globops.so");
56         }
57         
58         virtual ~ModuleGlobops()
59         {
60                 delete Srv;
61         }
62         
63         virtual Version GetVersion()
64         {
65                 return Version(1,0,0,1,VF_STATIC|VF_VENDOR);
66         }
67         
68         virtual int OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list &params)
69         {
70                 // check if this is our mode character...
71                 if ((modechar == 'g') && (type == MT_CLIENT))
72                 {
73                         // we dont actually do anything with the mode in this module -
74                         // just tell the core its been claimed and is ok to give users.                         
75                         return 1;
76                 }
77                 else
78                 {
79                         // this mode isn't ours, we have to bail and return 0 to not handle it.
80                         return 0;
81                 }
82         }
83 };
84
85 // stuff down here is the module-factory stuff. For basic modules you can ignore this.
86
87 class ModuleGlobopsFactory : public ModuleFactory
88 {
89  public:
90         ModuleGlobopsFactory()
91         {
92         }
93         
94         ~ModuleGlobopsFactory()
95         {
96         }
97         
98         virtual Module * CreateModule()
99         {
100                 return new ModuleGlobops;
101         }
102         
103 };
104
105
106 extern "C" void * init_module( void )
107 {
108         return new ModuleGlobopsFactory;
109 }
110