1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * Inspire is copyright (C) 2002-2004 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 * ---------------------------------------------------
22 /* $ModDesc: Provides support for oper-only chans via the +O channel mode */
27 class ModuleOperChans : public Module
34 // Add a mode +O for channels with no parameters
35 Srv->AddExtendedMode('O',MT_CHANNEL,false,0,0);
38 virtual int OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list ¶ms)
40 if ((modechar == 'O') && (type == MT_CHANNEL))
42 chanrec* chan = (chanrec*)target;
44 if ((Srv->IsUlined(user->nick)) || (Srv->IsUlined(user->server)) || (!strcmp(user->server,"")) || (strchr(user->modes,'o')))
50 // eat the mode change, return an error
51 WriteServ(user->fd,"468 %s %s :Only servers and opers may set channel mode +O",user->nick, chan->name);
55 // must return 1 to handle the mode!
62 virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname)
64 if (!strchr(user->modes,'o'))
68 if (chan->IsCustomModeSet('O'))
70 WriteServ(user->fd,"520 %s %s :Only IRC operators may join the channel %s (+O is set)",user->nick, chan->name,chan->name);
78 virtual ~ModuleOperChans()
83 virtual Version GetVersion()
85 return Version(1,0,0,0);
88 virtual void OnUserConnect(userrec* user)
95 class ModuleOperChansFactory : public ModuleFactory
98 ModuleOperChansFactory()
102 ~ModuleOperChansFactory()
106 virtual Module * CreateModule()
108 return new ModuleOperChans;
114 extern "C" void * init_module( void )
116 return new ModuleOperChansFactory;