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"
25 /* $ModDesc: Provides support for oper-only chans via the +O channel mode */
27 class ModuleOperChans : public Module
31 ModuleOperChans(Server* Me)
35 // Add a mode +O for channels with no parameters
36 Srv->AddExtendedMode('O',MT_CHANNEL,false,0,0);
39 void Implements(char* List)
41 List[I_OnExtendedMode] = List[I_On005Numeric] = List[I_OnUserPreJoin] = 1;
44 virtual int OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list ¶ms)
46 if ((modechar == 'O') && (type == MT_CHANNEL))
48 chanrec* chan = (chanrec*)target;
50 if ((Srv->IsUlined(user->nick)) || (Srv->IsUlined(user->server)) || (!*user->server) || (*user->oper))
52 log(DEBUG,"Allowing mode +O");
57 // eat the mode change, return an error
58 WriteServ(user->fd,"468 %s %s :Only servers and opers may set channel mode +O",user->nick, chan->name);
62 // must return 1 to handle the mode!
69 virtual void On005Numeric(std::string &output)
71 InsertMode(output,"O",4);
74 virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname)
80 if (chan->IsModeSet('O'))
82 WriteServ(user->fd,"520 %s %s :Only IRC operators may join the channel %s (+O is set)",user->nick, chan->name,chan->name);
90 virtual ~ModuleOperChans()
94 virtual Version GetVersion()
96 return Version(1,0,0,0,VF_STATIC|VF_VENDOR);
101 class ModuleOperChansFactory : public ModuleFactory
104 ModuleOperChansFactory()
108 ~ModuleOperChansFactory()
112 virtual Module * CreateModule(Server* Me)
114 return new ModuleOperChans(Me);
120 extern "C" void * init_module( void )
122 return new ModuleOperChansFactory;