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 * ---------------------------------------------------
25 /* $ModDesc: Provides support for unreal-style umode +B */
27 class BotMode : public ModeHandler
29 BotMode() : ModeHandler('B', 0, 0, false, MODETYPE_USER, false) { }
31 ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding)
35 if (!dest->IsModeSet('B'))
37 user->SetMode('B',true);
38 return MODEACTION_ALLOW;
43 if (dest->IsModeSet('B'))
45 user->SetMode('B',false);
46 return MODEACTION_ALLOW;
52 class ModuleBotMode : public Module
56 ModuleBotMode(Server* Me)
61 if (!Srv->AddExtendedMode('B',MT_CLIENT,false,0,0))
63 Srv->Log(DEFAULT,"*** m_botmode: ERROR, failed to allocate user mode +B!");
68 void Implements(char* List)
70 List[I_OnWhois] = List[I_OnExtendedMode] = 1;
73 virtual ~ModuleBotMode()
77 virtual Version GetVersion()
79 return Version(1,0,0,0,VF_STATIC|VF_VENDOR);
82 virtual int OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list ¶ms)
84 if ((modechar == 'B') && (type == MT_CLIENT))
94 virtual void OnWhois(userrec* src, userrec* dst)
96 if (dst->modes['B'-65])
98 Srv->SendTo(NULL,src,"335 "+std::string(src->nick)+" "+std::string(dst->nick)+" :is a \2bot\2 on "+Srv->GetNetworkName());
104 // stuff down here is the module-factory stuff. For basic modules you can ignore this.
106 class ModuleBotModeFactory : public ModuleFactory
109 ModuleBotModeFactory()
113 ~ModuleBotModeFactory()
117 virtual Module * CreateModule(Server* Me)
119 return new ModuleBotMode(Me);
125 extern "C" void * init_module( void )
127 return new ModuleBotModeFactory;