2001-08-08 18:42:14 -04:00
|
|
|
# /CLONES - Display clones in the active channel
|
2000-10-19 15:41:05 -04:00
|
|
|
|
|
|
|
use Irssi;
|
2001-07-16 16:22:45 -04:00
|
|
|
use strict;
|
2000-10-19 15:41:05 -04:00
|
|
|
|
|
|
|
sub cmd_clones {
|
2001-08-08 18:42:14 -04:00
|
|
|
my ($data, $server, $channel) = @_;
|
2000-10-19 15:41:05 -04:00
|
|
|
|
2001-08-08 18:42:14 -04:00
|
|
|
if (!$channel || $channel->{type} ne "CHANNEL") {
|
|
|
|
Irssi::print("No active channel in window");
|
|
|
|
return;
|
|
|
|
}
|
2000-10-19 15:41:05 -04:00
|
|
|
|
2001-08-08 18:42:14 -04:00
|
|
|
my %hostnames = {};
|
|
|
|
foreach my $nick ($channel->nicks()) {
|
|
|
|
$hostnames{$nick->{host}}++;
|
|
|
|
}
|
2000-10-19 15:41:05 -04:00
|
|
|
|
2001-08-08 18:42:14 -04:00
|
|
|
my $count = 0;
|
|
|
|
foreach my $host (keys %hostnames) {
|
|
|
|
my $clones = $hostnames{$host};
|
|
|
|
if ($clones >= 2) {
|
|
|
|
$channel->print("Clones:") if ($count == 0);
|
|
|
|
$channel->print("$host: $clones");
|
|
|
|
$count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$channel->print("No clones in channel") if ($count == 0);
|
2000-10-19 15:41:05 -04:00
|
|
|
}
|
|
|
|
|
2001-02-13 13:19:59 -05:00
|
|
|
Irssi::command_bind('clones', 'cmd_clones');
|