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 * ---------------------------------------------------
24 #include "helperfuncs.h"
26 /* $ModDesc: Only opers may create new channels if this module is loaded */
28 class ModuleRestrictChans : public Module
32 std::map<irc::string,int> allowchans;
36 ConfigReader* MyConf = new ConfigReader();
38 for (int i = 0; i < MyConf->Enumerate("allowchannel"); i++)
41 txt = MyConf->ReadValue("allowchannel", "name", i);
42 irc::string channel = txt.c_str();
43 allowchans[channel] = 1;
49 ModuleRestrictChans(Server* Me)
56 virtual void OnRehash(const std::string ¶meter)
61 void Implements(char* List)
63 List[I_OnUserPreJoin] = List[I_OnRehash] = 1;
66 virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname)
68 irc::string x = cname;
69 // user is not an oper and its not in the allow list
70 if ((!*user->oper) && (allowchans.find(x) == allowchans.end()))
72 // channel does not yet exist (record is null, about to be created IF we were to allow it)
75 WriteServ(user->fd,"530 %s %s :Only IRC operators may create new channels",user->nick,cname,cname);
82 virtual ~ModuleRestrictChans()
86 virtual Version GetVersion()
88 return Version(1,0,0,1,VF_VENDOR);
93 class ModuleRestrictChansFactory : public ModuleFactory
96 ModuleRestrictChansFactory()
100 ~ModuleRestrictChansFactory()
104 virtual Module * CreateModule(Server* Me)
106 return new ModuleRestrictChans(Me);
112 extern "C" void * init_module( void )
114 return new ModuleRestrictChansFactory;