Skip to content
Extraits de code Groupes Projets
Valider d2150f47 rédigé par Alexandre Morignot's avatar Alexandre Morignot
Parcourir les fichiers

we can now do !get -1 (works only with 1)

parent a9a09bb7
Branches
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -12,16 +12,40 @@ sub exec { ...@@ -12,16 +12,40 @@ sub exec {
$time = 6 if (!$time); $time = 6 if (!$time);
$time *= ($unit eq 's') ? 1 : ($unit eq 'm') ? 60 : 3600; $time *= ($unit eq 's') ? 1 : ($unit eq 'm') ? 60 : 3600;
$kernel->delay_set('_later', $time, $nick, $id);
my $sth = $dbh->prepare_cached('INSERT INTO playbot_later (content, nick, date) VALUES (?, ?, ?)'); if ($id == -1) {
my $sth = $dbh->prepare_cached('
SELECT content
FROM playbot_chan
WHERE id < (SELECT id
FROM playbot_chan
WHERE content = ?)
AND chan = (SELECT chan
FROM playbot_chan
WHERE content = ?)
ORDER BY id DESC
LIMIT 1');
unless (defined $sth) { unless (defined $sth) {
$log->error("Couldn't prepare querie; aborting"); $log->error("Couldn't prepare querie; aborting");
return; return;
} }
$sth->execute($id, $id)
or $log->error("Couldn't finish transaction: " . $dbh->errstr);
return unless ($content);
my $content = $sth->fetch;
$id = $content->[0];
}
my $sth = $dbh->prepare_cached('INSERT INTO playbot_later (content, nick, date) VALUES (?, ?, ?)');
unless (defined $sth) {
$log->error("Couldn't prepare querie; aborting");
return;
}
$sth->execute($id, $nick, time + $time) $sth->execute($id, $nick, time + $time)
or $log->error("Couldn't finish transaction: " . $dbh->errstr); or $log->error("Couldn't finish transaction: " . $dbh->errstr);
$kernel->delay_set('_later', $time, $nick, $id);
} }
1; 1;
...@@ -43,7 +43,7 @@ sub exec { ...@@ -43,7 +43,7 @@ sub exec {
commands::fav::exec($nick, $id) commands::fav::exec($nick, $id)
} }
elsif ($msg =~ /^ *!later(?: ([0-9]+))?(?: in ([0-9]*)?(h|m|s)?)?/) { elsif ($msg =~ /^ *!later(?: (-?[0-9]+))?(?: in ([0-9]*)?(h|m|s)?)?/) {
my $id = ($1) ? $1 : $lastID->{$chan->[0]}; my $id = ($1) ? $1 : $lastID->{$chan->[0]};
my ($time, $unit) = ($2, $3); my ($time, $unit) = ($2, $3);
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter