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 * ---------------------------------------------------
23 #include "helperfuncs.h"
25 /* $ModDesc: Provides support for oper-only chans via the +O channel mode */
27 class OperChans : public ModeHandler
30 /* This is an oper-only mode */
31 OperChans() : ModeHandler('O', 0, 0, false, MODETYPE_CHANNEL, true) { }
33 ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding)
37 if (!channel->IsModeSet('O'))
39 channel->SetMode('O',true);
40 return MODEACTION_ALLOW;
45 if (channel->IsModeSet('O'))
47 channel->SetMode('O',false);
48 return MODEACTION_ALLOW;
52 return MODEACTION_DENY;
56 class ModuleOperChans : public Module
61 ModuleOperChans(Server* Me)
65 // Add a mode +O for channels with no parameters
67 Srv->AddMode(oc, 'O');
70 void Implements(char* List)
72 List[I_On005Numeric] = List[I_OnUserPreJoin] = 1;
75 virtual void On005Numeric(std::string &output)
77 InsertMode(output,"O",4);
80 virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname)
86 if (chan->IsModeSet('O'))
88 WriteServ(user->fd,"520 %s %s :Only IRC operators may join the channel %s (+O is set)",user->nick, chan->name,chan->name);
96 virtual ~ModuleOperChans()
101 virtual Version GetVersion()
103 return Version(1,0,0,0,VF_STATIC|VF_VENDOR);
108 class ModuleOperChansFactory : public ModuleFactory
111 ModuleOperChansFactory()
115 ~ModuleOperChansFactory()
119 virtual Module * CreateModule(Server* Me)
121 return new ModuleOperChans(Me);
127 extern "C" void * init_module( void )
129 return new ModuleOperChansFactory;