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

get rid of $lastID.

!later withoud id works everytime, same for !later -1
parent 3aeed0af
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -8,32 +8,36 @@ our $dbh;
our $log;
sub exec {
my ($kernel, $nick, $id, $time, $unit) = @_;
my ($kernel, $nick, $id, $offset, $chan, $time, $unit) = @_;
print ">>@_\n";
$time = 6 if (!$time);
$time *= ($unit eq 's') ? 1 : ($unit eq 'm') ? 60 : 3600;
if ($id == -1) {
if ($offset == -1) {
print "lolo\n";
my $sth = $dbh->prepare_cached('
SELECT content
FROM playbot_chan
WHERE id < (SELECT id
WHERE date < (SELECT date
FROM playbot_chan
WHERE content = ?)
WHERE content = ?
AND chan = ?)
AND chan = (SELECT chan
FROM playbot_chan
WHERE content = ?)
ORDER BY id DESC
WHERE content = ?
AND chan = ?)
ORDER BY date DESC
LIMIT 1');
unless (defined $sth) {
$log->error("Couldn't prepare querie; aborting");
return;
}
$sth->execute($id, $id)
$sth->execute($id, $chan->[0], $id, $chan->[0])
or $log->error("Couldn't finish transaction: " . $dbh->errstr);
return unless ($content);
my $content = $sth->fetch;
return unless ($content);
$id = $content->[0];
}
......
......@@ -14,14 +14,15 @@ use commands::get;
my $lastID;
my $irc;
my $dbh;
sub setConf {
my ($ircNew, $dbh, $log, $lastIDnew) = @_;
my ($ircNew, $dbhNew, $log, $lastIDnew) = @_;
$commands::fav::dbh = $dbh;
$commands::tag::dbh = $dbh;
$commands::get::dbh = $dbh;
$commands::later::dbh = $dbh;
$commands::fav::dbh = $dbhNew;
$commands::tag::dbh = $dbhNew;
$commands::get::dbh = $dbhNew;
$commands::later::dbh = $dbhNew;
$commands::fav::log = $log;
$commands::tag::log = $log;
......@@ -31,8 +32,9 @@ sub setConf {
$commands::fav::irc = $ircNew;
$commands::get::irc = $ircNew;
$irc = $ircNew;
$lastID = $lastIDnew;
$irc = $ircNew;
$dbh = $dbhNew;
}
sub exec {
......@@ -45,10 +47,23 @@ sub exec {
commands::fav::exec($nick, $id)
}
elsif ($msg =~ /^ *!later(?: (-?[0-9]+))?(?: in ([0-9]*)?(h|m|s)?)?/) {
my $id = ($1) ? $1 : $lastID->{$chan->[0]};
my $id = $1;
my $offset = $1;
my ($time, $unit) = ($2, $3);
commands::later::exec($kernel, $nick, $id, $time, $unit);
if ($id eq '' || $id =~ /^-/) {
my $sth = $dbh->prepare('
SELECT content
FROM playbot_chan
WHERE chan = ?
AND date <= NOW()
ORDER BY date DESC
LIMIT 1');
$sth->execute($chan->[0]);
$id = $sth->fetch->[0];
}
commands::later::exec($kernel, $nick, $id, $offset, $chan, $time, $unit);
}
elsif ($msg =~ /^( *!tag)(?:( +)([0-9]+))?/) {
my $id = $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