X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_denychans.cpp;h=c823b9c1e835f4a9d4f91d1c0dca95f0a21693db;hb=66098d307c036997e51eaea21724615e27fdc3e9;hp=709a285a05f54287a884c2ed98d5d62b40fff215;hpb=3385d43be8fbac15a16f00777f5c6eba01908373;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_denychans.cpp b/src/modules/m_denychans.cpp index 709a285a0..c823b9c1e 100644 --- a/src/modules/m_denychans.cpp +++ b/src/modules/m_denychans.cpp @@ -19,6 +19,7 @@ #include "modules.h" #include "hashcomp.h" #include "helperfuncs.h" +#include "inspircd.h" /* $ModDesc: Implements config tags which allow blocking of joins to channels */ @@ -26,25 +27,25 @@ class ModuleDenyChannels : public Module { private: - Server *Srv; + ConfigReader *Conf; public: - ModuleDenyChannels(Server* Me) : Module::Module(Me) + ModuleDenyChannels(InspIRCd* Me) : Module::Module(Me) { - Srv = Me; + Conf = new ConfigReader; } - virtual void OnRehash(std::string param) + virtual void OnRehash(const std::string ¶m) { - delete Conf; + DELETE(Conf); Conf = new ConfigReader; } virtual ~ModuleDenyChannels() { - delete Conf; + DELETE(Conf); } virtual Version GetVersion() @@ -57,30 +58,28 @@ class ModuleDenyChannels : public Module List[I_OnUserPreJoin] = List[I_OnRehash] = 1; } - virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname) - { - bool isoper = strchr(user->modes,'o') ? true : false; - + virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname) + { for (int j =0; j < Conf->Enumerate("badchan"); j++) { irc::string cn = Conf->ReadValue("badchan","name",j).c_str(); irc::string thischan = cname; if (thischan == cn) { - if ((Conf->ReadFlag("badchan","allowopers",j)) && isoper == true) + if ((Conf->ReadFlag("badchan","allowopers",j)) && *user->oper) { return 0; } else { std::string reason = Conf->ReadValue("badchan","reason",j); - WriteServ(user->fd,"926 %s %s :Channel %s is forbidden: %s",user->nick,cname,cname,reason.c_str()); + user->WriteServ("926 %s %s :Channel %s is forbidden: %s",user->nick,cname,cname,reason.c_str()); return 1; } } } return 0; - } + } }; // stuff down here is the module-factory stuff. For basic modules you can ignore this. @@ -96,7 +95,7 @@ class ModuleDenyChannelsFactory : public ModuleFactory { } - virtual Module * CreateModule(Server* Me) + virtual Module * CreateModule(InspIRCd* Me) { return new ModuleDenyChannels(Me); }