diff --git a/PBot/ChanOpCommands.pm b/PBot/ChanOpCommands.pm index f95271ba..6bf8852f 100644 --- a/PBot/ChanOpCommands.pm +++ b/PBot/ChanOpCommands.pm @@ -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"; } diff --git a/PBot/ChanOps.pm b/PBot/ChanOps.pm index 1ec02f66..2c5e8292 100644 --- a/PBot/ChanOps.pm +++ b/PBot/ChanOps.pm @@ -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 { diff --git a/PBot/Utils/ParseDate.pm b/PBot/Utils/ParseDate.pm index 2a85736b..414d9a8c 100644 --- a/PBot/Utils/ParseDate.pm +++ b/PBot/Utils/ParseDate.pm @@ -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;