🎨 回复增加防洪处理

This commit is contained in:
kotoriのねこ 2022-09-02 12:51:40 -05:00
parent 320fadc5cb
commit 9e11ed7d8e
No known key found for this signature in database
GPG Key ID: 8B213C1B412C672C

View File

@ -1,5 +1,6 @@
import datetime import datetime
import time import time
import asyncio
from aiohttp import ClientConnectorError from aiohttp import ClientConnectorError
from genshin import Game, GenshinException, AlreadyClaimed, InvalidCookies from genshin import Game, GenshinException, AlreadyClaimed, InvalidCookies
@ -96,6 +97,7 @@ class SignJob:
text = f"<a href=\"tg://user?id={sign_db.user_id}\">NOTICE {sign_db.user_id}</a>\n\n{text}" text = f"<a href=\"tg://user?id={sign_db.user_id}\">NOTICE {sign_db.user_id}</a>\n\n{text}"
try: try:
await context.bot.send_message(sign_db.chat_id, text, parse_mode=ParseMode.HTML) await context.bot.send_message(sign_db.chat_id, text, parse_mode=ParseMode.HTML)
await asyncio.sleep(5) # 回复延迟5S避免触发洪水防御
except BadRequest as exc: except BadRequest as exc:
Log.error(f"执行自动签到时发生错误 用户UID[{user_id}]", exc) Log.error(f"执行自动签到时发生错误 用户UID[{user_id}]", exc)
sign_db.status = SignStatusEnum.BAD_REQUEST sign_db.status = SignStatusEnum.BAD_REQUEST