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 * ---------------------------------------------------
27 /* $ModDesc: Only opers may create new channels if this module is loaded */
29 class ModuleRestrictChans : public Module
33 std::map<irc::string,int> allowchans;
37 ConfigReader* MyConf = new ConfigReader(ServerInstance);
39 for (int i = 0; i < MyConf->Enumerate("allowchannel"); i++)
42 txt = MyConf->ReadValue("allowchannel", "name", i);
43 irc::string channel = txt.c_str();
44 allowchans[channel] = 1;
50 ModuleRestrictChans(InspIRCd* Me)
57 virtual void OnRehash(const std::string ¶meter)
62 void Implements(char* List)
64 List[I_OnUserPreJoin] = List[I_OnRehash] = 1;
67 virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname)
69 irc::string x = cname;
70 // user is not an oper and its not in the allow list
71 if ((!*user->oper) && (allowchans.find(x) == allowchans.end()))
73 // channel does not yet exist (record is null, about to be created IF we were to allow it)
76 user->WriteServ("530 %s %s :Only IRC operators may create new channels",user->nick,cname,cname);
83 virtual ~ModuleRestrictChans()
87 virtual Version GetVersion()
89 return Version(1,0,0,1,VF_VENDOR);
94 class ModuleRestrictChansFactory : public ModuleFactory
97 ModuleRestrictChansFactory()
101 ~ModuleRestrictChansFactory()
105 virtual Module * CreateModule(InspIRCd* Me)
107 return new ModuleRestrictChans(Me);
113 extern "C" void * init_module( void )
115 return new ModuleRestrictChansFactory;