From 81707fe9dc5cb09364f7da526010848e64b9ec3f Mon Sep 17 00:00:00 2001 From: Jordan Doyle Date: Tue, 14 May 2019 09:53:42 +0100 Subject: [PATCH] Use RANDOM() instead of trying to implement random ourselves --- 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 +++ b/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 @@ def quote(bot, args, sender, source): 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] -- libgit2 1.7.2