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 /* $ModDesc: Provides support for oper-only chans via the +O channel mode */
21 class OperChans : public ModeHandler
24 /* This is an oper-only mode */
25 OperChans(InspIRCd* Instance) : ModeHandler(Instance, 'O', 0, 0, false, MODETYPE_CHANNEL, true) { }
27 ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding)
31 if (!channel->IsModeSet('O'))
33 channel->SetMode('O',true);
34 return MODEACTION_ALLOW;
39 if (channel->IsModeSet('O'))
41 channel->SetMode('O',false);
42 return MODEACTION_ALLOW;
46 return MODEACTION_DENY;
50 class ModuleOperChans : public Module
55 ModuleOperChans(InspIRCd* Me)
59 oc = new OperChans(ServerInstance);
60 ServerInstance->AddMode(oc, 'O');
63 void Implements(char* List)
65 List[I_OnUserPreJoin] = 1;
68 virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname, std::string &privs)
74 if (chan->IsModeSet('O'))
76 user->WriteServ("520 %s %s :Only IRC operators may join the channel %s (+O is set)",user->nick, chan->name,chan->name);
84 virtual ~ModuleOperChans()
86 ServerInstance->Modes->DelMode(oc);
90 virtual Version GetVersion()
92 return Version(1,1,0,0,VF_VENDOR|VF_COMMON,API_VERSION);
97 class ModuleOperChansFactory : public ModuleFactory
100 ModuleOperChansFactory()
104 ~ModuleOperChansFactory()
108 virtual Module * CreateModule(InspIRCd* Me)
110 return new ModuleOperChans(Me);
116 extern "C" void * init_module( void )
118 return new ModuleOperChansFactory;