1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2010 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;
25 ConfigTagList tags = ServerInstance->Config->ConfTags("allowchannel");
26 for(ConfigIter i = tags.first; i != tags.second; ++i)
28 ConfigTag* tag = i->second;
29 std::string txt = tag->getString("name");
30 allowchans.insert(txt.c_str());
38 Implementation eventlist[] = { I_OnUserPreJoin, I_OnRehash };
39 ServerInstance->Modules->Attach(eventlist, this, 2);
42 virtual void OnRehash(User* user)
48 virtual ModResult OnUserPreJoin(User* user, Channel* chan, const char* cname, std::string &privs, const std::string &keygiven)
50 irc::string x = cname;
52 return MOD_RES_PASSTHRU;
54 // channel does not yet exist (record is null, about to be created IF we were to allow it)
57 // user is not an oper and its not in the allow list
58 if ((!IS_OPER(user)) && (allowchans.find(x) == allowchans.end()))
60 user->WriteNumeric(ERR_BANNEDFROMCHAN, "%s %s :Only IRC operators may create new channels",user->nick.c_str(),cname);
64 return MOD_RES_PASSTHRU;
67 virtual ~ModuleRestrictChans()
71 virtual Version GetVersion()
73 return Version("Only opers may create new channels if this module is loaded",VF_VENDOR);
77 MODULE_INIT(ModuleRestrictChans)