]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_botmode.cpp
1fe3728ee29a2a2973b9416b68229f90c5ae8a2f
[user/henk/code/inspircd.git] / src / modules / m_botmode.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2009 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 SimpleUserModeHandler
21 {
22  public:
23         BotMode(InspIRCd* Instance) : SimpleUserModeHandler(Instance, 'B') { }
24 };
25
26 class ModuleBotMode : public Module
27 {
28
29         BotMode* bm;
30  public:
31         ModuleBotMode(InspIRCd* Me)
32                 : Module(Me)
33         {
34
35                 bm = new BotMode(ServerInstance);
36                 if (!ServerInstance->Modes->AddMode(bm))
37                         throw ModuleException("Could not add new modes!");
38                 Implementation eventlist[] = { I_OnWhois };
39                 ServerInstance->Modules->Attach(eventlist, this, 1);
40         }
41
42
43         virtual ~ModuleBotMode()
44         {
45                 ServerInstance->Modes->DelMode(bm);
46                 delete bm;
47         }
48
49         virtual Version GetVersion()
50         {
51                 return Version("$Id$",VF_COMMON|VF_VENDOR,API_VERSION);
52         }
53
54         virtual void OnWhois(User* src, User* dst)
55         {
56                 if (dst->IsModeSet('B'))
57                 {
58                         ServerInstance->SendWhoisLine(src, dst, 335, std::string(src->nick)+" "+std::string(dst->nick)+" :is a bot on "+ServerInstance->Config->Network);
59                 }
60         }
61
62 };
63
64
65 MODULE_INIT(ModuleBotMode)