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 * ---------------------------------------------------
16 /* $ModDesc: Provides support for oper-only chans via the +O channel mode */
18 class OperChans : public ModeHandler
21 /* This is an oper-only mode */
22 OperChans(InspIRCd* Instance) : ModeHandler(Instance, 'O', 0, 0, false, MODETYPE_CHANNEL, true) { }
24 ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding)
28 if (!channel->IsModeSet('O'))
30 channel->SetMode('O',true);
31 return MODEACTION_ALLOW;
36 if (channel->IsModeSet('O'))
38 channel->SetMode('O',false);
39 return MODEACTION_ALLOW;
43 return MODEACTION_DENY;
47 class ModuleOperChans : public Module
52 ModuleOperChans(InspIRCd* Me)
56 oc = new OperChans(ServerInstance);
57 if (!ServerInstance->AddMode(oc, 'O'))
58 throw ModuleException("Could not add new modes!");
61 void Implements(char* List)
63 List[I_OnUserPreJoin] = 1;
66 virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname, std::string &privs)
72 if (chan->IsModeSet('O'))
74 user->WriteServ("520 %s %s :Only IRC operators may join the channel %s (+O is set)",user->nick, chan->name,chan->name);
82 virtual ~ModuleOperChans()
84 ServerInstance->Modes->DelMode(oc);
88 virtual Version GetVersion()
90 return Version(1,1,0,0,VF_VENDOR|VF_COMMON,API_VERSION);
94 MODULE_INIT(ModuleOperChans)