From: martin f. krafft Date: Fri, 17 Sep 2021 05:30:04 +0000 (+0200) Subject: Introduce /ctrlact snoop X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=c97267640985a2d6d894c0d8571a49427912ee43;p=irssi-scripts.irssi.org.git Introduce /ctrlact snoop Snooping on a channel means ctrlact will apply rules as if you had been active on the channel at the time you issue the command — without you actually having to engage and/or let anyone know. Signed-off-by: martin f. krafft --- diff --git a/scripts/ctrlact.pl b/scripts/ctrlact.pl index 4d85caa..ef95d04 100644 --- a/scripts/ctrlact.pl +++ b/scripts/ctrlact.pl @@ -802,7 +802,6 @@ sub cmd_remove { return; } } - if (!defined $pos) { if (!$name) { if ($witem) { @@ -821,6 +820,38 @@ sub cmd_remove { } } +sub cmd_snoop { + my ($data, $server, $witem) = @_; + my $args = parse_args($data); + my $type = $args->{type} // 'channel'; + my $tag = $args->{tag}; + my $name; + + for my $item (@{$args->{rest}}) { + if (!$name) { + $name = $item; + } + else { + error("Unexpected argument: $item"); + return; + } + } + + if (!$name) { + if ($witem) { + $name = $witem->{name}; + $tag = $server->{chatnet} unless $tag; + } + else { + error("No name specified, and no active window item"); + return; + } + } + + $OWN_ACTIVITY{($tag, $name)} = time(); + info("Snooping in on $tag/$name", 1); +} + sub cmd_sleep { my ($data, $server, $witem) = @_; my $args = parse_args($data); @@ -929,6 +960,7 @@ Irssi::command_bind('ctrlact load',\&cmd_load); Irssi::command_bind('ctrlact save',\&cmd_save); Irssi::command_bind('ctrlact add',\&cmd_add); Irssi::command_bind('ctrlact remove',\&cmd_remove); +Irssi::command_bind('ctrlact snoop',\&cmd_snoop); Irssi::command_bind('ctrlact sleep',\&cmd_sleep); Irssi::command_bind('ctrlact list',\&cmd_list); Irssi::command_bind('ctrlact query',\&cmd_query);