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
22 std::map<irc::string,int> allowchans;
26 ConfigReader* MyConf = new ConfigReader;
28 for (int i = 0; i < MyConf->Enumerate("allowchannel"); i++)
31 txt = MyConf->ReadValue("allowchannel", "name", i);
32 irc::string channel = txt.c_str();
33 allowchans[channel] = 1;
43 Implementation eventlist[] = { I_OnUserPreJoin, I_OnRehash };
44 ServerInstance->Modules->Attach(eventlist, this, 2);
47 virtual void OnRehash(User* user)
53 virtual ModResult OnUserPreJoin(User* user, Channel* chan, const char* cname, std::string &privs, const std::string &keygiven)
55 irc::string x = cname;
57 return MOD_RES_PASSTHRU;
59 // channel does not yet exist (record is null, about to be created IF we were to allow it)
62 // user is not an oper and its not in the allow list
63 if ((!IS_OPER(user)) && (allowchans.find(x) == allowchans.end()))
65 user->WriteNumeric(ERR_BANNEDFROMCHAN, "%s %s :Only IRC operators may create new channels",user->nick.c_str(),cname);
69 return MOD_RES_PASSTHRU;
72 virtual ~ModuleRestrictChans()
76 virtual Version GetVersion()
78 return Version("Only opers may create new channels if this module is loaded",VF_VENDOR,API_VERSION);
82 MODULE_INIT(ModuleRestrictChans)