diff --git a/lib/commands/later.pm b/lib/commands/later.pm index 6692cce2f4617346b701e842701d4b25eed9d31a..c1c365c51377a3573204bc9e6ab20a71b5bed480 100644 --- a/lib/commands/later.pm +++ b/lib/commands/later.pm @@ -4,12 +4,24 @@ require Exporter; our @ISA = qw(Exporter); our @EXPORT_OK = qw(exec); +our $dbh; +our $log; + sub exec { my ($kernel, $nick, $id, $time, $unit) = @_; $time = 6 if (!$time); $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 (?, ?, ?)'); + unless (defined $sth) { + $log->error("Couldn't prepare querie; aborting"); + return; + } + + $sth->execute($id, $nick, time + $time) + or $log->error("Couldn't finish transaction: " . $dbh->errstr); } 1; diff --git a/lib/commands/parser.pm b/lib/commands/parser.pm index 953c1d8020cda37d33ee8a73bc9cf832dbe4265a..40c595fe8b27b50f617105c0b525d7201391ed7c 100644 --- a/lib/commands/parser.pm +++ b/lib/commands/parser.pm @@ -22,9 +22,11 @@ sub setConf { $commands::fav::dbh = $dbh; $commands::tag::dbh = $dbh; $commands::get::dbh = $dbh; + $commands::later::dbh = $dbh; $commands::fav::log = $log; $commands::tag::log = $log; + $commands::later::log = $log; $commands::fav::irc = $ircNew; $commands::get::irc = $ircNew;