1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2009 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(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding, bool)
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->Modes->AddMode(oc))
58 throw ModuleException("Could not add new modes!");
59 Implementation eventlist[] = { I_OnUserPreJoin };
60 ServerInstance->Modules->Attach(eventlist, this, 1);
64 virtual int OnUserPreJoin(User* user, Channel* chan, const char* cname, std::string &privs, const std::string &keygiven)
70 if (chan->IsModeSet('O'))
72 user->WriteNumeric(ERR_CANTJOINOPERSONLY, "%s %s :Only IRC operators may join the channel %s (+O is set)",user->nick.c_str(), chan->name.c_str(), chan->name.c_str());
79 if (chan && chan->IsExtBanned(user->oper, 'O'))
81 user->WriteNumeric(ERR_BANNEDFROMCHAN, "%s %s :Cannot join channel (You're banned)", user->nick.c_str(), chan->name.c_str());
89 virtual ~ModuleOperChans()
91 ServerInstance->Modes->DelMode(oc);
95 virtual Version GetVersion()
97 return Version("$Id$", VF_VENDOR | VF_COMMON, API_VERSION);
101 MODULE_INIT(ModuleOperChans)