2001-08-08 18:42:14 -04:00
|
|
|
# /CLONES - Display clones in the active channel
|
2001-12-15 08:22:38 -05:00
|
|
|
# Modified by Roi Dayan. dejavo@punkass.com
|
2000-10-19 15:41:05 -04:00
|
|
|
|
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) = @_;
|
2001-12-15 08:22:38 -05:00
|
|
|
my $min_show_count = ($data =~ /^[0-9]+$/) ? $data : 2;
|
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 = {};
|
2001-12-15 08:22:38 -05:00
|
|
|
my %hostnicks = {};
|
|
|
|
my @hosttmp = {};
|
2001-08-08 18:42:14 -04:00
|
|
|
foreach my $nick ($channel->nicks()) {
|
2001-12-15 08:22:38 -05:00
|
|
|
my @hosttmp = split(/\@/,$nick->{host});
|
|
|
|
$hostnames{$hosttmp[1]}++;
|
|
|
|
$hostnicks{$hosttmp[1]} = $hostnicks{$hosttmp[1]}.$hostnames{$hosttmp[1]}.". ".$nick->{nick}."!".$nick->{host}."\n";
|
|
|
|
$hostnicks{$hosttmp[1]} =~ s/^,//;
|
|
|
|
# $hostnicks{$hosttmp[1]} =~ s/\n$//;
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach my $nick (keys %hostnicks) {
|
|
|
|
$hostnicks{$nick} =~ s/\n$//;
|
2001-08-08 18:42:14 -04:00
|
|
|
}
|
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};
|
2001-12-15 08:22:38 -05:00
|
|
|
if ($clones >= $min_show_count) {
|
2001-08-08 18:42:14 -04:00
|
|
|
$channel->print("Clones:") if ($count == 0);
|
2001-12-15 08:22:38 -05:00
|
|
|
$channel->print("$host: $clones $hostnicks{$host}");
|
2001-08-08 18:42:14 -04:00
|
|
|
$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');
|