diff --git a/lib/commands/get.pm b/lib/commands/get.pm index 7ebfa8c9430bd5e08b5b149c9f28ff5d5eb485ce..e2266151a614605d2e3ba3157b5838069afc4aa4 100644 --- a/lib/commands/get.pm +++ b/lib/commands/get.pm @@ -29,7 +29,9 @@ sub exec { natural join playbot_tags where tag in ('.$params.') group by id - having count(*) >= ?'); + having count(*) >= ? + order by rand() + limit 1'); $sth->execute(@tags, scalar @tags); } else { @@ -40,19 +42,18 @@ sub exec { where pt.tag in ('.$params.') and pc.chan = ? group by p.id - having count(*) >= ?'); + having count(*) >= ? + order by rand() + limit 1'); $sth->execute(@tags, $chan->[0], scalar @tags); } - $content = $sth->fetchall_arrayref; + $content = $sth->fetch; if (!@{$content}) { $irc->yield(privmsg => $chan => "Je n'ai rien dans ce registre."); return } - else { - $content = $content->[rand @{$content}]; - } } else { my $sth;