1#!/usr/local/bin/perl 2 3# (c) Matth�us 'JonnyBG' Wander <jbg@swznet.de> 4 5# Usage: Simply use /list as you always do 6 7use strict; 8use vars qw($VERSION %IRSSI); 9 10$VERSION = '1.00'; 11%IRSSI = ( 12 authors => 'Matth�us \'JonnyBG\' Wander', 13 contact => 'jbg@swznet.de', 14 name => 'xlist', 15 description => 'Better readable listing of channel names', 16 license => 'GPLv2', 17 url => 'http://jbg.swznet.de/xlist/', 18); 19 20use Irssi; 21 22my %xlist = (); 23 24sub collect { 25 my ($server, $data) = @_; 26 27 my (undef, $channel, $users, $topic) = split(/\s/, $data, 4); 28 $topic = substr($topic, 1); 29 30 $xlist{$channel} = [ $users, $topic ]; 31} 32 33sub list { 34 my ($data, $server) = @_; 35 %xlist = (); 36 37 print "%K[%n".$server->{'tag'}."%K]%n %B<-->%n xlist"; 38} 39 40sub show { 41 my ($server) = @_; 42 my ($printstring, $channel); 43 44 for $channel ( sort { ${ $xlist{$b} }[0] <=> ${ $xlist{$a} }[0] } keys %xlist ) { 45 $printstring = "%K[%n" . $server->{'tag'} . "%K]%n " . 46 sprintf("%4d", ${ $xlist{$channel} }[0]) . 47 " " . $channel; 48 49 if (length ${ $xlist{$channel} }[1] > 0 ) { 50 $printstring .= " %B->%n ". ${ $xlist{$channel} }[1]; 51 } 52 53 print $printstring; 54 } 55 56 %xlist = (); 57 58 print "%K[%n".$server->{'tag'}."%K]%n %B<-->%n End of xlist"; 59} 60 61Irssi::command_bind('list', \&list); 62Irssi::signal_add('event 322', \&collect); 63Irssi::signal_add('event 323', \&show); 64 65print "%B<-->%n xlist v$VERSION: Simply use /list as you always do"; 66