From 5d793c65c4d0f267e24303f167faf1b896c69e11 Mon Sep 17 00:00:00 2001 From: qianxu Date: Fri, 13 Oct 2023 01:30:42 +0800 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20=E6=94=B9=E8=BF=9B?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=20(#591)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * refactor: 改进代码 * 🚨 `pre-commit-ci`修复格式错误 --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- GenshinUID/client.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/GenshinUID/client.py b/GenshinUID/client.py index bc0c4322..75476d1c 100644 --- a/GenshinUID/client.py +++ b/GenshinUID/client.py @@ -405,11 +405,12 @@ async def onebot_red_send( target_type: Optional[str], ): from nonebot.adapters.red.bot import Bot + from nonebot.adapters.red.api.model import ChatType from nonebot.adapters.red.message import Message, MessageSegment assert isinstance(bot, Bot) - chat_type = 2 if target_type == 'group' else 1 + chat_type = ChatType.GROUP if target_type == 'group' else ChatType.FRIEND async def _send(content: Optional[str], image: Optional[str]): result_msg: Message = Message() @@ -431,11 +432,7 @@ async def onebot_red_send( result_msg += MessageSegment.file(path) if target_id: - await bot.send_message( - chat_type, # type: ignore - target_id, - result_msg, - ) + await bot.send_message(chat_type, target_id, result_msg) if file: del_file(path) # type: ignore