1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2008 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 * ---------------------------------------------------
17 /* $ModDesc: Implements config tags which allow blocking of joins to channels */
19 class ModuleDenyChannels : public Module
27 ModuleDenyChannels(InspIRCd* Me) : Module(Me)
30 Conf = new ConfigReader(ServerInstance);
31 Implementation eventlist[] = { I_OnUserPreJoin, I_OnRehash };
32 ServerInstance->Modules->Attach(eventlist, this, 2);
35 virtual void OnRehash(User* user, const std::string ¶m)
38 Conf = new ConfigReader(ServerInstance);
41 virtual ~ModuleDenyChannels()
46 virtual Version GetVersion()
48 return Version(1,1,0,1,VF_VENDOR,API_VERSION);
52 virtual int OnUserPreJoin(User* user, Channel* chan, const char* cname, std::string &privs)
54 for (int j =0; j < Conf->Enumerate("badchan"); j++)
56 if (match(cname, Conf->ReadValue("badchan","name",j).c_str()))
58 if (IS_OPER(user) && Conf->ReadFlag("badchan","allowopers",j))
64 std::string reason = Conf->ReadValue("badchan","reason",j);
66 for (int j = 0; j < Conf->Enumerate("goodchan"); j++)
68 if (match(cname, Conf->ReadValue("goodchan", "name", j).c_str()))
74 user->WriteServ("926 %s %s :Channel %s is forbidden: %s",user->nick,cname,cname,reason.c_str());
83 MODULE_INIT(ModuleDenyChannels)