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

We can now save "context" tags, if any are return by the parser

parent dbd56890
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -15,14 +15,23 @@ sub exec {
}
}
sub addContext
{
my ($id, $msg) = @_;
while ($msg =~ /#?([a-zA-Z0-9_-]+)/g) {
addTag($id, $1, 1);
}
}
sub addTag
{
my ($id, $tag) = @_;
my ($id, $tag, $context) = @_;
my $sth = $dbh->prepare_cached('INSERT INTO playbot_tags (id, tag) VALUES (?, ?)');
my $sth = $dbh->prepare_cached('INSERT INTO playbot_tags (id, tag, context) VALUES (?, ?, ?)');
$log->error("Couldn't prepare querie; aborting") unless (defined $sth);
$sth->execute($id, $tag)
$sth->execute($id, $tag, ($context) ? 1 : 0)
or $log->error("Couldn't finish transaction: " . $dbh->errstr);
}
......
......@@ -10,6 +10,9 @@ use soundcloud;
use mixcloud;
use zippy;
use lib "$FindBin::Bin/lib/";
use commands::tag;
our $irc;
our $dbh;
our $log;
......@@ -83,6 +86,10 @@ sub parse {
else {
$irc->yield(privmsg => $chan => '['.$id.'] '.$content{'title'}) ;
}
if (defined $content{'context'}) {
commands::tag::addContext($id, $content{'context'});
}
}
return $id;
......
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