🏡 index : ~doyle/dave.git

author Jordan Doyle <jordan@doyle.la> 2019-05-14 9:53:42.0 +01:00:00
committer GitHub <noreply@github.com> 2019-05-14 9:53:42.0 +01:00:00
commit
81707fe9dc5cb09364f7da526010848e64b9ec3f [patch]
tree
3816b9e1947ce218fa87a80d3c98dfabc04df191
parent
e3b22781b63a50c92fc3e93dcbdc27d927456fc6
download
81707fe9dc5cb09364f7da526010848e64b9ec3f.tar.gz

Use RANDOM() instead of trying to implement random ourselves



Diff

 dave/modules/quote.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/dave/modules/quote.py b/dave/modules/quote.py
index e436dd9..ed0a22b 100644
--- a/dave/modules/quote.py
+++ a/dave/modules/quote.py
@@ -1,5 +1,6 @@
"""Quote system"""
from sqlalchemy.exc import SQLAlchemyError
from sqlalchemy.sql.expression import func
import dave.module
import dave.config
import uuid
@@ -34,7 +35,7 @@
        bot.reply(source, sender, "No quotes found.")
        return

    row = query.offset(random.randrange(query.count())).first()
    row = query.order_by(func.random()).first()

    bot.reply(source, sender, assembleFormattedText(A.normal[
        "<{}> ".format(row.attributed.strip()) if row.attributed else "", A.bold[row.quote]