]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_botmode.cpp
Fix all typos (not as fun as 'kill all humans' but meh, beggers cant be choosers)
[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 BotMode : public ModeHandler
28 {
29  public:
30         BotMode() : ModeHandler('B', 0, 0, false, MODETYPE_USER, false) { }
31
32         ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding)
33         {
34                 if (adding)
35                 {
36                         if (!dest->IsModeSet('B'))
37                         {
38                                 dest->SetMode('B',true);
39                                 return MODEACTION_ALLOW;
40                         }
41                 }
42                 else
43                 {
44                         if (dest->IsModeSet('B'))
45                         {
46                                 dest->SetMode('B',false);
47                                 return MODEACTION_ALLOW;
48                         }
49                 }
50         }
51 };
52
53 class ModuleBotMode : public Module
54 {
55         Server *Srv;
56         BotMode* bm;
57  public:
58         ModuleBotMode(Server* Me)
59                 : Module::Module(Me)
60         {
61                 Srv = Me;
62                 bm = new BotMode();
63                 Srv->AddMode(bm, 'B');
64         }
65
66         void Implements(char* List)
67         {
68                 List[I_OnWhois] = 1;
69         }
70         
71         virtual ~ModuleBotMode()
72         {
73         }
74         
75         virtual Version GetVersion()
76         {
77                 return Version(1,0,0,0,VF_STATIC|VF_VENDOR);
78         }
79
80         virtual void OnWhois(userrec* src, userrec* dst)
81         {
82                 if (dst->IsModeSet('B'))
83                 {
84                         Srv->SendTo(NULL,src,"335 "+std::string(src->nick)+" "+std::string(dst->nick)+" :is a \2bot\2 on "+Srv->GetNetworkName());
85                 }
86         }
87
88 };
89
90 // stuff down here is the module-factory stuff. For basic modules you can ignore this.
91
92 class ModuleBotModeFactory : public ModuleFactory
93 {
94  public:
95         ModuleBotModeFactory()
96         {
97         }
98         
99         ~ModuleBotModeFactory()
100         {
101         }
102         
103         virtual Module * CreateModule(Server* Me)
104         {
105                 return new ModuleBotMode(Me);
106         }
107         
108 };
109
110
111 extern "C" void * init_module( void )
112 {
113         return new ModuleBotModeFactory;
114 }
115