summaryrefslogtreecommitdiffstats
path: root/scripts/act.pl
blob: 21cbbbbb8030cf569251c657c5398c28fbaae451 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/perl
# resets window activity status
#  by c0ffee 
#    - http://www.penguin-breeder.org/irssi/

#<scriptinfo>
use strict;
use vars qw($VERSION %IRSSI);

use Irssi 20020120;
$VERSION = "0.15";
%IRSSI = (
    authors	=> "c0ffee",
    contact	=> "c0ffee\@penguin-breeder.org",
    name	=> "Reset window activity status",
    description	=> "Reset window activity status. defines command /act",
    license	=> "Public Domain",
    url		=> "http://www.penguin-breeder.org/irssi/",
    changed	=> "Thu Apr 16 15:55:05 BST 2015",
);
#</scriptinfo>

#
# /ACT [PUBLIC|ALL]
#
# /ACT without parameters marks windows as non-active where no
# public talk occured.
#
# /ACT PUBLIC also removes those where no nick hilight was triggered
#
# /ACT ALL sets all windows as non-active

Irssi::command_bind 'act' => sub {
    my ( $data, $server, $item ) = @_;
    $data =~ s/\s+$//g;
    if ($data) {
      Irssi::command_runsub('act', $data, $server, $item);
    }
    else {
      _act(1);
    }
};

Irssi::command_bind('act public', sub { _act(2); });
Irssi::command_bind('act all', sub { _act(3); });

sub _act {
  my($level) = @_;
  for (Irssi::windows()) {
    if ($_->{data_level} <= $level) {
      Irssi::signal_emit("window dehilight", $_);
    }
  }
}