From bfab1ec2139047fc4900a3f5eec7fa92d2f396e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B4=9B=E6=B0=B4=E5=B1=85=E5=AE=A4?= Date: Fri, 2 Dec 2022 14:53:41 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Improve=20restrict=20and=20lower?= =?UTF-8?q?=20the=20restriction=20time?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/decorators/restricts.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/utils/decorators/restricts.py b/utils/decorators/restricts.py index cef3020..d28286c 100644 --- a/utils/decorators/restricts.py +++ b/utils/decorators/restricts.py @@ -78,7 +78,7 @@ def restricts( # 洪水防御 if restrict_since: - if (time.time() - restrict_since) >= 60 * 5: + if (time.time() - restrict_since) >= 60: del context.user_data["restrict_since"] del context.user_data["usage_count"] else: @@ -86,8 +86,11 @@ def restricts( else: if count >= 6: context.user_data["restrict_since"] = time.time() - await message.reply_text("你已经触发洪水防御,请等待5分钟") - logger.warning(f"用户 {user.full_name}[{user.id}] 触发洪水限制 已被限制5分钟") + if update.callback_query: + await update.callback_query.answer("你已经触发洪水防御,请等待60秒", show_alert=True) + else: + await message.reply_text("你已经触发洪水防御,请等待60秒") + logger.warning(f"用户 {user.full_name}[{user.id}] 触发洪水限制 已被限制60秒") return return_data # 单次使用限制 if command_time: