From 202b8df0a69050412f4f55e85db850ad2c687693 Mon Sep 17 00:00:00 2001 From: suyiiyii Date: Tue, 26 Nov 2024 01:18:26 +0800 Subject: [PATCH] :bug: fix test 2 --- nonebot_bison/sub_manager/add_cookie_target.py | 10 ++++------ nonebot_bison/sub_manager/utils.py | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/nonebot_bison/sub_manager/add_cookie_target.py b/nonebot_bison/sub_manager/add_cookie_target.py index b3f7361..919d0ca 100644 --- a/nonebot_bison/sub_manager/add_cookie_target.py +++ b/nonebot_bison/sub_manager/add_cookie_target.py @@ -24,10 +24,9 @@ def do_add_cookie_target(add_cookie_target_matcher: type[Matcher]): await MessageFactory(await parse_text(res)).send() @add_cookie_target_matcher.got("target_idx", parameterless=[handle_cancel]) - async def got_target_idx(state: T_State, target_idx_str: str = ArgPlainText()): + async def got_target_idx(state: T_State, target_idx: str = ArgPlainText()): try: - target_idx = int(target_idx_str) - state["target"] = state["sub_table"][target_idx] + state["target"] = state["sub_table"][int(target_idx)] state["site"] = platform_manager[state["target"]["platform_name"]].site except Exception: await add_cookie_target_matcher.reject("序号错误") @@ -55,10 +54,9 @@ def do_add_cookie_target(add_cookie_target_matcher: type[Matcher]): ) @add_cookie_target_matcher.got("cookie_idx", MessageTemplate("{_prompt}"), [handle_cancel]) - async def got_cookie_idx(state: T_State, cookie_idx_str: str = ArgPlainText()): + async def got_cookie_idx(state: T_State, cookie_idx: str = ArgPlainText()): try: - cookie_idx = int(cookie_idx_str) - state["cookie"] = state["cookies"][cookie_idx - 1] + state["cookie"] = state["cookies"][int(cookie_idx) - 1] except Exception: await add_cookie_target_matcher.reject("序号错误") diff --git a/nonebot_bison/sub_manager/utils.py b/nonebot_bison/sub_manager/utils.py index e715ac4..2418cfc 100644 --- a/nonebot_bison/sub_manager/utils.py +++ b/nonebot_bison/sub_manager/utils.py @@ -127,5 +127,5 @@ async def only_allow_private( event: Event, matcher: type[Matcher], ): - if event.__getattr__("message_type") != "private": + if not (hasattr(event, "message_type") and getattr(event, "message_type") == "private"): await matcher.finish("请在私聊中使用此命令")