1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2009 InspIRCd Development Team
6 * See: http://wiki.inspircd.org/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
16 /* $ModDesc: Only opers may create new channels if this module is loaded */
18 class ModuleRestrictChans : public Module
20 std::set<irc::string> allowchans;
27 ConfigTag* tag = ServerInstance->Config->ConfValue("allowchannel", i);
30 std::string txt = tag->getString("name");
31 allowchans.insert(txt.c_str());
39 Implementation eventlist[] = { I_OnUserPreJoin, I_OnRehash };
40 ServerInstance->Modules->Attach(eventlist, this, 2);
43 virtual void OnRehash(User* user)
49 virtual ModResult OnUserPreJoin(User* user, Channel* chan, const char* cname, std::string &privs, const std::string &keygiven)
51 irc::string x = cname;
53 return MOD_RES_PASSTHRU;
55 // channel does not yet exist (record is null, about to be created IF we were to allow it)
58 // user is not an oper and its not in the allow list
59 if ((!IS_OPER(user)) && (allowchans.find(x) == allowchans.end()))
61 user->WriteNumeric(ERR_BANNEDFROMCHAN, "%s %s :Only IRC operators may create new channels",user->nick.c_str(),cname);
65 return MOD_RES_PASSTHRU;
68 virtual ~ModuleRestrictChans()
72 virtual Version GetVersion()
74 return Version("Only opers may create new channels if this module is loaded",VF_VENDOR);
78 MODULE_INIT(ModuleRestrictChans)