From: martin f. krafft Date: Sat, 11 Sep 2021 00:11:37 +0000 (+0200) Subject: Let query work on current item if not otherwise specified X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=198a850ef6df7a2f8f437abe03d0878c0bf85b8e;p=irssi-scripts.irssi.org.git Let query work on current item if not otherwise specified 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 --- diff --git a/scripts/ctrlact.pl b/scripts/ctrlact.pl index c390a5e..8dda1c4 100644 --- a/scripts/ctrlact.pl +++ b/scripts/ctrlact.pl @@ -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); } }