]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_botmode.cpp
86dc9ea0055170ded2b67da1e1d022b3a02a266f
[user/henk/code/inspircd.git] / src / modules / m_botmode.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2007 InspIRCd Development Team
6  * See: http://www.inspircd.org/wiki/index.php/Credits
7  *
8  * This program is free but copyrighted software; see
9  *            the file COPYING for details.
10  *
11  * ---------------------------------------------------
12  */
13
14 #include "inspircd.h"
15
16 /* $ModDesc: Provides support for unreal-style umode +B */
17
18 /** Handles user mode +B
19  */
20 class BotMode : public ModeHandler
21 {
22  public:
23         BotMode(InspIRCd* Instance) : ModeHandler(Instance, 'B', 0, 0, false, MODETYPE_USER, false) { }
24
25         ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding)
26         {
27                 if (adding)
28                 {
29                         if (!dest->IsModeSet('B'))
30                         {
31                                 dest->SetMode('B',true);
32                                 return MODEACTION_ALLOW;
33                         }
34                 }
35                 else
36                 {
37                         if (dest->IsModeSet('B'))
38                         {
39                                 dest->SetMode('B',false);
40                                 return MODEACTION_ALLOW;
41                         }
42                 }
43                 
44                 return MODEACTION_DENY;
45         }
46 };
47
48 class ModuleBotMode : public Module
49 {
50         
51         BotMode* bm;
52  public:
53         ModuleBotMode(InspIRCd* Me)
54                 : Module(Me)
55         {
56                 
57                 bm = new BotMode(ServerInstance);
58                 if (!ServerInstance->AddMode(bm, 'B'))
59                         throw ModuleException("Could not add new modes!");
60         }
61
62         void Implements(char* List)
63         {
64                 List[I_OnWhois] = 1;
65         }
66         
67         virtual ~ModuleBotMode()
68         {
69                 ServerInstance->Modes->DelMode(bm);
70                 DELETE(bm);
71         }
72         
73         virtual Version GetVersion()
74         {
75                 return Version(1,1,0,0,VF_COMMON|VF_VENDOR,API_VERSION);
76         }
77
78         virtual void OnWhois(userrec* src, userrec* dst)
79         {
80                 if (dst->IsModeSet('B'))
81                 {
82                         ServerInstance->SendWhoisLine(src, dst, 335, std::string(src->nick)+" "+std::string(dst->nick)+" :is a bot on "+ServerInstance->Config->Network);
83                 }
84         }
85
86 };
87
88
89 MODULE_INIT(ModuleBotMode)