mirror of
https://github.com/pragma-/pbot.git
synced 2024-12-24 11:42:35 +01:00
Add "forever" as valid parsedate option
`ban` command will not save ban to unban-timeouts if "forever" is used.
This commit is contained in:
parent
3be6755a61
commit
b5c10b73d9
@ -65,10 +65,16 @@ sub ban_user {
|
||||
}
|
||||
|
||||
my $botnick = $self->{pbot}->{registry}->get_value('irc', 'botnick');
|
||||
return "" if $target =~ /\Q$botnick\E/i;
|
||||
return "I don't think so." if $target =~ /^\Q$botnick\E!/i;
|
||||
|
||||
$self->{pbot}->{chanops}->ban_user_timed($target, $channel, $length);
|
||||
$length = duration($length);
|
||||
|
||||
if ($length > 0) {
|
||||
$length = duration($length);
|
||||
} else {
|
||||
$length = 'all eternity';
|
||||
}
|
||||
|
||||
return "/msg $nick $target banned in $channel for $length";
|
||||
}
|
||||
|
||||
|
@ -116,10 +116,12 @@ sub ban_user_timed {
|
||||
my $self = shift;
|
||||
my ($mask, $channel, $length) = @_;
|
||||
|
||||
$mask .= '!*@*' if $mask !~ m/[!@]/;
|
||||
$mask .= '!*@*' if $mask !~ m/[\$!@]/;
|
||||
$self->ban_user($mask, $channel);
|
||||
$self->{unban_timeout}->hash->{$channel}->{$mask}{timeout} = gettimeofday + $length;
|
||||
$self->{unban_timeout}->save;
|
||||
if ($length > 0) {
|
||||
$self->{unban_timeout}->hash->{$channel}->{$mask}{timeout} = gettimeofday + $length;
|
||||
$self->{unban_timeout}->save;
|
||||
}
|
||||
}
|
||||
|
||||
sub join_channel {
|
||||
|
@ -20,7 +20,9 @@ sub parsedate {
|
||||
|
||||
my $seconds = 0;
|
||||
foreach my $input (@inputs) {
|
||||
return -1 if $input =~ m/forever/i;
|
||||
$input .= ' seconds' if $input =~ m/^\d+$/;
|
||||
|
||||
my $parse = Time::ParseDate::parsedate($input, NOW => $now);
|
||||
|
||||
if (not defined $parse) {
|
||||
@ -30,7 +32,7 @@ sub parsedate {
|
||||
}
|
||||
}
|
||||
|
||||
return ($seconds, undef);
|
||||
return $seconds;
|
||||
}
|
||||
|
||||
1;
|
||||
|
Loading…
Reference in New Issue
Block a user