Irssi – All public messages script

Sends all public messages from all active channels to the window named ‘allpubmsgs’, excluding the currently active window and any channel names in the exclude list. Displays channel names with different colors. I use this script together with the ‘hilightwin.pl’. I have split my irssi terminal into 3 windows, one for the active channel, one for allpubmsg and one for hilightwin. I think this gives a very nice view of whats going on in all channels without having to switch back and forth all the time.

allpubmsgs.pl (1.7 kB)

use strict;
use Irssi;
use Irssi::Irc;

use vars qw($VERSION %IRSSI);

$VERSION = "0.3";
%IRSSI = (
        "authors"       => 'Hersson',
        "homepage"      => 'www.hersson.net',
        "name"          => 'allpubmsgs',
        "description"   => 'Sends all public messsages from all channels to one window, exluding the currently active window and entries in the exclude list. Separates channels with different colors.',
        "license"       => 'Public Domain',
        "changed"       => '2011-28-03'
);


# Change the names and colors to your liking
my %chan_colors = (
    '#archlinux' => '%m',
    '##mac' => '%y',
    '#macosx' => '%r',
    '#freenode' => '%g',
    );
# Channels to exclude
my @exclude_list = qw{#mac1};

sub sig_printtext
{
  my ($dest, $text, $stripped) = @_;

  my $color="%N"; #Set color to default
 
  # If channel is a key in hash change color
  while(my ($key, $value) = each(%chan_colors)){
    if (lc $dest->{target} eq lc $key) {
        $color = $value;
    }
  }

  # Fix so any % char are printed
  $text =~ s/\%/%%/g;
   
    if (grep {m|^$dest->{target}$|} @exclude_list) {} else {
   
        if ($dest->{level} & MSGLEVEL_PUBLIC) {
            my $windowname = Irssi::window_find_name('allpubmsgs');

            my $witem = Irssi::active_win()->{active}; #Get active window
            if (lc $witem->{name} ne lc $dest->{target} ) {  #If msg is not from active window print it to allpubmsg
                $windowname->print($color . $dest->{target} . ":%n " . $text, MSGLEVEL_CLIENTCRAP) if ($windowname);
            }
        }
    }
}

my $windowname = Irssi::window_find_name('allpubmsgs');
if (!$windowname)
{
  Irssi::command("window new");
  Irssi::command("window name allpubmsgs");
}

Irssi::signal_add(
{
  'print text', 'sig_printtext'
}
);
  • Twitter
  • Facebook
  • del.icio.us
  • Digg
  • Google Bookmarks
  • StumbleUpon
  • FriendFeed

Leave a Reply

Your email address will not be published. Required fields are marked *


− three = 1

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>