# # $Id: ego.pl,v 1.20 2007/10/18 01:22:07 nugget Exp $ # # Ego Window # Original Version by David McNett # # This script detects any message or action that contains one # of the specified keywords and drops that line into your # window named 'ego'. If the ego window is always visible, # this allows you to notice if a conversation in a hidden # window turns to a subject you want to participate in. # my @keywords = ('nugget','miata','nuggie','roadster','slacker','rumpus','porsche','911'); use Irssi; use Irssi::Irc; use strict; my $cvsid = '$Id: ego.pl,v 1.20 2007/10/18 01:22:07 nugget Exp $'; my $version = '?'; if( $cvsid =~ /\$Id: [^ ]+ (\d+\.\d+)/ ) { $version = $1; } sub event_ego { my ($server, $data, $nick, $address) = @_; my ($target, $text) = split(/ :/, $data, 2); my $mynick = $server->{'nick'}; if($target =~ /^$mynick$/i) { my $outbuf = "[$nick->] $text"; my $linelen = Irssi::window_find_name('ego')->{'width'}; my $curlen = (length($outbuf)) + 8; if($curlen > $linelen) { $outbuf = substr($outbuf,0,($linelen-11)) . '...'; } Irssi::window_find_name('ego')->print("%c$outbuf", MSGLEVEL_NO_ACT+MSGLEVEL_CLIENTCRAP); } else { for(my $i=0; $i<@keywords; $i++) { my $key = $keywords[$i]; if(($nick ne 'dctievent') and ($nick ne 'udevent')) { if($text =~ /$key/i) { my $outbuf = "[$nick/$target] $text"; my $linelen = Irssi::window_find_name('ego')->{'width'}; my $curlen = (length($outbuf)) + 8; if($curlen > $linelen) { $outbuf = substr($outbuf,0,($linelen-11)) . '...'; } Irssi::window_find_name('ego')->print("%c$outbuf", MSGLEVEL_CLIENTCRAP+MSGLEVEL_NO_ACT); $i = @keywords; } } } } } Irssi::signal_add("event privmsg", "event_ego"); Irssi::window_find_name('ego')->print("EGO Window v$version loaded...", MSGLEVEL_PUBLIC);