From 705853459e7170316fde62f25e40398b35bd4870 Mon Sep 17 00:00:00 2001 From: Robby Date: Wed, 21 Nov 2018 01:53:03 +0100 Subject: m_filter: Add a warn action for notifying opers while still allowing the message through. Thanks to @H7-25 (Simos) for the idea. --- docs/conf/filter.conf.example | 3 +++ docs/conf/helpop-full.conf.example | 3 +++ src/modules/m_filter.cpp | 18 ++++++++++++++---- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/docs/conf/filter.conf.example b/docs/conf/filter.conf.example index a389d39e1..26c68d2c3 100644 --- a/docs/conf/filter.conf.example +++ b/docs/conf/filter.conf.example @@ -10,6 +10,9 @@ # # Valid actions for 'action' are: # +# warn This allows the line and sends out a notice to all opers +# with +s. +# # block This blocks the line, sends out a notice to all opers with # +s and informs the user that their message was blocked. # diff --git a/docs/conf/helpop-full.conf.example b/docs/conf/helpop-full.conf.example index 17e9ee37d..f6ebb828b 100644 --- a/docs/conf/helpop-full.conf.example +++ b/docs/conf/helpop-full.conf.example @@ -487,11 +487,14 @@ Valid FILTER Actions -------------------- None Does nothing +Warn Lets the message through and informs +s IRCops of the message + and all relevant info Block Blocks message and informs +s IRCops of the blocked message and all relevant info Silent Blocks message, but does not notify IRCops Kill Kills the user Gline Glines the user for the specified duration +Zline Zlines the user for the specified duration Shun Shuns the user for the specified duration (requires the shun module) Valid FILTER Flags diff --git a/src/modules/m_filter.cpp b/src/modules/m_filter.cpp index d32a11f21..584bfef00 100644 --- a/src/modules/m_filter.cpp +++ b/src/modules/m_filter.cpp @@ -39,6 +39,7 @@ enum FilterAction { FA_GLINE, FA_ZLINE, + FA_WARN, FA_BLOCK, FA_SILENT, FA_KILL, @@ -240,9 +241,9 @@ CmdResult CommandFilter::Handle(User* user, const Params& parameters) if (!ModuleFilter::StringToFilterAction(parameters[1], type)) { if (ServerInstance->XLines->GetFactory("SHUN")) - user->WriteNotice("*** Invalid filter type '" + parameters[1] + "'. Supported types are 'gline', 'zline', 'none', 'block', 'silent', 'kill', and 'shun'."); + user->WriteNotice("*** Invalid filter type '" + parameters[1] + "'. Supported types are 'gline', 'zline', 'none', 'warn', 'block', 'silent', 'kill', and 'shun'."); else - user->WriteNotice("*** Invalid filter type '" + parameters[1] + "'. Supported types are 'gline', 'zline', 'none', 'block', 'silent', and 'kill'."); + user->WriteNotice("*** Invalid filter type '" + parameters[1] + "'. Supported types are 'gline', 'zline', 'none', 'warn', 'block', 'silent', and 'kill'."); return CMD_FAILURE; } @@ -363,6 +364,12 @@ ModResult ModuleFilter::OnUserPreMessage(User* user, const MessageTarget& msgtar target = t->name; } + if (f->action == FA_WARN) + { + ServerInstance->SNO->WriteGlobalSno('f', InspIRCd::Format("WARNING: %s's message to %s matched %s (%s)", + user->nick.c_str(), target.c_str(), f->freeform.c_str(), f->reason.c_str())); + return MOD_RES_PASSTHRU; + } if (f->action == FA_BLOCK) { ServerInstance->SNO->WriteGlobalSno('f', InspIRCd::Format("%s had their message to %s filtered as it matched %s (%s)", @@ -478,10 +485,10 @@ ModResult ModuleFilter::OnPreCommand(std::string& command, CommandBase::Params& /* We cant block a part or quit, so instead we change the reason to 'Reason filtered' */ parameters[parting ? 1 : 0] = "Reason filtered"; - /* We're blocking, OR theyre quitting and its a KILL action + /* We're warning or blocking, OR theyre quitting and its a KILL action * (we cant kill someone whos already quitting, so filter them anyway) */ - if ((f->action == FA_BLOCK) || (((!parting) && (f->action == FA_KILL))) || (f->action == FA_SILENT)) + if ((f->action == FA_WARN) || (f->action == FA_BLOCK) || (((!parting) && (f->action == FA_KILL))) || (f->action == FA_SILENT)) { return MOD_RES_PASSTHRU; } @@ -737,6 +744,8 @@ bool ModuleFilter::StringToFilterAction(const std::string& str, FilterAction& fa fa = FA_GLINE; else if (stdalgo::string::equalsci(str, "zline")) fa = FA_ZLINE; + else if (stdalgo::string::equalsci(str, "warn")) + fa = FA_WARN; else if (stdalgo::string::equalsci(str, "block")) fa = FA_BLOCK; else if (stdalgo::string::equalsci(str, "silent")) @@ -759,6 +768,7 @@ std::string ModuleFilter::FilterActionToString(FilterAction fa) { case FA_GLINE: return "gline"; case FA_ZLINE: return "zline"; + case FA_WARN: return "warn"; case FA_BLOCK: return "block"; case FA_SILENT: return "silent"; case FA_KILL: return "kill"; -- cgit v1.2.3