]> git.99rst.org Git - irssi-scripts.irssi.org.git/commitdiff
Let query work on current item if not otherwise specified
authormartin f. krafft <redacted>
Sat, 11 Sep 2021 00:11:37 +0000 (02:11 +0200)
committermartin f. krafft <redacted>
Fri, 17 Sep 2021 21:41:58 +0000 (23:41 +0200)
If no name is given to /ctrlact query, try to deduce the name of the
active window item, and use that.

Signed-off-by: martin f. krafft <redacted>
scripts/ctrlact.pl

index c390a5ece674c1fc345407ce2d488204c40ce337..8dda1c4997e535331e1a79a749d7dacf6e34bb08 100644 (file)
@@ -801,14 +801,27 @@ sub cmd_list {
 }
 
 sub cmd_query {
-       my ($data, $server, $item) = @_;
+       my ($data, $server, $witem) = @_;
        my $args = parse_args($data);
        my $type = $args->{type} // 'channel';
        my $tag = $args->{tag} // '*';
        my $max = $args->{max};
-       foreach my $name (@{$args->{rest}}) {
+       my @words = @{$args->{rest}};
+
+       if (!@words) {
+               if ($witem) {
+                       push @words, $witem->{name};
+                       $tag = $server->{chatnet} unless $tag ne '*';
+               }
+               else {
+                       error("No name specified, and no active window item");
+                       return;
+               }
+       }
+
+       foreach my $name (@words) {
                my ($t, $tt, $match) = get_specific_threshold($type, $name, $tag);
-               printf CLIENTCRAP "ctrlact $type map: %s %*s → %d (%s, match:%s)", $tag, $max, $name, $t, $tt, $match;
+               info(sprintf("%7s: %7s %-22s → %-8s  match: %s", $type, $tag, $name, $tt, $match), 1);
        }
 }
 
git clone https://git.99rst.org/PROJECT