From 42d42a25b4449c0f6675cb73bbd9d3bf33bea583 Mon Sep 17 00:00:00 2001 From: Kamal Curi Date: Wed, 26 Jul 2023 14:18:35 -0300 Subject: [PATCH] ADD: --rq abuse/spam now gets ignored --- motd | 2 +- utils/commands.py | 26 +++++++++++++++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/motd b/motd index e2f5613..8d5af7d 100644 --- a/motd +++ b/motd @@ -5,7 +5,7 @@ █ ▄ █ ▄▄▄█ ▄▄▄█ ▄ ██ █▄▄▄█ ▄▄▄█ █ █ █ █ █▄▄▄█ █▄▄▄█ █▄█ █ █ █▄▄▄ █▄█ █▄▄█▄▄▄▄▄▄▄█▄▄▄▄▄▄▄█▄▄▄▄▄▄▄█▄▄▄▄▄▄▄█▄▄▄▄▄▄▄█ -Neeble version: 2023.07.19b +Neeble version: 2023.07.26 Help with the development of neeble-bot in https://brejela.club/gitea/neeble-club/neeble Thank you! diff --git a/utils/commands.py b/utils/commands.py index e3eecb7..8f5760f 100644 --- a/utils/commands.py +++ b/utils/commands.py @@ -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