3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-12-24 03:33:06 +01:00

Improve ban command to accept nick as argument and determine an appropriate banmask

This commit is contained in:
Pragmatic Software 2015-08-22 11:05:53 -07:00
parent d317f2a0c5
commit 050714e359

View File

@ -124,7 +124,8 @@ sub unban_user {
my ($message_account, $hostmask) = $self->{pbot}->{messagehistory}->{database}->find_message_account_by_nick($mask);
if (defined $hostmask) {
$bans = $self->{pbot}->{bantracker}->get_baninfo($hostmask, $channel);
my $nickserv = $self->{pbot}->{messagehistory}->{database}->get_current_nickserv_account($message_account);
$bans = $self->{pbot}->{bantracker}->get_baninfo($hostmask, $channel, $nickserv);
}
}
@ -149,7 +150,21 @@ sub ban_user_timed {
my $self = shift;
my ($mask, $channel, $length) = @_;
$mask .= '!*@*' if $mask !~ m/[\$!@]/;
if ($mask !~ m/[!@]/) {
my ($message_account, $hostmask) = $self->{pbot}->{messagehistory}->{database}->find_message_account_by_nick($mask);
if (defined $hostmask) {
my $nickserv = $self->{pbot}->{messagehistory}->{database}->get_current_nickserv_account($message_account);
if (defined $nickserv && length $nickserv) {
$mask = '$a:' . $nickserv;
} else {
my ($nick, $user, $host) = $hostmask =~ m/([^!]+)!([^@]+)@(.*)/;
$mask = "*!$user\@" . PBot::AntiFlood::address_to_mask($host);
}
} else {
$mask .= '!*@*';
}
}
$self->ban_user($mask, $channel);
if ($length > 0) {
$self->{unban_timeout}->hash->{$channel}->{$mask}{timeout} = gettimeofday + $length;