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 ServerInstance->AddMode(bm, 'B');
71 void Implements(char* List)
76 virtual ~ModuleBotMode()
78 ServerInstance->Modes->DelMode(bm);
82 virtual Version GetVersion()
84 return Version(1,1,0,0,VF_COMMON|VF_VENDOR,API_VERSION);
87 virtual void OnWhois(userrec* src, userrec* dst)
89 if (dst->IsModeSet('B'))
91 ServerInstance->SendWhoisLine(src, dst, 335, std::string(src->nick)+" "+std::string(dst->nick)+" :is a \2bot\2 on "+ServerInstance->Config->Network);
97 // stuff down here is the module-factory stuff. For basic modules you can ignore this.
99 class ModuleBotModeFactory : public ModuleFactory
102 ModuleBotModeFactory()
106 ~ModuleBotModeFactory()
110 virtual Module * CreateModule(InspIRCd* Me)
112 return new ModuleBotMode(Me);
118 extern "C" void * init_module( void )
120 return new ModuleBotModeFactory;