X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_filter.cpp;h=8e43d276755078620d738d726bfad1eb296bd7e8;hb=91e0af0fc4889f20d2f63426f8fe379674fc0393;hp=9acce033a564bec659e09cda20a19c6c37e5a051;hpb=f62654a6859998f9d63eb22702c572d5ebcff15c;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_filter.cpp b/src/modules/m_filter.cpp index 9acce033a..8e43d2767 100644 --- a/src/modules/m_filter.cpp +++ b/src/modules/m_filter.cpp @@ -146,9 +146,9 @@ class CommandFilter : public Command flags_needed = 'o'; this->syntax = " [] :"; } - CmdResult Handle(const std::vector&, User*); + CmdResult Handle(const std::vector& , User* ) CXX11_OVERRIDE; - RouteDescriptor GetRouting(User* user, const std::vector& parameters) + RouteDescriptor GetRouting(User* user, const std::vector& parameters) CXX11_OVERRIDE { return ROUTE_BROADCAST; } @@ -156,7 +156,7 @@ class CommandFilter : public Command class ModuleFilter : public Module { - typedef std::set ExemptTargetSet; + typedef insp::flat_set ExemptTargetSet; bool initing; RegexFactory* factory; @@ -176,7 +176,7 @@ class ModuleFilter : public Module ExemptTargetSet exemptednicks; ModuleFilter(); - CullResult cull(); + CullResult cull() CXX11_OVERRIDE; ModResult OnUserPreMessage(User* user, void* dest, int target_type, std::string& text, char status, CUList& exempt_list, MessageType msgtype) CXX11_OVERRIDE; FilterResult* FilterMatch(User* user, const std::string &text, int flags); bool DeleteFilter(const std::string &freeform); @@ -187,7 +187,7 @@ class ModuleFilter : public Module FilterResult DecodeFilter(const std::string &data); void OnSyncNetwork(ProtocolInterface::Server& server) CXX11_OVERRIDE; void OnDecodeMetaData(Extensible* target, const std::string &extname, const std::string &extdata) CXX11_OVERRIDE; - ModResult OnStats(char symbol, User* user, string_list &results) CXX11_OVERRIDE; + ModResult OnStats(Stats::Context& stats) CXX11_OVERRIDE; ModResult OnPreCommand(std::string &command, std::vector ¶meters, LocalUser *user, bool validated, const std::string &original_line) CXX11_OVERRIDE; void OnUnloadModule(Module* mod) CXX11_OVERRIDE; bool AppliesToMe(User* user, FilterResult* filter, int flags); @@ -343,14 +343,14 @@ ModResult ModuleFilter::OnUserPreMessage(User* user, void* dest, int target_type { ServerInstance->SNO->WriteGlobalSno('a', "FILTER: "+user->nick+" had their message filtered, target was "+target+": "+f->reason); if (target_type == TYPE_CHANNEL) - user->WriteNumeric(ERR_CANNOTSENDTOCHAN, "%s :Message to channel blocked and opers notified (%s)", target.c_str(), f->reason.c_str()); + user->WriteNumeric(ERR_CANNOTSENDTOCHAN, target, InspIRCd::Format("Message to channel blocked and opers notified (%s)", f->reason.c_str())); else user->WriteNotice("Your message to "+target+" was blocked and opers notified: "+f->reason); } else if (f->action == FA_SILENT) { if (target_type == TYPE_CHANNEL) - user->WriteNumeric(ERR_CANNOTSENDTOCHAN, "%s :Message to channel blocked (%s)", target.c_str(), f->reason.c_str()); + user->WriteNumeric(ERR_CANNOTSENDTOCHAN, target, InspIRCd::Format("Message to channel blocked (%s)", f->reason.c_str())); else user->WriteNotice("Your message to "+target+" was blocked: "+f->reason); } @@ -632,17 +632,15 @@ std::pair ModuleFilter::AddFilter(const std::string &freeform bool ModuleFilter::StringToFilterAction(const std::string& str, FilterAction& fa) { - irc::string s(str.c_str()); - - if (s == "gline") + if (stdalgo::string::equalsci(str, "gline")) fa = FA_GLINE; - else if (s == "block") + else if (stdalgo::string::equalsci(str, "block")) fa = FA_BLOCK; - else if (s == "silent") + else if (stdalgo::string::equalsci(str, "silent")) fa = FA_SILENT; - else if (s == "kill") + else if (stdalgo::string::equalsci(str, "kill")) fa = FA_KILL; - else if (s == "none") + else if (stdalgo::string::equalsci(str, "none")) fa = FA_NONE; else return false; @@ -693,21 +691,21 @@ void ModuleFilter::ReadFilters() } } -ModResult ModuleFilter::OnStats(char symbol, User* user, string_list &results) +ModResult ModuleFilter::OnStats(Stats::Context& stats) { - if (symbol == 's') + if (stats.GetSymbol() == 's') { for (std::vector::iterator i = filters.begin(); i != filters.end(); i++) { - results.push_back("223 "+user->nick+" :"+RegexEngine.GetProvider()+":"+i->freeform+" "+i->GetFlags()+" "+FilterActionToString(i->action)+" "+ConvToStr(i->gline_time)+" :"+i->reason); + stats.AddRow(223, RegexEngine.GetProvider()+":"+i->freeform+" "+i->GetFlags()+" "+FilterActionToString(i->action)+" "+ConvToStr(i->gline_time)+" :"+i->reason); } for (ExemptTargetSet::const_iterator i = exemptedchans.begin(); i != exemptedchans.end(); ++i) { - results.push_back("223 "+user->nick+" :EXEMPT "+(*i)); + stats.AddRow(223, "EXEMPT "+(*i)); } for (ExemptTargetSet::const_iterator i = exemptednicks.begin(); i != exemptednicks.end(); ++i) { - results.push_back("223 "+user->nick+" :EXEMPT "+(*i)); + stats.AddRow(223, "EXEMPT "+(*i)); } } return MOD_RES_PASSTHRU;