]> git.madduck.net Git - code/irssi/scripts-bc-bd.git/blobdiff - chanact.pl

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

simplify level assignment
[code/irssi/scripts-bc-bd.git] / chanact.pl
index 10e1c83bcb94e3e65e9dfb6c63957443cf8e2844..44b071af02d874d7e0732a7b90a90b3f05b1ba9a 100644 (file)
@@ -165,6 +165,7 @@ $VERSION = "0.5.11";
 #              * <string> : space-separated list of windows for which to use
 #                              chanact_filter_windowlist_level instead of
 #                              chanact_filter.
+#                              The special string @QUERIES matches all queries.
 #
 # /set chanact_filter_windowlist_level <int>
 #   like chanact_filter for windows in chanact_filter_windowlist. Defaults to
@@ -246,14 +247,22 @@ sub remake() {
                !ref($active) && next;
 
                my $name = $win->get_active_name;
-
-               my $filter_level = Irssi::settings_get_int('chanact_filter');
-               if (grep { $_ eq $name } split ' ', $windowlist) {
-                       # window matches $windowlist, so use
-                       # chanact_filter_windowlist_level to override
-                       # chanact_filter
-                       $filter_level = Irssi::settings_get_int('chanact_filter_windowlist_level');
+               my $type = $active->{type};
+
+               # determine whether we have a match with the windowlist
+               my @windowlist = split ' ', $windowlist;
+               my $match_windowlist = grep { $_ eq $name } @windowlist;
+               if ($type eq 'QUERY') {
+                       # if this is a query, also try to match @QUERIES
+                       $match_windowlist ||= grep { $_ eq '@QUERIES' } @windowlist;
                }
+
+               # choose filter_level according to whether the window is in
+               # the windowlist
+               my $filter_level = $match_windowlist
+                       ? Irssi::settings_get_int('chanact_filter_windowlist_level')
+                       : Irssi::settings_get_int('chanact_filter');
+
                # skip windows with data of level lower than the applicable
                # filter setting
                next if ($win->{data_level} < $filter_level);
@@ -267,7 +276,7 @@ sub remake() {
        
                # check if we should show the mode
                $mode = "";
-               if ($active->{type} eq "CHANNEL") {
+               if ($type eq "CHANNEL") {
                        my $server = $win->{active_server};
                        !ref($server) && next;
 
@@ -492,7 +501,8 @@ Irssi::signal_add_last('window refnum changed', 'refnum_changed');
 # 0.5.11
 #      - added chanact_filter_windowlist, which is a space-separated list of
 #        windows for which to use chanact_filter_windowlist_level instead of
-#        chanact_filter (madduck@madduck.net).
+#        chanact_filter. You can use @QUERIES to match all queries
+#        (madduck@madduck.net).
 #
 # 0.5.10
 #      - fixed irssi crash when using Irssi::print from within remake()