diff --git a/lib/commands/tag.pm b/lib/commands/tag.pm index 9f4f552bdcc5196c5d36123f5f06410a7a86f713..23310996138a8b88a69e229ecf048b3a192b1078 100644 --- a/lib/commands/tag.pm +++ b/lib/commands/tag.pm @@ -32,12 +32,19 @@ sub addTag my $stopwords_en = getStopWords('en'); my $stopwords_fr = getStopWords('fr'); - return if ($stopwords_en->{lc $tag} or $stopwords_fr->{lc $tag}); - - my $sth = $dbh->prepare_cached('INSERT INTO playbot_tags (id, tag, context) - VALUES (?, ?, ?) - ON DUPLICATE KEY - UPDATE context = 0'); + return if ($context and ($stopwords_en->{lc $tag} or $stopwords_fr->{lc $tag})); + + my $sth; + + if (!$context) { + $sth = $dbh->prepare_cached('INSERT INTO playbot_tags (id, tag, context) + VALUES (?, ?, ?) + ON DUPLICATE KEY + UPDATE context = 0'); + } else { + $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, ($context) ? 1 : 0)