|
|
|
@ -5,7 +5,7 @@ import logging
|
|
|
|
|
|
|
|
|
|
import os
|
|
|
|
|
import json
|
|
|
|
|
from datetime import datetime
|
|
|
|
|
from datetime import datetime, timedelta
|
|
|
|
|
|
|
|
|
|
from random import randrange
|
|
|
|
|
|
|
|
|
@ -33,6 +33,10 @@ with open(RQ_LEADERBOARD, mode='r') as f:
|
|
|
|
|
|
|
|
|
|
quote_content = {}
|
|
|
|
|
|
|
|
|
|
last_rq = {}
|
|
|
|
|
last_rqer = ''
|
|
|
|
|
rq_abusers = {}
|
|
|
|
|
|
|
|
|
|
last_quote = 0
|
|
|
|
|
|
|
|
|
|
@client.event
|
|
|
|
@ -112,9 +116,29 @@ async def random_quote(bot: object) -> str:
|
|
|
|
|
"""
|
|
|
|
|
Get a random quote from the database.
|
|
|
|
|
"""
|
|
|
|
|
global last_rq
|
|
|
|
|
global last_rqer
|
|
|
|
|
global rq_abusers
|
|
|
|
|
chosen_one = get_quotes(quote_id_stack)
|
|
|
|
|
stack_len = len(quote_id_stack)
|
|
|
|
|
|
|
|
|
|
# The next two IF statements are meant to deal with `--rq` abuse
|
|
|
|
|
if last_rqer != bot.author.name:
|
|
|
|
|
rq_abusers[last_rqer] = 0
|
|
|
|
|
|
|
|
|
|
if last_rqer == bot.author.name and datetime.now() < last_rq[bot.author.name] + timedelta(seconds = 30):
|
|
|
|
|
if bot.author.name in rq_abusers.keys():
|
|
|
|
|
rq_abusers[bot.author.name] += 1
|
|
|
|
|
else:
|
|
|
|
|
rq_abusers[bot.author.name] = 1
|
|
|
|
|
if rq_abusers[bot.author.name] > 3:
|
|
|
|
|
return 0
|
|
|
|
|
return await bot.send('Chill.')
|
|
|
|
|
|
|
|
|
|
last_rqer = bot.author.name
|
|
|
|
|
last_rq[bot.author.name] = datetime.now()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#Adds to --rq leaderboard
|
|
|
|
|
if bot.author.name in rq_leaderboard.keys():
|
|
|
|
|
rq_leaderboard[bot.author.name] += 1
|
|
|
|
|