7 /* $ModDesc: Provides support for oper-only chans via the +O channel mode */
12 class ModuleOperChans : public Module
19 // Add a mode +O for channels with no parameters
20 Srv->AddExtendedMode('O',MT_CHANNEL,false,0,0);
23 virtual int OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list ¶ms)
25 if ((modechar == 'O') && (type == MT_CHANNEL))
27 chanrec* chan = (chanrec*)target;
29 if ((Srv->IsUlined(user->nick)) || (Srv->IsUlined(user->server)) || (!strcmp(user->server,"")) || (strchr(user->modes,'o')))
35 // eat the mode change, return an error
36 WriteServ(user->fd,"468 %s %s :Only servers and opers may set channel mode +O",user->nick, chan->name);
40 // must return 1 to handle the mode!
47 virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname)
49 if (!strchr(user->modes,'o'))
53 if (chan->IsCustomModeSet('O'))
55 WriteServ(user->fd,"520 %s %s :Only IRC operators may join the channel %s (+O is set)",user->nick, chan->name,chan->name);
63 virtual ~ModuleOperChans()
68 virtual Version GetVersion()
70 return Version(1,0,0,0);
73 virtual void OnUserConnect(userrec* user)
80 class ModuleOperChansFactory : public ModuleFactory
83 ModuleOperChansFactory()
87 ~ModuleOperChansFactory()
91 virtual Module * CreateModule()
93 return new ModuleOperChans;
99 extern "C" void * init_module( void )
101 return new ModuleOperChansFactory;