diff options
| author | Alexander Færøy | 2014-05-31 13:10:46 +0200 | 
|---|---|---|
| committer | Alexander Færøy | 2014-05-31 13:10:46 +0200 | 
| commit | 2d0759e6ca5767b48bcc85bf38c2c43d5f0b63b1 (patch) | |
| tree | 1c5e6d817c88e67b46e216a50e0aef5428bf63df /scripts/u.pl | |
| parent | 2d080422d79d1fd49d6c5528593ccaaff9bfc583 (diff) | |
| download | scripts.irssi.org-2d0759e6ca5767b48bcc85bf38c2c43d5f0b63b1.tar.bz2 | |
Import scripts from scripts.irssi.org
Diffstat (limited to 'scripts/u.pl')
| -rw-r--r-- | scripts/u.pl | 69 | 
1 files changed, 69 insertions, 0 deletions
| diff --git a/scripts/u.pl b/scripts/u.pl new file mode 100644 index 0000000..a552da7 --- /dev/null +++ b/scripts/u.pl @@ -0,0 +1,69 @@ +use vars qw($VERSION %IRSSI); + +use Irssi 20020120; +$VERSION = "1.2"; +%IRSSI = ( +    authors	=> "Michiel", +    contact	=> "michiel\@dotgeek.org", +    name	=> "List nicks in channel", +    description	=> "BitchX /u clone. Use /u <regex> to show all nicks (including ident\@host) matching regex in the current channel.", +    license	=> "GNU GPL", +    url		=> "http://otoria.freecode.nl/~michiel/u.pl", +    changed	=> "Thu Jun  3 11:04:27 CEST 2004", +); + + +sub cmd_u +{ +	my ($data, $server, $channel) = @_; +	my @nicks; +	my $space; +	my $msg; +	my $match; +	my $nick; + +	if ($channel->{type} ne "CHANNEL") +	{ +		Irssi::print("You are not on a channel"); +		return; +	} + +	@nicks = $channel->nicks(); + +	$space = ' 'x50; + +	foreach $nick (@nicks) +	{ + +		# user status? +		$msg = ($nick->{serverop} ? '[*' : '[ '); +		$msg .= ($nick->{other} ? chr($nick->{other}) : ($nick->{op} ? '@' : ($nick->{halfop} ? '%' : ($nick->{voice} ? '+' : ' ')))); + +		# if nick is too long, cut it off +		if (length($nick->{nick}) > 10) +		{ +			$msg .= substr($nick->{nick}, 0, 10)."] "; +		} +		else # if it is too short, add some spaces +		{ +			$msg .= $nick->{nick}.substr($space, 0, 10-length($nick->{nick}))."] "; +		} + +		# if host is too long, cut it off +		if (length($nick->{host}) > 50) +		{ +			$msg .= '['.substr($nick->{host}, 0, 50).']'; +		} +		else # if it is too short, add some spaces +		{ +			$msg .= '['.$nick->{host}.substr($space, 0, 50-length($nick->{host})).']'; +		} +		 +		$match = $nick->{nick}.'!'.$nick->{host}; # For regexp matching + +		$channel->print($msg) if $match =~ /$data/i; +		 +	} +} + +Irssi::command_bind('u','cmd_u'); | 
