]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_botmode.cpp
Updated copyrights in headers etc using perl inplace edit
[user/henk/code/inspircd.git] / src / modules / m_botmode.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 #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                         return;
40                 }
41         }
42
43         void Implements(char* List)
44         {
45                 List[I_OnWhois] = List[I_OnExtendedMode] = 1;
46         }
47         
48         virtual ~ModuleBotMode()
49         {
50         }
51         
52         virtual Version GetVersion()
53         {
54                 return Version(1,0,0,0,VF_STATIC|VF_VENDOR);
55         }
56         
57         virtual int OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list &params)
58         {
59                 if ((modechar == 'B') && (type == MT_CLIENT))
60                 {
61                         return 1;
62                 }
63                 else
64                 {
65                         return 0;
66                 }
67         }
68
69         virtual void OnWhois(userrec* src, userrec* dst)
70         {
71                 if (strchr(dst->modes,'B'))
72                 {
73                         Srv->SendTo(NULL,src,"335 "+std::string(src->nick)+" "+std::string(dst->nick)+" :is a \2bot\2 on "+Srv->GetNetworkName());
74                 }
75         }
76
77 };
78
79 // stuff down here is the module-factory stuff. For basic modules you can ignore this.
80
81 class ModuleBotModeFactory : public ModuleFactory
82 {
83  public:
84         ModuleBotModeFactory()
85         {
86         }
87         
88         ~ModuleBotModeFactory()
89         {
90         }
91         
92         virtual Module * CreateModule(Server* Me)
93         {
94                 return new ModuleBotMode(Me);
95         }
96         
97 };
98
99
100 extern "C" void * init_module( void )
101 {
102         return new ModuleBotModeFactory;
103 }
104