diff --git a/PlayBot.pl b/PlayBot.pl index 991e018238708ce89df298020e215571d9f02356..64d0a5fa562d5666d626e34684317d76331e395e 100755 --- a/PlayBot.pl +++ b/PlayBot.pl @@ -256,6 +256,8 @@ sub on_speak $log->debug($content{'url'}); } else { + # insertion de la vidéo dans la bdd + my $sth = $dbh->prepare_cached('INSERT INTO playbot (date, type, url, sender_irc, sender, title, chan) VALUES (NOW(),?,?,?,?,?,?)'); $log->error("Couldn't prepare querie; aborting") unless (defined $sth); @@ -275,6 +277,18 @@ sub on_speak $id = $sth->fetch->[0]; } + + # insertion des éventuels tags + while ($msg =~ /#([a-zA-Z_-]*)/g) { + next if (!$1); + my $sth = $dbh->prepare_cached('INSERT INTO playbot_tags (id, tag) VALUES (?, ?)'); + $log->error("Couldn't prepare querie; aborting") unless (defined $sth); + + $sth->execute($id, $1) + or $log->error("Couldn't finish transaction: " . $dbh->errstr); + } + + # message sur irc if (defined $content{'author'}) { $irc->yield(privmsg => $chan => '['.$id.'] '.$content{'title'}.' | '.$content{'author'}) ;