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 * ---------------------------------------------------
22 /* $ModDesc: Only opers may create new channels if this module is loaded */
24 class ModuleRestrictChans : public Module
28 std::map<irc::string,int> allowchans;
32 ConfigReader* MyConf = new ConfigReader(ServerInstance);
34 for (int i = 0; i < MyConf->Enumerate("allowchannel"); i++)
37 txt = MyConf->ReadValue("allowchannel", "name", i);
38 irc::string channel = txt.c_str();
39 allowchans[channel] = 1;
45 ModuleRestrictChans(InspIRCd* Me)
52 virtual void OnRehash(const std::string ¶meter)
57 void Implements(char* List)
59 List[I_OnUserPreJoin] = List[I_OnRehash] = 1;
62 virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname, std::string &privs)
64 irc::string x = cname;
65 // user is not an oper and its not in the allow list
66 if ((!*user->oper) && (allowchans.find(x) == allowchans.end()))
68 // channel does not yet exist (record is null, about to be created IF we were to allow it)
71 user->WriteServ("530 %s %s :Only IRC operators may create new channels",user->nick,cname,cname);
78 virtual ~ModuleRestrictChans()
82 virtual Version GetVersion()
84 return Version(1,1,0,1,VF_VENDOR,API_VERSION);
89 class ModuleRestrictChansFactory : public ModuleFactory
92 ModuleRestrictChansFactory()
96 ~ModuleRestrictChansFactory()
100 virtual Module * CreateModule(InspIRCd* Me)
102 return new ModuleRestrictChans(Me);
108 extern "C" void * init_module( void )
110 return new ModuleRestrictChansFactory;