1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
7 * <brain@chatspike.net>
8 * <Craig@chatspike.net>
10 * Written by Craig Edwards, Craig McLure, and others.
11 * This program is free but copyrighted software; see
12 * the file COPYING for details.
14 * ---------------------------------------------------
24 #include "configreader.h"
27 /* $ModDesc: Provides support for unreal-style umode +B */
29 /** Handles user mode +B
31 class BotMode : public ModeHandler
34 BotMode(InspIRCd* Instance) : ModeHandler(Instance, 'B', 0, 0, false, MODETYPE_USER, false) { }
36 ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding)
38 /* Only opers can change other users modes */
39 if ((source != dest) && (!*source->oper))
40 return MODEACTION_DENY;
44 if (!dest->IsModeSet('B'))
46 dest->SetMode('B',true);
47 return MODEACTION_ALLOW;
52 if (dest->IsModeSet('B'))
54 dest->SetMode('B',false);
55 return MODEACTION_ALLOW;
59 return MODEACTION_DENY;
63 class ModuleBotMode : public Module
68 ModuleBotMode(InspIRCd* Me)
72 bm = new BotMode(ServerInstance);
73 ServerInstance->AddMode(bm, 'B');
76 void Implements(char* List)
81 virtual ~ModuleBotMode()
83 ServerInstance->Modes->DelMode(bm);
87 virtual Version GetVersion()
89 return Version(1,1,0,0,VF_COMMON|VF_VENDOR,API_VERSION);
92 virtual void OnWhois(userrec* src, userrec* dst)
94 if (dst->IsModeSet('B'))
96 ServerInstance->SendWhoisLine(src, dst, 335, std::string(src->nick)+" "+std::string(dst->nick)+" :is a \2bot\2 on "+ServerInstance->Config->Network);
102 // stuff down here is the module-factory stuff. For basic modules you can ignore this.
104 class ModuleBotModeFactory : public ModuleFactory
107 ModuleBotModeFactory()
111 ~ModuleBotModeFactory()
115 virtual Module * CreateModule(InspIRCd* Me)
117 return new ModuleBotMode(Me);
123 extern "C" void * init_module( void )
125 return new ModuleBotModeFactory;