mirror of
https://github.com/irssi/irssi.git
synced 2024-11-03 04:27:19 -05:00
Some cleanups, complains if not run in channel.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1729 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
c54646cad9
commit
8a7fa0f047
@ -1,25 +1,32 @@
|
|||||||
# /CLONES - display real name of nick
|
# /CLONES - Display clones in the active channel
|
||||||
|
|
||||||
use Irssi;
|
use Irssi;
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
sub cmd_clones {
|
sub cmd_clones {
|
||||||
my ($data, $server, $channel) = @_;
|
my ($data, $server, $channel) = @_;
|
||||||
my (%hostnames, $host, @nicks, $nick);
|
|
||||||
|
|
||||||
@nicks = $channel->nicks();
|
if (!$channel || $channel->{type} ne "CHANNEL") {
|
||||||
|
Irssi::print("No active channel in window");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
foreach $nick (@nicks) {
|
my %hostnames = {};
|
||||||
|
foreach my $nick ($channel->nicks()) {
|
||||||
$hostnames{$nick->{host}}++;
|
$hostnames{$nick->{host}}++;
|
||||||
}
|
}
|
||||||
|
|
||||||
$channel->print("Clones:");
|
my $count = 0;
|
||||||
foreach $host (keys %hostnames) {
|
foreach my $host (keys %hostnames) {
|
||||||
my $clones = $hostnames{$host};
|
my $clones = $hostnames{$host};
|
||||||
if ($clones >= 2) {
|
if ($clones >= 2) {
|
||||||
|
$channel->print("Clones:") if ($count == 0);
|
||||||
$channel->print("$host: $clones");
|
$channel->print("$host: $clones");
|
||||||
}
|
$count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$channel->print("No clones in channel") if ($count == 0);
|
||||||
|
}
|
||||||
|
|
||||||
Irssi::command_bind('clones', 'cmd_clones');
|
Irssi::command_bind('clones', 'cmd_clones');
|
||||||
|
Loading…
Reference in New Issue
Block a user