]> git.99rst.org Git - irssi-scripts.irssi.org.git/commitdiff
Introduce /ctrlact snoop
authormartin f. krafft <redacted>
Fri, 17 Sep 2021 05:30:04 +0000 (07:30 +0200)
committermartin f. krafft <redacted>
Fri, 17 Sep 2021 21:41:58 +0000 (23:41 +0200)
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 <redacted>
scripts/ctrlact.pl

index 4d85caa0c18f1cc32721bb69caf040a34d5e9ec1..ef95d04300a699d26b6e49e5f63be184f5d9a2e9 100644 (file)
@@ -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);
git clone https://git.99rst.org/PROJECT