diff --git a/lib/commands/later.pm b/lib/commands/later.pm index 9af5e8601131f496889087d1f048934055f0347d..59367e0f6294657bf61b4612b00e8a82d023deb2 100644 --- a/lib/commands/later.pm +++ b/lib/commands/later.pm @@ -13,18 +13,22 @@ sub exec { $time = 6 if (!$time); $time *= ($unit eq 's') ? 1 : ($unit eq 'm') ? 60 : 3600; - while ($offset <= 0) { + while ($offset < 0) { my $sth = $dbh->prepare_cached(' SELECT content FROM playbot_chan WHERE date < (SELECT date FROM playbot_chan WHERE content = ? - AND chan = ?) + AND chan = ? + ORDER BY date DESC + LIMIT 1) AND chan = (SELECT chan FROM playbot_chan WHERE content = ? - AND chan = ?) + AND chan = ? + ORDER BY date DESC + LIMIT 1) ORDER BY date DESC LIMIT 1'); unless (defined $sth) { diff --git a/lib/commands/parser.pm b/lib/commands/parser.pm index 368cbaceaddc08c01efe0322dfe957c404c900ca..79935f02672f6932bd2f1251462aecf4c825abeb 100644 --- a/lib/commands/parser.pm +++ b/lib/commands/parser.pm @@ -48,7 +48,7 @@ sub exec { } elsif ($msg =~ /^ *!later(?: (-?[0-9]+))?(?: in ([0-9]*)?(h|m|s)?)?/) { my $id = $1; - my $offset = $1; + my $offset = ($1) ? $1 : 0; my ($time, $unit) = ($2, $3); if ($id eq '' || $id =~ /^-/) {