1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2007 InspIRCd Development Team
6 * See: http://www.inspircd.org/wiki/index.php/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
19 #include "configreader.h"
22 /* $ModDesc: Provides support for unreal-style umode +B */
24 /** Handles user mode +B
26 class BotMode : public ModeHandler
29 BotMode(InspIRCd* Instance) : ModeHandler(Instance, 'B', 0, 0, false, MODETYPE_USER, false) { }
31 ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding)
33 /* Only opers can change other users modes */
34 if ((source != dest) && (!*source->oper))
35 return MODEACTION_DENY;
39 if (!dest->IsModeSet('B'))
41 dest->SetMode('B',true);
42 return MODEACTION_ALLOW;
47 if (dest->IsModeSet('B'))
49 dest->SetMode('B',false);
50 return MODEACTION_ALLOW;
54 return MODEACTION_DENY;
58 class ModuleBotMode : public Module
63 ModuleBotMode(InspIRCd* Me)
67 bm = new BotMode(ServerInstance);
68 if (!ServerInstance->AddMode(bm, 'B'))
69 throw ModuleException("Could not add new modes!");
72 void Implements(char* List)
77 virtual ~ModuleBotMode()
79 ServerInstance->Modes->DelMode(bm);
83 virtual Version GetVersion()
85 return Version(1,1,0,0,VF_COMMON|VF_VENDOR,API_VERSION);
88 virtual void OnWhois(userrec* src, userrec* dst)
90 if (dst->IsModeSet('B'))
92 ServerInstance->SendWhoisLine(src, dst, 335, std::string(src->nick)+" "+std::string(dst->nick)+" :is a bot on "+ServerInstance->Config->Network);
98 // stuff down here is the module-factory stuff. For basic modules you can ignore this.
100 class ModuleBotModeFactory : public ModuleFactory
103 ModuleBotModeFactory()
107 ~ModuleBotModeFactory()
111 virtual Module * CreateModule(InspIRCd* Me)
113 return new ModuleBotMode(Me);
119 extern "C" void * init_module( void )
121 return new ModuleBotModeFactory;