From 438b23a0b940740ef3de87d7d7b5a868f2c8ad8f Mon Sep 17 00:00:00 2001 From: suyiiyii Date: Mon, 28 Oct 2024 12:44:51 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20=E4=BB=8E=20Site=20=E4=B8=AD=E7=A7=BB?= =?UTF-8?q?=E9=99=A4=20=E3=80=8C=E6=97=A0=E6=95=88=E7=9A=84=20Cookie?= =?UTF-8?q?=E3=80=8D=20=E6=96=87=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nonebot_bison/sub_manager/add_cookie.py | 4 +++- nonebot_bison/utils/site.py | 1 - tests/sub_manager/test_add_cookie.py | 6 +++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/nonebot_bison/sub_manager/add_cookie.py b/nonebot_bison/sub_manager/add_cookie.py index 28f54b6..61cdcd6 100644 --- a/nonebot_bison/sub_manager/add_cookie.py +++ b/nonebot_bison/sub_manager/add_cookie.py @@ -55,7 +55,9 @@ def do_add_cookie(add_cookie: type[Matcher]): cookie_site = cast(type[CookieSite], platform_manager[state["platform"]].site) cookie_text = cookie.extract_plain_text() if not await cookie_site.validate_cookie(cookie_text): - await add_cookie.reject(state["site"].cookie_format_prompt) + await add_cookie.reject( + "无效的 Cookie,请检查后重新输入,详情见https://nonebot-bison.netlify.app/usage/cookie.html" + ) state["cookie"] = cookie_text @add_cookie.handle() diff --git a/nonebot_bison/utils/site.py b/nonebot_bison/utils/site.py index 9a042f2..d975f93 100644 --- a/nonebot_bison/utils/site.py +++ b/nonebot_bison/utils/site.py @@ -166,7 +166,6 @@ class Site(metaclass=RegistryMeta, base=True): class CookieSite(Site): client_mgr: type[CookieClientManager] = CookieClientManager - cookie_format_prompt = "无效的 Cookie,请检查后重新输入,详情见<待添加的文档>" @classmethod async def get_cookie_name(cls, content: str) -> str: diff --git a/tests/sub_manager/test_add_cookie.py b/tests/sub_manager/test_add_cookie.py index 62b39c0..8aea570 100644 --- a/tests/sub_manager/test_add_cookie.py +++ b/tests/sub_manager/test_add_cookie.py @@ -126,7 +126,11 @@ async def test_add_cookie(app: App): message=Message("test"), sender=fake_superuser, to_me=True, user_id=fake_superuser.user_id ) ctx.receive_event(bot, event_4_err) - ctx.should_call_send(event_4_err, "无效的 Cookie,请检查后重新输入,详情见<待添加的文档>", True) + ctx.should_call_send( + event_4_err, + "无效的 Cookie,请检查后重新输入,详情见https://nonebot-bison.netlify.app/usage/cookie.html", + True, + ) ctx.should_rejected() event_4_ok = fake_private_message_event( message=Message(json.dumps({"cookie": "test"})),