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) # ========= 群聊 =========