From 84e497e65a8437aa216bbbbdee656e0df7c4c6ed Mon Sep 17 00:00:00 2001 From: Azide Date: Wed, 11 May 2022 17:36:16 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=88=A0=E9=99=A4=E8=AE=A2?= =?UTF-8?q?=E9=98=85=E5=91=BD=E4=BB=A4=E7=9A=84=E5=8F=96=E6=B6=88=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/nonebot_bison/config_manager.py | 7 +++++-- tests/test_config_manager_add.py | 4 ++-- tests/test_config_manager_query_del.py | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/plugins/nonebot_bison/config_manager.py b/src/plugins/nonebot_bison/config_manager.py index 931bf3e..21438ee 100644 --- a/src/plugins/nonebot_bison/config_manager.py +++ b/src/plugins/nonebot_bison/config_manager.py @@ -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) diff --git a/tests/test_config_manager_add.py b/tests/test_config_manager_add.py index a38a1a8..ae679c0 100644 --- a/tests/test_config_manager_add.py +++ b/tests/test_config_manager_add.py @@ -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 diff --git a/tests/test_config_manager_query_del.py b/tests/test_config_manager_query_del.py index 51dd80d..4cad12f 100644 --- a/tests/test_config_manager_query_del.py +++ b/tests/test_config_manager_query_del.py @@ -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, )