]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
m_filter: Add a warn action for notifying opers while still allowing the message...
authorRobby <robby@chatbelgie.be>
Wed, 21 Nov 2018 00:53:03 +0000 (01:53 +0100)
committerPeter Powell <petpow@saberuk.com>
Wed, 21 Nov 2018 01:15:12 +0000 (01:15 +0000)
Thanks to @H7-25 (Simos) for the idea.

docs/conf/filter.conf.example
docs/conf/helpop-full.conf.example
src/modules/m_filter.cpp

index a389d39e159d0ca0ce0c24ad046f79c296eb3edc..26c68d2c30cb450f58e881b4f37d8ef52438abe4 100644 (file)
@@ -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.
 #
index 17e9ee37dc8422c894cd5e71302ce0c617633da8..f6ebb828b3f22df614d982170b571e680d020920 100644 (file)
@@ -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
index d32a11f21ce58050e232663885cd07a11cf33168..584bfef002fc259afdb57ba019f9fed1283cf6ff 100644 (file)
@@ -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";