]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_botmode.cpp
Remove a redundant method here, call the mode manager directly
[user/henk/code/inspircd.git] / src / modules / m_botmode.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2008 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(User* source, User* dest, Channel* 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->Modes->AddMode(bm))
59                         throw ModuleException("Could not add new modes!");
60                 Implementation eventlist[] = { I_OnWhois };
61                 ServerInstance->Modules->Attach(eventlist, this, 1);
62         }
63
64         
65         virtual ~ModuleBotMode()
66         {
67                 ServerInstance->Modes->DelMode(bm);
68                 delete bm;
69         }
70         
71         virtual Version GetVersion()
72         {
73                 return Version(1,1,0,0,VF_COMMON|VF_VENDOR,API_VERSION);
74         }
75
76         virtual void OnWhois(User* src, User* dst)
77         {
78                 if (dst->IsModeSet('B'))
79                 {
80                         ServerInstance->SendWhoisLine(src, dst, 335, std::string(src->nick)+" "+std::string(dst->nick)+" :is a bot on "+ServerInstance->Config->Network);
81                 }
82         }
83
84 };
85
86
87 MODULE_INIT(ModuleBotMode)