添加删除订阅命令的取消功能

This commit is contained in:
Azide 2022-05-11 17:36:16 +08:00
parent d0f56e76cd
commit 84e497e65a
3 changed files with 8 additions and 5 deletions

View File

@ -269,13 +269,16 @@ def do_del_sub(del_sub: Type[Matcher]):
if platform.enable_tag:
res += " {}".format(", ".join(sub["tags"]))
res += "\n"
res += "请输入要删除的订阅的序号"
res += "请输入要删除的订阅的序号\n输入'取消'中止"
await bot.send(event=event, message=Message(await parse_text(res)))
@del_sub.receive()
async def do_del(event: Event, state: T_State):
user_msg = str(event.get_message()).strip()
if user_msg == "取消":
await del_sub.finish("删除中止")
try:
index = int(str(event.get_message()).strip())
index = int(user_msg)
config = Config()
user_info = state["target_user_info"]
assert isinstance(user_info, User)

View File

@ -387,8 +387,8 @@ async def test_add_with_get_id(app: App):
True,
)
"""
line 362:
知道为什么要在这里这样写
关于Message([MessageSegment(*BotReply.add_reply_on_id_input_search())]):
异客知道为什么要在这里这样写
没有[]的话assert不了(should_call_send使用[MessageSegment(...)]的格式进行比较)
不在这里MessageSegment()的话也assert不了(指不能让add_reply_on_id_input_search直接返回一个MessageSegment对象)
amen

View File

@ -67,7 +67,7 @@ async def test_del_sub(app: App):
ctx.should_call_send(
event,
Message(
"订阅的帐号为:\n1 weibo 明日方舟Arknights 6279793937\n [图文] 明日方舟\n请输入要删除的订阅的序号"
"订阅的帐号为:\n1 weibo 明日方舟Arknights 6279793937\n [图文] 明日方舟\n请输入要删除的订阅的序号\n输入'取消'中止"
),
True,
)