1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
7 * <brain@chatspike.net>
8 * <Craig@chatspike.net>
10 * Written by Craig Edwards, Craig McLure, and others.
11 * This program is free but copyrighted software; see
12 * the file COPYING for details.
14 * ---------------------------------------------------
21 #include "helperfuncs.h"
23 /* $ModDesc: Implements config tags which allow blocking of joins to channels */
25 class ModuleDenyChannels : public Module
33 ModuleDenyChannels(Server* Me) : Module::Module(Me)
36 Conf = new ConfigReader;
39 virtual void OnRehash(std::string param)
42 Conf = new ConfigReader;
45 virtual ~ModuleDenyChannels()
50 virtual Version GetVersion()
52 return Version(1,0,0,1,VF_VENDOR);
55 void Implements(char* List)
57 List[I_OnUserPreJoin] = List[I_OnRehash] = 1;
60 virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname)
62 bool isoper = strchr(user->modes,'o') ? true : false;
64 for (int j =0; j < Conf->Enumerate("badchan"); j++)
66 irc::string cn = Conf->ReadValue("badchan","name",j).c_str();
67 irc::string thischan = cname;
70 if ((Conf->ReadFlag("badchan","allowopers",j)) && isoper == true)
76 std::string reason = Conf->ReadValue("badchan","reason",j);
77 WriteServ(user->fd,"926 %s %s :Channel %s is forbidden: %s",user->nick,cname,cname,reason.c_str());
86 // stuff down here is the module-factory stuff. For basic modules you can ignore this.
88 class ModuleDenyChannelsFactory : public ModuleFactory
91 ModuleDenyChannelsFactory()
95 ~ModuleDenyChannelsFactory()
99 virtual Module * CreateModule(Server* Me)
101 return new ModuleDenyChannels(Me);
107 extern "C" void * init_module( void )
109 return new ModuleDenyChannelsFactory;