X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_filter.cpp;h=46f5922f017cd1250cdfa96eb20c11f3ab2a9074;hb=7c0c957577a195b4819e4d7f2c9672d7c7522b0d;hp=8dd862ee7f7fadef819ac6ad7f324b31d3b84fdd;hpb=93876363f89ea7a451ba1e18407e08a539854208;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_filter.cpp b/src/modules/m_filter.cpp index 8dd862ee7..46f5922f0 100644 --- a/src/modules/m_filter.cpp +++ b/src/modules/m_filter.cpp @@ -25,10 +25,14 @@ using namespace std; #include "users.h" #include "channels.h" #include "modules.h" -#include "helperfuncs.h" +#include "inspircd.h" /* $ModDesc: An enhanced version of the unreal m_filter.so used by chatspike.net */ + + +/** Holds a filter pattern and reason + */ class Filter : public classbase { public: @@ -38,6 +42,8 @@ class Filter : public classbase typedef std::map filter_t; +/** Thrown by m_filter + */ class FilterException : public ModuleException { public: @@ -49,11 +55,11 @@ class FilterException : public ModuleException class ModuleFilter : public Module { - Server *Srv; + filter_t filters; public: - ModuleFilter(Server* Me) + ModuleFilter(InspIRCd* Me) : Module::Module(Me) { // read the configuration file on startup. @@ -61,7 +67,7 @@ class ModuleFilter : public Module // main config file, then append your tags to the bottom // of the main config... but rather messy. That's why the capability // of using a seperate config file is provided. - Srv = Me; + OnRehash(""); } @@ -86,7 +92,7 @@ class ModuleFilter : public Module std::string text2 = text+" "; for (filter_t::iterator index = filters.begin(); index != filters.end(); index++) { - if ((Srv->MatchText(text2,index->first)) || (Srv->MatchText(text,index->first))) + if ((ServerInstance->MatchText(text2,index->first)) || (ServerInstance->MatchText(text,index->first))) { Filter* f = (Filter*)index->second; std::string target = ""; @@ -104,19 +110,14 @@ class ModuleFilter : public Module if (f->action == "block") { - Srv->SendOpers(std::string("FILTER: ")+std::string(user->nick)+ - std::string(" had their notice filtered, target was ")+ - target+": "+f->reason); - Srv->SendTo(NULL,user,"NOTICE "+std::string(user->nick)+ - " :Your notice has been filtered and opers notified: "+f->reason); + ServerInstance->WriteOpers(std::string("FILTER: ")+user->nick+" had their notice filtered, target was "+target+": "+f->reason); + user->WriteServ("NOTICE "+std::string(user->nick)+" :Your notice has been filtered and opers notified: "+f->reason); } - Srv->Log(DEFAULT,std::string("FILTER: ")+std::string(user->nick)+ - std::string(" had their notice filtered, target was ")+ - target+": "+f->reason+" Action: "+f->action); + ServerInstance->Log(DEFAULT,"FILTER: "+std::string(user->nick)+std::string(" had their notice filtered, target was ")+target+": "+f->reason+" Action: "+f->action); if (f->action == "kill") { - userrec::QuitUser(user,f->reason); + userrec::QuitUser(ServerInstance,user,f->reason); } return 1; } @@ -128,10 +129,10 @@ class ModuleFilter : public Module { // reload our config file on rehash - we must destroy and re-allocate the classes // to call the constructor again and re-read our data. - ConfigReader* Conf = new ConfigReader; + ConfigReader* Conf = new ConfigReader(ServerInstance); std::string filterfile = Conf->ReadValue("filter","file",0); // this automatically re-reads the configuration file into the class - ConfigReader* MyConf = new ConfigReader(filterfile); + ConfigReader* MyConf = new ConfigReader(ServerInstance, filterfile); if ((filterfile == "") || (!MyConf->Verify())) { // bail if the user forgot to create a config file @@ -155,7 +156,7 @@ class ModuleFilter : public Module x->action = do_action; filters[pattern] = x; } - Srv->Log(DEFAULT,std::string("m_filter: read configuration from ")+filterfile); + ServerInstance->Log(DEFAULT,"m_filter: read configuration from "+filterfile); DELETE(Conf); DELETE(MyConf); } @@ -181,7 +182,7 @@ class ModuleFilterFactory : public ModuleFactory { } - virtual Module * CreateModule(Server* Me) + virtual Module * CreateModule(InspIRCd* Me) { return new ModuleFilter(Me); }