dotfiles

My personal shell configs and stuff
git clone git://git.alex.balgavy.eu/dotfiles.git
Log | Files | Refs | Submodules | README | LICENSE

hilightwin.pl (2610B)


      1 #
      2 # Print hilighted messages & private messages to window named "hilight" for
      3 # irssi 0.7.99 by Timo Sirainen
      4 #
      5 # Modded a tiny bit by znx to stop private messages entering the hilighted
      6 # window (can be toggled) and to put up a timestamp.
      7 #
      8 # Changed a little by rummik to optionally show network name. Enable with
      9 # `/set hilightwin_show_network on`
     10 #
     11 
     12 use strict;
     13 use Irssi;
     14 use POSIX;
     15 use vars qw($VERSION %IRSSI);
     16 
     17 $VERSION = "1.00";
     18 %IRSSI = (
     19     authors     => "Timo \'cras\' Sirainen, Mark \'znx\' Sangster, Kimberly \'rummik\' Zick",
     20     contact     => "tss\@iki.fi, znxster\@gmail.com, git\@zick.kim",
     21     name        => "hilightwin",
     22     description => "Print hilighted messages to window named \"hilight\"",
     23     license     => "Public Domain",
     24     url         => "http://irssi.org/",
     25     changed     => "Thu Apr  6 15:30:25 EDT 2017"
     26 );
     27 
     28 sub is_ignored {
     29     my ($dest) = @_;
     30 
     31     my @ignore = split(' ', Irssi::settings_get_str('hilightwin_ignore_targets'));
     32     return 0 if (!@ignore);
     33 
     34     my %targets = map { $_ => 1 } @ignore;
     35 
     36     return 1 if exists($targets{"*"});
     37     return 1 if exists($targets{$dest->{target}});
     38 
     39     if ($dest->{server}) {
     40         my $tag = $dest->{server}->{tag};
     41         return 1 if exists($targets{$tag . "/*"});
     42         return 1 if exists($targets{$tag . "/" . $dest->{target}});
     43     }
     44 
     45     return 0;
     46 }
     47 
     48 sub sig_printtext {
     49     my ($dest, $text, $stripped) = @_;
     50 
     51     my $opt = MSGLEVEL_HILIGHT;
     52     my $shownetwork = Irssi::settings_get_bool('hilightwin_show_network');
     53 
     54     if(Irssi::settings_get_bool('hilightwin_showprivmsg')) {
     55         $opt = MSGLEVEL_HILIGHT|MSGLEVEL_MSGS;
     56     }
     57     
     58     if(
     59         ($dest->{level} & ($opt)) &&
     60         ($dest->{level} & MSGLEVEL_NOHILIGHT) == 0 &&
     61         (!is_ignored($dest))
     62     ) {
     63         my $window = Irssi::window_find_name('hilight');
     64         
     65         if ($dest->{level} & MSGLEVEL_PUBLIC) {
     66             $text = $dest->{target}.": ".$text;
     67             $text = $dest->{server}->{tag} . "/" . $text if ($shownetwork);
     68         } elsif ($shownetwork) {
     69             $text = $dest->{server}->{tag} . ": " . $text;
     70         }
     71         $text =~ s/%/%%/g;
     72         $window->print($text, MSGLEVEL_CLIENTCRAP) if ($window);
     73     }
     74 }
     75 
     76 my $window = Irssi::window_find_name('hilight');
     77 Irssi::print("Create a window named 'hilight'") if (!$window);
     78 
     79 Irssi::settings_add_bool('hilightwin','hilightwin_showprivmsg',1);
     80 Irssi::settings_add_str('hilightwin', 'hilightwin_ignore_targets', '');
     81 Irssi::settings_add_bool('hilightwin','hilightwin_show_network', 0);
     82 
     83 Irssi::signal_add('print text', 'sig_printtext');
     84 
     85 # vim:set ts=4 sw=4 et: