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

!get work with an ID

parent 175a892f
Branches
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -6,6 +6,7 @@ our @EXPORT_OK = qw(exec); ...@@ -6,6 +6,7 @@ our @EXPORT_OK = qw(exec);
use strict; use strict;
use warnings; use warnings;
use Scalar::Util qw(looks_like_number);
our $dbh; our $dbh;
our $irc; our $irc;
...@@ -19,10 +20,17 @@ sub exec { ...@@ -19,10 +20,17 @@ sub exec {
my @tags = ($msg =~ /#?([a-zA-Z0-9_-]+)/g); my @tags = ($msg =~ /#?([a-zA-Z0-9_-]+)/g);
my $content; my $content;
my $sth;
if (@tags) { if (@tags) {
if (looks_like_number($tags[0])) {
$sth = $dbh->prepare('select id, sender, title, url
from playbot
where id = ?');
$sth->execute($tags[0]);
}
else {
my $params = join ', ' => ('?') x @tags; my $params = join ', ' => ('?') x @tags;
my $sth;
if ($all) { if ($all) {
$sth = $dbh->prepare('select id, sender, title, url $sth = $dbh->prepare('select id, sender, title, url
...@@ -48,6 +56,7 @@ sub exec { ...@@ -48,6 +56,7 @@ sub exec {
limit 1'); limit 1');
$sth->execute(@tags, $chan->[0], scalar @tags); $sth->execute(@tags, $chan->[0], scalar @tags);
} }
}
$content = $sth->fetch; $content = $sth->fetch;
...@@ -57,8 +66,6 @@ sub exec { ...@@ -57,8 +66,6 @@ sub exec {
} }
} }
else { else {
my $sth;
if ($all) { if ($all) {
$sth = $dbh->prepare('select id, sender, title, url from playbot $sth = $dbh->prepare('select id, sender, title, url from playbot
order by rand() order by rand()
...@@ -83,7 +90,7 @@ sub exec { ...@@ -83,7 +90,7 @@ sub exec {
} }
} }
my $sth = $dbh->prepare("select group_concat(tag separator ' ') $sth = $dbh->prepare("select group_concat(tag separator ' ')
from playbot_tags from playbot_tags
where id = ? and context = 0 where id = ? and context = 0
group by id"); group by 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