mirror of
https://github.com/suyiiyii/nonebot-bison.git
synced 2025-06-07 12:23:00 +08:00
fix test:修改了订阅过程中bot的回复内容并调整单元测试
This commit is contained in:
parent
2d4887c1d7
commit
8e315d53d3
@ -138,7 +138,7 @@ def do_add_sub(add_sub: Type[Matcher]):
|
|||||||
state["id"] = target
|
state["id"] = target
|
||||||
state["name"] = name
|
state["name"] = name
|
||||||
except (LookupError):
|
except (LookupError):
|
||||||
url = "https://nonebot-bison.vercel.app/usage/#%E6%89%80%E6%94%AF%E6%8C%81%E5%B9%B3%E5%8F%B0%E7%9A%84-uid"
|
url = "https://nonebot-bison.netlify.app/usage/#%E6%89%80%E6%94%AF%E6%8C%81%E5%B9%B3%E5%8F%B0%E7%9A%84-uid"
|
||||||
title = "Bison所支持的平台UID"
|
title = "Bison所支持的平台UID"
|
||||||
content = "查询相关平台的uid格式或获取方式"
|
content = "查询相关平台的uid格式或获取方式"
|
||||||
image = "https://s3.bmp.ovh/imgs/2022/03/ab3cc45d83bd3dd3.jpg"
|
image = "https://s3.bmp.ovh/imgs/2022/03/ab3cc45d83bd3dd3.jpg"
|
||||||
@ -183,13 +183,17 @@ def do_add_sub(add_sub: Type[Matcher]):
|
|||||||
if not platform_manager[state["platform"]].enable_tag:
|
if not platform_manager[state["platform"]].enable_tag:
|
||||||
state["tags"] = []
|
state["tags"] = []
|
||||||
return
|
return
|
||||||
state["_prompt"] = '请输入要订阅的tag,订阅所有tag输入"全部标签"'
|
state["_prompt"] = '请输入要订阅/屏蔽的tag(不含#号)\n多个tag请使用空格隔开\n具体规则回复"详情"'
|
||||||
|
|
||||||
async def parser_tags(event: MessageEvent, state: T_State):
|
async def parser_tags(event: MessageEvent, state: T_State):
|
||||||
if not isinstance(state["tags"], Message):
|
if not isinstance(state["tags"], Message):
|
||||||
return
|
return
|
||||||
if str(event.get_message()).strip() == "取消": # 一般不会有叫 取消 的tag吧
|
if str(event.get_message()).strip() == "取消": # 一般不会有叫 取消 的tag吧
|
||||||
await add_sub.finish("已中止订阅")
|
await add_sub.finish("已中止订阅")
|
||||||
|
if str(event.get_message()).strip() == "详情":
|
||||||
|
await add_sub.reject(
|
||||||
|
'订阅tag直接输入tag内容\n订阅所有tag输入"全部标签"\n屏蔽tag请在tag名称前添加~号\n详见https://nonebot-bison.netlify.app/usage/#平台订阅标签-tag'
|
||||||
|
)
|
||||||
if str(event.get_message()).strip() == "全部标签":
|
if str(event.get_message()).strip() == "全部标签":
|
||||||
state["tags"] = []
|
state["tags"] = []
|
||||||
else:
|
else:
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
from email import message
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
import respx
|
import respx
|
||||||
from httpx import Response
|
from httpx import Response
|
||||||
@ -154,12 +156,20 @@ async def test_add_with_target(app: App):
|
|||||||
)
|
)
|
||||||
ctx.receive_event(bot, event_5_ok)
|
ctx.receive_event(bot, event_5_ok)
|
||||||
ctx.should_call_send(event_5_ok, Message(BotReply.add_reply_on_tags), True)
|
ctx.should_call_send(event_5_ok, Message(BotReply.add_reply_on_tags), True)
|
||||||
event_6 = fake_group_message_event(
|
event_6_more_info = fake_group_message_event(
|
||||||
|
message=Message("详情"), sender=fake_admin_user
|
||||||
|
)
|
||||||
|
ctx.receive_event(bot, event_6_more_info)
|
||||||
|
ctx.should_call_send(
|
||||||
|
event_6_more_info, BotReply.add_reply_on_tags_need_more_info, True
|
||||||
|
)
|
||||||
|
ctx.should_rejected()
|
||||||
|
event_6_ok = fake_group_message_event(
|
||||||
message=Message("全部标签"), sender=fake_admin_user
|
message=Message("全部标签"), sender=fake_admin_user
|
||||||
)
|
)
|
||||||
ctx.receive_event(bot, event_6)
|
ctx.receive_event(bot, event_6_ok)
|
||||||
ctx.should_call_send(
|
ctx.should_call_send(
|
||||||
event_6, BotReply.add_reply_subscribe_success("明日方舟Arknights"), True
|
event_6_ok, BotReply.add_reply_subscribe_success("明日方舟Arknights"), True
|
||||||
)
|
)
|
||||||
ctx.should_finished()
|
ctx.should_finished()
|
||||||
subs = config.list_subscribe(10000, "group")
|
subs = config.list_subscribe(10000, "group")
|
||||||
|
@ -99,7 +99,7 @@ class BotReply:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def add_reply_on_id_input_search():
|
def add_reply_on_id_input_search():
|
||||||
search_url = "https://nonebot-bison.vercel.app/usage/#%E6%89%80%E6%94%AF%E6%8C%81%E5%B9%B3%E5%8F%B0%E7%9A%84-uid"
|
search_url = "https://nonebot-bison.netlify.app/usage/#%E6%89%80%E6%94%AF%E6%8C%81%E5%B9%B3%E5%8F%B0%E7%9A%84-uid"
|
||||||
search_title = "Bison所支持的平台UID"
|
search_title = "Bison所支持的平台UID"
|
||||||
search_content = "查询相关平台的uid格式或获取方式"
|
search_content = "查询相关平台的uid格式或获取方式"
|
||||||
search_image = "https://s3.bmp.ovh/imgs/2022/03/ab3cc45d83bd3dd3.jpg"
|
search_image = "https://s3.bmp.ovh/imgs/2022/03/ab3cc45d83bd3dd3.jpg"
|
||||||
@ -144,5 +144,6 @@ class BotReply:
|
|||||||
add_reply_on_id_input_error = "id输入错误"
|
add_reply_on_id_input_error = "id输入错误"
|
||||||
add_reply_on_target_parse_input_error = "不能从你的输入中提取出id,请检查你输入的内容是否符合预期"
|
add_reply_on_target_parse_input_error = "不能从你的输入中提取出id,请检查你输入的内容是否符合预期"
|
||||||
add_reply_on_platform_input_error = "平台输入错误"
|
add_reply_on_platform_input_error = "平台输入错误"
|
||||||
add_reply_on_tags = '请输入要订阅的tag,订阅所有tag输入"全部标签"'
|
add_reply_on_tags = '请输入要订阅/屏蔽的tag(不含#号)\n多个tag请使用空格隔开\n具体规则回复"详情"'
|
||||||
|
add_reply_on_tags_need_more_info = '订阅tag直接输入tag内容\n订阅所有tag输入"全部标签"\n屏蔽tag请在tag名称前添加~号\n详见https://nonebot-bison.netlify.app/usage/#平台订阅标签-tag'
|
||||||
add_reply_abort = "已中止订阅"
|
add_reply_abort = "已中止订阅"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user