diff options
| author | dequis | 2017-02-10 17:59:58 -0300 | 
|---|---|---|
| committer | dequis | 2017-02-13 11:30:17 -0300 | 
| commit | 6ea316d2d74f5b55bc4ef8ef8e43ec8ed0132575 (patch) | |
| tree | 7dccc881d503921ea551677a5d3a53a4961cf012 | |
| parent | eab456c01b8c4393f82dfe95897a90def31aa346 (diff) | |
| download | scripts.irssi.org-6ea316d2d74f5b55bc4ef8ef8e43ec8ed0132575.tar.bz2 | |
hilightwin.pl: Add hilightwin_ignore_targets setting
Setting parser inspired by irssi's own strarray_find_dest()
| -rw-r--r-- | scripts/hilightwin.pl | 26 | 
1 files changed, 24 insertions, 2 deletions
| diff --git a/scripts/hilightwin.pl b/scripts/hilightwin.pl index 7d70317..2e407fa 100644 --- a/scripts/hilightwin.pl +++ b/scripts/hilightwin.pl @@ -11,7 +11,7 @@ use Irssi;  use POSIX;  use vars qw($VERSION %IRSSI);  -$VERSION = "0.04"; +$VERSION = "0.05";  %IRSSI = (      authors     => "Timo \'cras\' Sirainen, Mark \'znx\' Sangster",      contact     => "tss\@iki.fi, znxster\@gmail.com",  @@ -22,6 +22,26 @@ $VERSION = "0.04";      changed     => "Sun May 25 18:59:57 BST 2008"  ); +sub is_ignored { +    my ($dest) = @_; + +    my @ignore = split(' ', Irssi::settings_get_str('hilightwin_ignore_targets')); +    return 0 if (!@ignore); + +    my %targets = map { $_ => 1 } @ignore; + +    return 1 if exists($targets{"*"}); +    return 1 if exists($targets{$dest->{target}}); + +    if ($dest->{server}) { +        my $tag = $dest->{server}->{tag}; +        return 1 if exists($targets{$tag . "/*"}); +        return 1 if exists($targets{$tag . "/" . $dest->{target}}); +    } + +    return 0; +} +  sub sig_printtext {      my ($dest, $text, $stripped) = @_; @@ -33,7 +53,8 @@ sub sig_printtext {      if(          ($dest->{level} & ($opt)) && -        ($dest->{level} & MSGLEVEL_NOHILIGHT) == 0 +        ($dest->{level} & MSGLEVEL_NOHILIGHT) == 0 && +        (!is_ignored($dest))      ) {          my $window = Irssi::window_find_name('hilight'); @@ -49,6 +70,7 @@ my $window = Irssi::window_find_name('hilight');  Irssi::print("Create a window named 'hilight'") if (!$window);  Irssi::settings_add_bool('hilightwin','hilightwin_showprivmsg',1); +Irssi::settings_add_str('hilightwin', 'hilightwin_ignore_targets', '');  Irssi::signal_add('print text', 'sig_printtext'); | 
