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 */
30 class ModuleOperChans : public Module
33 ModuleOperChans(Server* Me)
37 // Add a mode +O for channels with no parameters
38 Srv->AddExtendedMode('O',MT_CHANNEL,false,0,0);
41 void Implements(char* List)
43 List[I_OnExtendedMode] = List[I_On005Numeric] = List[I_OnUserPreJoin] = 1;
46 virtual int OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list ¶ms)
48 if ((modechar == 'O') && (type == MT_CHANNEL))
50 chanrec* chan = (chanrec*)target;
52 if ((Srv->IsUlined(user->nick)) || (Srv->IsUlined(user->server)) || (!strcmp(user->server,"")) || (strchr(user->modes,'o')))
58 // eat the mode change, return an error
59 WriteServ(user->fd,"468 %s %s :Only servers and opers may set channel mode +O",user->nick, chan->name);
63 // must return 1 to handle the mode!
70 virtual void On005Numeric(std::string &output)
72 std::stringstream line(output);
73 std::string temp1, temp2;
77 if (temp1.substr(0,10) == "CHANMODES=")
79 // append the chanmode to the end
80 temp1 = temp1.substr(10,temp1.length());
81 temp1 = "CHANMODES=" + temp1 + "O";
83 temp2 = temp2 + temp1 + " ";
86 output = temp2.substr(0,temp2.length()-1);
89 virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname)
91 if (!strchr(user->modes,'o'))
95 if (chan->IsCustomModeSet('O'))
97 WriteServ(user->fd,"520 %s %s :Only IRC operators may join the channel %s (+O is set)",user->nick, chan->name,chan->name);
105 virtual ~ModuleOperChans()
109 virtual Version GetVersion()
111 return Version(1,0,0,0,VF_STATIC|VF_VENDOR);
116 class ModuleOperChansFactory : public ModuleFactory
119 ModuleOperChansFactory()
123 ~ModuleOperChansFactory()
127 virtual Module * CreateModule(Server* Me)
129 return new ModuleOperChans(Me);
135 extern "C" void * init_module( void )
137 return new ModuleOperChansFactory;