]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_botmode.cpp
Added query about printf() use
[user/henk/code/inspircd.git] / src / modules / m_botmode.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 #include <stdio.h>
20 #include <string>
21 #include "users.h"
22 #include "channels.h"
23 #include "modules.h"
24
25 /* $ModDesc: Provides support for unreal-style umode +B */
26
27 class ModuleBotMode : public Module
28 {
29         Server *Srv; 
30  public:
31         ModuleBotMode(Server* Me)
32                 : Module::Module(Me)
33         {
34                 Srv = Me;
35                 
36                 if (!Srv->AddExtendedMode('B',MT_CLIENT,false,0,0))
37                 {
38                         Srv->Log(DEFAULT,"*** m_botmode: ERROR, failed to allocate user mode +B!");
39                         printf("Could not claim usermode +B for this module!"); /* XXX - do we have a debug function? */
40                         return;
41                 }
42         }
43         
44         virtual ~ModuleBotMode()
45         {
46         }
47         
48         virtual Version GetVersion()
49         {
50                 return Version(1,0,0,0,VF_STATIC|VF_VENDOR);
51         }
52         
53         virtual int OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list &params)
54         {
55                 if ((modechar == 'B') && (type == MT_CLIENT))
56                 {
57                         return 1;
58                 }
59                 else
60                 {
61                         return 0;
62                 }
63         }
64
65         virtual void OnWhois(userrec* src, userrec* dst)
66         {
67                 if (strchr(dst->modes,'B'))
68                 {
69                         Srv->SendTo(NULL,src,"335 "+std::string(src->nick)+" "+std::string(dst->nick)+" :is a \2bot\2 on "+Srv->GetNetworkName());
70                 }
71         }
72
73 };
74
75 // stuff down here is the module-factory stuff. For basic modules you can ignore this.
76
77 class ModuleBotModeFactory : public ModuleFactory
78 {
79  public:
80         ModuleBotModeFactory()
81         {
82         }
83         
84         ~ModuleBotModeFactory()
85         {
86         }
87         
88         virtual Module * CreateModule(Server* Me)
89         {
90                 return new ModuleBotMode(Me);
91         }
92         
93 };
94
95
96 extern "C" void * init_module( void )
97 {
98         return new ModuleBotModeFactory;
99 }
100