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/clones.pl | |
| parent | 2d080422d79d1fd49d6c5528593ccaaff9bfc583 (diff) | |
| download | scripts.irssi.org-2d0759e6ca5767b48bcc85bf38c2c43d5f0b63b1.tar.bz2 | |
Import scripts from scripts.irssi.org
Diffstat (limited to 'scripts/clones.pl')
| -rw-r--r-- | scripts/clones.pl | 55 | 
1 files changed, 55 insertions, 0 deletions
| diff --git a/scripts/clones.pl b/scripts/clones.pl new file mode 100644 index 0000000..9e55a5f --- /dev/null +++ b/scripts/clones.pl @@ -0,0 +1,55 @@ +use Irssi 20010920.0000 (); +$VERSION = "2.01"; +%IRSSI = ( +    authors     => 'From irssi source, modified by David Leadbeater (dg)', +    name        => 'clones', +    description => '/CLONES - Display clones in the active channel (with added options)', +    license     => 'Same as Irssi', +    url         => 'http://irssi.dgl.yi.org/', +); + +use strict; + +sub cmd_clones { +  my ($data, $server, $channel) = @_; + +  my $min = $data =~ /\d/ ? $data : Irssi::settings_get_int('clones_min_show'); + +  if (!$channel || $channel->{type} ne 'CHANNEL') { +    Irssi::print('No active channel in window'); +    return; +  } + +  my %hostnames = {}; +  my $ident = Irssi::settings_get_bool('clones_host_only'); +   +  foreach my $nick ($channel->nicks()) { +	my $hostname; +	if($ident) { +	   ($hostname = $nick->{host}) =~ s/^[^@]+@//; +	}else{ +	   $hostname = $nick->{host}; +	} + +	$hostnames{$hostname} ||= []; +	push( @{ $hostnames{$hostname} }, $nick->{nick}); +  } + +  my $count = 0; +  foreach my $host (keys %hostnames) { +	next unless ref($hostnames{$host}) eq 'ARRAY'; # sometimes a hash is here +    my @clones = @{ $hostnames{$host} }; +    if (scalar @clones >= $min) { +      $channel->print('Clones:') if ($count == 0); +      $channel->print("$host: " . join(' ',@clones)); +      $count++; +    } +  } + +  $channel->print('No clones in channel') if ($count == 0); +} + +Irssi::command_bind('clones', 'cmd_clones'); +Irssi::settings_add_bool('misc', 'clones_host_only', 1); +Irssi::settings_add_int('misc', 'clones_min_show', 2); + | 
