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