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 * ---------------------------------------------------
19 /* $ModDesc: Only opers may create new channels if this module is loaded */
21 class ModuleRestrictChans : public Module
25 std::map<irc::string,int> allowchans;
29 ConfigReader* MyConf = new ConfigReader(ServerInstance);
31 for (int i = 0; i < MyConf->Enumerate("allowchannel"); i++)
34 txt = MyConf->ReadValue("allowchannel", "name", i);
35 irc::string channel = txt.c_str();
36 allowchans[channel] = 1;
42 ModuleRestrictChans(InspIRCd* Me)
49 virtual void OnRehash(userrec* user, const std::string ¶meter)
54 void Implements(char* List)
56 List[I_OnUserPreJoin] = List[I_OnRehash] = 1;
59 virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname, std::string &privs)
61 irc::string x = cname;
62 // user is not an oper and its not in the allow list
63 if ((!IS_OPER(user)) && (allowchans.find(x) == allowchans.end()))
65 // channel does not yet exist (record is null, about to be created IF we were to allow it)
68 user->WriteServ("530 %s %s :Only IRC operators may create new channels",user->nick,cname,cname);
75 virtual ~ModuleRestrictChans()
79 virtual Version GetVersion()
81 return Version(1,1,0,1,VF_VENDOR,API_VERSION);
85 MODULE_INIT(ModuleRestrictChans)