]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Add an option to the filter module to exclude registered users from a filter.
authorFilippo Cortigiani <simos@simosnap.org>
Mon, 20 May 2019 13:15:00 +0000 (15:15 +0200)
committerPeter Powell <petpow@saberuk.com>
Mon, 20 May 2019 13:15:00 +0000 (14:15 +0100)
docs/conf/filter.conf.example
docs/conf/helpop.conf.example
src/modules/m_filter.cpp

index f9afc85a82e8e49d2cb960965499fef819e4c62b..fe95687f5b290c04c88240714df26e0960c5b8a9 100644 (file)
@@ -51,8 +51,9 @@
 # P: Block part messages
 # q: Block quit messages
 # o: Don't match against opers
+# r: Don't match against registered users
 # c: Strip color codes from text before trying to match
-# *: Represents all of the above flags
+# *: Represents all of the above flags except r
 # -: Does nothing, a no-op for when you do not want to specify any flags
 
 # Example filters:
index ff9bc4b28a84723f2700de3c2b4a8e2f33c5e8f0..5b89c91f20f172fa7bfca9ee2a9b53195b523c56 100644 (file)
@@ -506,8 +506,9 @@ n    Block private and channel notices
 P    Block part messages
 q    Block quit messages
 o    Don't match against opers
+r    Don't match against registered users
 c    Strip all formatting codes from the message before matching
-*    Represents all of the above flags
+*    Represents all of the above flags except r 
 -    Does nothing, a non-op for when you do not want to specify any
      flags
 
index b2febf810a5ea65a54d80c7cde92fe6d57ca41f5..cad26be62f1a8304364e41befc56cce364e5b7f8 100644 (file)
@@ -26,6 +26,7 @@
 #include "modules/server.h"
 #include "modules/shun.h"
 #include "modules/stats.h"
+#include "modules/account.h"
 
 enum FilterFlags
 {
@@ -58,6 +59,7 @@ class FilterResult
        bool from_config;
 
        bool flag_no_opers;
+       bool flag_no_registered;
        bool flag_part_message;
        bool flag_quit_message;
        bool flag_privmsg;
@@ -79,7 +81,7 @@ class FilterResult
 
        char FillFlags(const std::string &fl)
        {
-               flag_no_opers = flag_part_message = flag_quit_message = flag_privmsg =
+               flag_no_opers = flag_no_registered = flag_part_message = flag_quit_message = flag_privmsg =
                        flag_notice = flag_strip_color = false;
 
                for (std::string::const_iterator n = fl.begin(); n != fl.end(); ++n)
@@ -104,6 +106,9 @@ class FilterResult
                                case 'c':
                                        flag_strip_color = true;
                                break;
+                               case 'r':
+                                       flag_no_registered = true;
+                               break;
                                case '*':
                                        flag_no_opers = flag_part_message = flag_quit_message =
                                                flag_privmsg = flag_notice = flag_strip_color = true;
@@ -129,13 +134,14 @@ class FilterResult
                        flags.push_back('p');
                if (flag_notice)
                        flags.push_back('n');
-
                /* Order is important here, 'c' must be the last char in the string as it is unsupported
                 * on < 2.0.10, and the logic in FillFlags() stops parsing when it ecounters an unknown
                 * character.
                 */
                if (flag_strip_color)
                        flags.push_back('c');
+               if (flag_no_registered)
+                       flags.push_back('r');
 
                if (flags.empty())
                        flags.push_back('-');
@@ -305,8 +311,12 @@ CmdResult CommandFilter::Handle(User* user, const Params& parameters)
 
 bool ModuleFilter::AppliesToMe(User* user, FilterResult* filter, int iflags)
 {
+       const AccountExtItem* accountext = GetAccountExtItem();
+
        if ((filter->flag_no_opers) && user->IsOper())
                return false;
+       if ((filter->flag_no_registered) && accountext && accountext->get(user))
+               return false;
        if ((iflags & FLAG_PRIVMSG) && (!filter->flag_privmsg))
                return false;
        if ((iflags & FLAG_NOTICE) && (!filter->flag_notice))