1use vars qw($VERSION %IRSSI); 2 3use Irssi 20020120; 4$VERSION = "1.2"; 5%IRSSI = ( 6 authors => "Michiel", 7 contact => "michiel\@dotgeek.org", 8 name => "List nicks in channel", 9 description => "BitchX /u clone. Use /u <regex> to show all nicks (including ident\@host) matching regex in the current channel.", 10 license => "GNU GPL", 11 url => "http://otoria.freecode.nl/~michiel/u.pl", 12 changed => "Thu Jun 3 11:04:27 CEST 2004", 13); 14 15 16sub cmd_u 17{ 18 my ($data, $server, $channel) = @_; 19 my @nicks; 20 my $space; 21 my $msg; 22 my $match; 23 my $nick; 24 25 if ($channel->{type} ne "CHANNEL") 26 { 27 Irssi::print("You are not on a channel"); 28 return; 29 } 30 31 @nicks = $channel->nicks(); 32 33 $space = ' 'x50; 34 35 foreach $nick (@nicks) 36 { 37 38 # user status? 39 $msg = ($nick->{serverop} ? '[*' : '[ '); 40 $msg .= ($nick->{other} ? chr($nick->{other}) : ($nick->{op} ? '@' : ($nick->{halfop} ? '%' : ($nick->{voice} ? '+' : ' ')))); 41 42 # if nick is too long, cut it off 43 if (length($nick->{nick}) > 10) 44 { 45 $msg .= substr($nick->{nick}, 0, 10)."] "; 46 } 47 else # if it is too short, add some spaces 48 { 49 $msg .= $nick->{nick}.substr($space, 0, 10-length($nick->{nick}))."] "; 50 } 51 52 # if host is too long, cut it off 53 if (length($nick->{host}) > 50) 54 { 55 $msg .= '['.substr($nick->{host}, 0, 50).']'; 56 } 57 else # if it is too short, add some spaces 58 { 59 $msg .= '['.$nick->{host}.substr($space, 0, 50-length($nick->{host})).']'; 60 } 61 62 $match = $nick->{nick}.'!'.$nick->{host}; # For regexp matching 63 64 $channel->print($msg) if $match =~ /$data/i; 65 66 } 67} 68 69Irssi::command_bind('u','cmd_u'); 70