From 111d2477282a98ba36f31a519f5ff7659cbcbfe9 Mon Sep 17 00:00:00 2001 From: Alexandre Morignot <erdnaxeli@gmail.com> Date: Fri, 17 Oct 2014 18:56:02 +0200 Subject: [PATCH] a post of an already posted content gets the tags --- lib/sites/parser.pm | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/sites/parser.pm b/lib/sites/parser.pm index 4319057..a3b8b1d 100644 --- a/lib/sites/parser.pm +++ b/lib/sites/parser.pm @@ -65,9 +65,11 @@ sub parse { or $log->error("Couldn't finish transaction: " . $dbh->errstr); } + my @tags; # sélection de l'id de la vidéo insérée $id = $sth->{mysql_insertid}; if (!$id) { + # la vido avait déjà été insérée my $sth = $dbh->prepare_cached('SELECT id FROM playbot WHERE url = ?'); $log->error("Couldn't prepare querie; aborting") unless (defined $sth); @@ -75,6 +77,19 @@ sub parse { or $log->error("Couldn't finish transaction: " . $dbh->errstr); $id = $sth->fetch->[0]; + + # get tags + $sth = $dbh->prepare("select tag + from playbot_tags + where id = ? + "); + $sth->execute($id); + + while (my $data = $sth->fetch) { + my $tag = $data->[0]; + $tag =~ s/([a-zA-Z0-9_-]+)/#$1/; + push @tags, $tag; + } } # insertion du chan @@ -88,6 +103,7 @@ sub parse { # message sur irc $content{'id'} = $id; + $content{'tags'} = \@tags; delete $content{'url'}; $irc->yield(privmsg => $chan => utils::print::print(\%content)); } -- GitLab