🐛 从 Site 中移除 「无效的 Cookie」 文本

This commit is contained in:
suyiiyii 2024-10-28 12:44:51 +08:00
parent dcd32f0662
commit 438b23a0b9
Signed by: suyiiyii
GPG Key ID: 044704CB29B8AD85
3 changed files with 8 additions and 3 deletions

View File

@ -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()

View File

@ -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:

View File

@ -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"})),