X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_restrictchans.cpp;h=abfb6f580ac80eacc2303f47ed6eb59a81ec54af;hb=6f4bf8ffd367f35b96265fea1ad01fb1acf2adcd;hp=77ab094b6307ad16d8c3c5e3230d301dd0cf2527;hpb=2d821f2980825be73e3f90b47ffff365b0ec5ecb;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_restrictchans.cpp b/src/modules/m_restrictchans.cpp index 77ab094b6..abfb6f580 100644 --- a/src/modules/m_restrictchans.cpp +++ b/src/modules/m_restrictchans.cpp @@ -2,7 +2,7 @@ * | Inspire Internet Relay Chat Daemon | * +------------------------------------+ * - * Inspire is copyright (C) 2002-2004 ChatSpike-Dev. + * InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev. * E-mail: * * @@ -17,33 +17,63 @@ using namespace std; #include +#include #include "users.h" #include "channels.h" #include "modules.h" -#include "helperfuncs.h" + +#include "inspircd.h" /* $ModDesc: Only opers may create new channels if this module is loaded */ -Server *Srv; - class ModuleRestrictChans : public Module { + + + std::map allowchans; + + void ReadConfig() + { + ConfigReader* MyConf = new ConfigReader(ServerInstance); + allowchans.clear(); + for (int i = 0; i < MyConf->Enumerate("allowchannel"); i++) + { + std::string txt; + txt = MyConf->ReadValue("allowchannel", "name", i); + irc::string channel = txt.c_str(); + allowchans[channel] = 1; + } + DELETE(MyConf); + } + public: - ModuleRestrictChans(Server* Me) + ModuleRestrictChans(InspIRCd* Me) : Module::Module(Me) { - Srv = Me; + + ReadConfig(); + } + + virtual void OnRehash(const std::string ¶meter) + { + ReadConfig(); + } + + void Implements(char* List) + { + List[I_OnUserPreJoin] = List[I_OnRehash] = 1; } - virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname) + virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname, std::string &privs) { - // user is not an oper - if (!strchr(user->modes,'o')) + irc::string x = cname; + // user is not an oper and its not in the allow list + if ((!*user->oper) && (allowchans.find(x) == allowchans.end())) { // channel does not yet exist (record is null, about to be created IF we were to allow it) if (!chan) { - WriteServ(user->fd,"530 %s %s :Only IRC operators may create new channels",user->nick,cname,cname); + user->WriteServ("530 %s %s :Only IRC operators may create new channels",user->nick,cname,cname); return 1; } } @@ -56,7 +86,7 @@ class ModuleRestrictChans : public Module virtual Version GetVersion() { - return Version(1,0,0,1,VF_VENDOR); + return Version(1,1,0,1,VF_VENDOR,API_VERSION); } }; @@ -72,7 +102,7 @@ class ModuleRestrictChansFactory : public ModuleFactory { } - virtual Module * CreateModule(Server* Me) + virtual Module * CreateModule(InspIRCd* Me) { return new ModuleRestrictChans(Me); }