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 * ---------------------------------------------------
24 /* $ModDesc: Provides support for oper-only chans via the +O channel mode */
26 class OperChans : public ModeHandler
29 /* This is an oper-only mode */
30 OperChans(InspIRCd* Instance) : ModeHandler(Instance, 'O', 0, 0, false, MODETYPE_CHANNEL, true) { }
32 ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding)
36 if (!channel->IsModeSet('O'))
38 channel->SetMode('O',true);
39 return MODEACTION_ALLOW;
44 if (channel->IsModeSet('O'))
46 channel->SetMode('O',false);
47 return MODEACTION_ALLOW;
51 return MODEACTION_DENY;
55 class ModuleOperChans : public Module
60 ModuleOperChans(InspIRCd* Me)
64 oc = new OperChans(ServerInstance);
65 ServerInstance->AddMode(oc, 'O');
68 void Implements(char* List)
70 List[I_OnUserPreJoin] = 1;
73 virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname, std::string &privs)
79 if (chan->IsModeSet('O'))
81 user->WriteServ("520 %s %s :Only IRC operators may join the channel %s (+O is set)",user->nick, chan->name,chan->name);
89 virtual ~ModuleOperChans()
91 ServerInstance->Modes->DelMode(oc);
95 virtual Version GetVersion()
97 return Version(1,0,0,0,VF_VENDOR|VF_COMMON);
102 class ModuleOperChansFactory : public ModuleFactory
105 ModuleOperChansFactory()
109 ~ModuleOperChansFactory()
113 virtual Module * CreateModule(InspIRCd* Me)
115 return new ModuleOperChans(Me);
121 extern "C" void * init_module( void )
123 return new ModuleOperChansFactory;