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"
26 /* $ModDesc: Provides support for oper-only chans via the +O channel mode */
28 extern InspIRCd* ServerInstance;
30 class OperChans : public ModeHandler
33 /* This is an oper-only mode */
34 OperChans(InspIRCd* Instance) : ModeHandler(Instance, 'O', 0, 0, false, MODETYPE_CHANNEL, true) { }
36 ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding)
40 if (!channel->IsModeSet('O'))
42 channel->SetMode('O',true);
43 return MODEACTION_ALLOW;
48 if (channel->IsModeSet('O'))
50 channel->SetMode('O',false);
51 return MODEACTION_ALLOW;
55 return MODEACTION_DENY;
59 class ModuleOperChans : public Module
64 ModuleOperChans(InspIRCd* Me)
68 oc = new OperChans(ServerInstance);
69 Srv->AddMode(oc, 'O');
72 void Implements(char* List)
74 List[I_On005Numeric] = List[I_OnUserPreJoin] = 1;
77 virtual void On005Numeric(std::string &output)
79 ServerInstance->ModeGrok->InsertMode(output,"O",4);
82 virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname)
88 if (chan->IsModeSet('O'))
90 user->WriteServ("520 %s %s :Only IRC operators may join the channel %s (+O is set)",user->nick, chan->name,chan->name);
98 virtual ~ModuleOperChans()
103 virtual Version GetVersion()
105 return Version(1,0,0,0,VF_STATIC|VF_VENDOR);
110 class ModuleOperChansFactory : public ModuleFactory
113 ModuleOperChansFactory()
117 ~ModuleOperChansFactory()
121 virtual Module * CreateModule(InspIRCd* Me)
123 return new ModuleOperChans(Me);
129 extern "C" void * init_module( void )
131 return new ModuleOperChansFactory;