mirror of
https://github.com/pragma-/pbot.git
synced 2025-05-03 13:17:33 +02:00
Add -h option to aka
command to show full hostmasks
This commit is contained in:
parent
2a8d9152f5
commit
077978bfa1
@ -65,29 +65,53 @@ sub add_message {
|
|||||||
sub list_also_known_as {
|
sub list_also_known_as {
|
||||||
my ($self, $from, $nick, $user, $host, $arguments) = @_;
|
my ($self, $from, $nick, $user, $host, $arguments) = @_;
|
||||||
|
|
||||||
|
my $usage = "Usage: aka [-h] <nick>";
|
||||||
|
|
||||||
if(not length $arguments) {
|
if(not length $arguments) {
|
||||||
return "Usage: aka <nick>";
|
return $usage;
|
||||||
}
|
}
|
||||||
|
|
||||||
my @akas = $self->{database}->get_also_known_as($arguments);
|
my $getopt_error;
|
||||||
|
local $SIG{__WARN__} = sub {
|
||||||
|
$getopt_error = shift;
|
||||||
|
chomp $getopt_error;
|
||||||
|
};
|
||||||
|
|
||||||
|
my $show_hostmasks;
|
||||||
|
my ($ret, $args) = GetOptionsFromString($arguments,
|
||||||
|
'h' => \$show_hostmasks);
|
||||||
|
|
||||||
|
return "$getopt_error -- $usage" if defined $getopt_error;
|
||||||
|
return "Too many arguments -- $usage" if @$args > 1;
|
||||||
|
return "Missing argument -- $usage" if @$args != 1;
|
||||||
|
|
||||||
|
my @akas = $self->{database}->get_also_known_as(@$args[0]);
|
||||||
if(@akas) {
|
if(@akas) {
|
||||||
my $result = "$arguments also known as: ";
|
my $result = "@$args[0] also known as: ";
|
||||||
|
|
||||||
my %uniq;
|
my %uniq;
|
||||||
foreach my $aka (@akas) {
|
foreach my $aka (@akas) {
|
||||||
my ($nick) = $aka =~ /^([^!]+)!/;
|
if (not $show_hostmasks) {
|
||||||
$uniq{$nick} = $nick;
|
my ($nick) = $aka =~ /^([^!]+)!/;
|
||||||
|
$uniq{$nick} = $nick;
|
||||||
|
} else {
|
||||||
|
$uniq{$aka} = $aka;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
my $sep = "";
|
my $sep = "";
|
||||||
foreach my $aka (sort keys %uniq) {
|
foreach my $aka (sort keys %uniq) {
|
||||||
next if $aka =~ /^Guest\d+$/;
|
next if $aka =~ /^Guest\d+(!.*)?$/;
|
||||||
$result .= "$sep$aka";
|
$result .= "$sep$aka";
|
||||||
$sep = ", ";
|
if ($show_hostmasks) {
|
||||||
|
$sep = ",\n";
|
||||||
|
} else {
|
||||||
|
$sep = ", ";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
} else {
|
} else {
|
||||||
return "I don't know anybody named $arguments.";
|
return "I don't know anybody named @$args[0].";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,8 +13,8 @@ use warnings;
|
|||||||
# These are set automatically by the build/commit script
|
# These are set automatically by the build/commit script
|
||||||
use constant {
|
use constant {
|
||||||
BUILD_NAME => "PBot",
|
BUILD_NAME => "PBot",
|
||||||
BUILD_REVISION => 732,
|
BUILD_REVISION => 733,
|
||||||
BUILD_DATE => "2014-07-12",
|
BUILD_DATE => "2014-07-13",
|
||||||
};
|
};
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user