mirror of
https://github.com/suyiiyii/nonebot-bison.git
synced 2025-06-02 09:26:12 +08:00
🐛 fix test 2
This commit is contained in:
parent
d75fe36c3b
commit
202b8df0a6
@ -24,10 +24,9 @@ def do_add_cookie_target(add_cookie_target_matcher: type[Matcher]):
|
|||||||
await MessageFactory(await parse_text(res)).send()
|
await MessageFactory(await parse_text(res)).send()
|
||||||
|
|
||||||
@add_cookie_target_matcher.got("target_idx", parameterless=[handle_cancel])
|
@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:
|
try:
|
||||||
target_idx = int(target_idx_str)
|
state["target"] = state["sub_table"][int(target_idx)]
|
||||||
state["target"] = state["sub_table"][target_idx]
|
|
||||||
state["site"] = platform_manager[state["target"]["platform_name"]].site
|
state["site"] = platform_manager[state["target"]["platform_name"]].site
|
||||||
except Exception:
|
except Exception:
|
||||||
await add_cookie_target_matcher.reject("序号错误")
|
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])
|
@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:
|
try:
|
||||||
cookie_idx = int(cookie_idx_str)
|
state["cookie"] = state["cookies"][int(cookie_idx) - 1]
|
||||||
state["cookie"] = state["cookies"][cookie_idx - 1]
|
|
||||||
except Exception:
|
except Exception:
|
||||||
await add_cookie_target_matcher.reject("序号错误")
|
await add_cookie_target_matcher.reject("序号错误")
|
||||||
|
|
||||||
|
@ -127,5 +127,5 @@ async def only_allow_private(
|
|||||||
event: Event,
|
event: Event,
|
||||||
matcher: type[Matcher],
|
matcher: type[Matcher],
|
||||||
):
|
):
|
||||||
if event.__getattr__("message_type") != "private":
|
if not (hasattr(event, "message_type") and getattr(event, "message_type") == "private"):
|
||||||
await matcher.finish("请在私聊中使用此命令")
|
await matcher.finish("请在私聊中使用此命令")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user