X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fmodules%2Fm_filter.cpp;h=d2cffdb5dd8e712ae56a68846d0e424210b62704;hb=553a8da754c8cd308bad2008018849714e70f9b7;hp=f3f58a0739ab55678f9753161346b8ce7968873c;hpb=79228c71c3cf862046ef456f2fbb0cc2fe4c9369;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_filter.cpp b/src/modules/m_filter.cpp index f3f58a073..d2cffdb5d 100644 --- a/src/modules/m_filter.cpp +++ b/src/modules/m_filter.cpp @@ -1,16 +1,25 @@ -/* +------------------------------------+ - * | Inspire Internet Relay Chat Daemon | - * +------------------------------------+ +/* + * InspIRCd -- Internet Relay Chat Daemon * - * InspIRCd: (C) 2002-2010 InspIRCd Development Team - * See: http://wiki.inspircd.org/Credits + * Copyright (C) 2009 Daniel De Graaf + * Copyright (C) 2004, 2008 Craig Edwards + * Copyright (C) 2007 Dennis Friis + * Copyright (C) 2007 Robin Burchell * - * This program is free but copyrighted software; see - * the file COPYING for details. + * This file is part of InspIRCd. InspIRCd is free software: you can + * redistribute it and/or modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation, version 2. * - * --------------------------------------------------- + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ + #include "inspircd.h" #include "xline.h" #include "m_regex.h" @@ -139,7 +148,7 @@ class ModuleFilter : public Module std::vector exemptfromfilter; // List of channel names excluded from filtering. ModuleFilter(); - + void init(); ~ModuleFilter(); ModResult OnUserPreMessage(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list); FilterResult* FilterMatch(User* user, const std::string &text, int flags); @@ -155,7 +164,7 @@ class ModuleFilter : public Module void OnSyncNetwork(Module* proto, void* opaque); void OnDecodeMetaData(Extensible* target, const std::string &extname, const std::string &extdata); ModResult OnStats(char symbol, User* user, string_list &results); - ModResult OnPreCommand(std::string &command, std::vector ¶meters, User *user, bool validated, const std::string &original_line); + ModResult OnPreCommand(std::string &command, std::vector ¶meters, LocalUser *user, bool validated, const std::string &original_line); bool AppliesToMe(User* user, FilterResult* filter, int flags); void ReadFilters(ConfigReader &MyConf); }; @@ -165,7 +174,8 @@ CmdResult CommandFilter::Handle(const std::vector ¶meters, User if (parameters.size() == 1) { /* Deleting a filter */ - if (static_cast(*creator).DeleteFilter(parameters[0])) + Module *me = creator; + if (static_cast(me)->DeleteFilter(parameters[0])) { user->WriteServ("NOTICE %s :*** Removed filter '%s'", user->nick.c_str(), parameters[0].c_str()); ServerInstance->SNO->WriteToSnoMask(IS_LOCAL(user) ? 'a' : 'A', std::string("FILTER: ")+user->nick+" removed filter '"+parameters[0]+"'"); @@ -212,7 +222,9 @@ CmdResult CommandFilter::Handle(const std::vector ¶meters, User { reason = parameters[3]; } - std::pair result = static_cast(*creator).AddFilter(freeform, type, reason, duration, flags); + + Module *me = creator; + std::pair result = static_cast(me)->AddFilter(freeform, type, reason, duration, flags); if (result.first) { user->WriteServ("NOTICE %s :*** Added filter '%s', type '%s'%s%s, flags '%s', reason: '%s'", user->nick.c_str(), freeform.c_str(), @@ -254,6 +266,10 @@ bool ModuleFilter::AppliesToMe(User* user, FilterResult* filter, int iflags) } ModuleFilter::ModuleFilter() : filtcommand(this), RegexEngine(this, "regex") +{ +} + +void ModuleFilter::init() { ServerInstance->AddCommand(&filtcommand); Implementation eventlist[] = { I_OnPreCommand, I_OnStats, I_OnSyncNetwork, I_OnDecodeMetaData, I_OnUserPreMessage, I_OnUserPreNotice, I_OnRehash }; @@ -335,7 +351,7 @@ ModResult ModuleFilter::OnUserPreNotice(User* user,void* dest,int target_type, s return MOD_RES_PASSTHRU; } -ModResult ModuleFilter::OnPreCommand(std::string &command, std::vector ¶meters, User *user, bool validated, const std::string &original_line) +ModResult ModuleFilter::OnPreCommand(std::string &command, std::vector ¶meters, LocalUser *user, bool validated, const std::string &original_line) { flags = 0; if (validated && IS_LOCAL(user)) @@ -437,6 +453,8 @@ void ModuleFilter::OnRehash(User* user) } } std::string newrxengine = "regex/" + MyConf.ReadValue("filteropts", "engine", 0); + if (newrxengine == "regex/") + newrxengine = "regex"; if (RegexEngine.GetProvider() == newrxengine) return; @@ -446,14 +464,14 @@ void ModuleFilter::OnRehash(User* user) RegexEngine.SetProvider(newrxengine); if (!RegexEngine) { - ServerInstance->SNO->WriteGlobalSno('a', "WARNING: Regex engine '%s' is not loaded - Filter functionality disabled until this is corrected.", RegexEngine.GetProvider().c_str()); + ServerInstance->SNO->WriteGlobalSno('a', "WARNING: Regex engine '%s' is not loaded - Filter functionality disabled until this is corrected.", newrxengine.c_str()); } ReadFilters(MyConf); } Version ModuleFilter::GetVersion() { - return Version("Text (spam) filtering", VF_VENDOR | VF_COMMON, RegexEngine); + return Version("Text (spam) filtering", VF_VENDOR | VF_COMMON, RegexEngine ? RegexEngine->name : ""); }