From f23733ebe6d4416111f5210f937c840fc74960bf Mon Sep 17 00:00:00 2001 From: RockChinQ <1010553892@qq.com> Date: Sat, 25 May 2024 09:23:45 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E7=A7=81=E8=81=8A=E5=9B=9E=E5=A4=8D?= =?UTF-8?q?=E5=BB=B6=E8=BF=9F=E4=B8=89=E7=A7=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- campux/imbot/nbmod.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/campux/imbot/nbmod.py b/campux/imbot/nbmod.py index 5108b6a..3d83407 100644 --- a/campux/imbot/nbmod.py +++ b/campux/imbot/nbmod.py @@ -33,6 +33,9 @@ def can_send_help_message(user_id: int) -> bool: help_message_sent_record[user_id] = time.time() return True +async def fdelay(seconds: float=3): + await asyncio.sleep(seconds) + # ========= 私聊 ========= sign_up = on_command("注册账号", rule=to_me() & is_private & not_bot_self, priority=10, block=True) reset_password = on_command("重置密码", rule=to_me() & is_private & not_bot_self, priority=10, block=True) @@ -46,6 +49,9 @@ async def sign_up_func(event: Event): try: pwd = await api.campux_api.sign_up(uin=int(event.get_user_id())) + + await fdelay() + await sign_up.finish(f"注册成功,初始密码:\n{pwd}") except Exception as e: if isinstance(e, nonebot.exception.FinishedException): @@ -57,6 +63,9 @@ async def sign_up_func(event: Event): async def reset_password_func(event: Event): try: pwd = await api.campux_api.reset_password(uin=int(event.get_user_id())) + + await fdelay() + await reset_password.finish(f"重置成功,新密码:\n{pwd}") except Exception as e: if isinstance(e, nonebot.exception.FinishedException): @@ -82,6 +91,9 @@ async def qrcode_callback(content: bytes): )) try: + + await fdelay() + await ap.social.platform_api.relogin(qrcode_callback) except Exception as e: if isinstance(e, nonebot.exception.FinishedException): @@ -93,6 +105,9 @@ async def qrcode_callback(content: bytes): async def any_message_func(event: Event): if not can_send_help_message(int(event.get_user_id())): return + + await fdelay() + await any_message.finish(nonebot.get_driver().config.campux_help_message) # ========= 群聊 =========