From 5c00eb7e0f34b876e4a31973725f7a06e198dc38 Mon Sep 17 00:00:00 2001 From: ishkong <19740260+ishkong@users.noreply.github.com> Date: Wed, 13 Mar 2024 02:00:41 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20=E6=9B=B4=E6=A0=87=E5=87=86?= =?UTF-8?q?=E7=9A=84ob11=E5=90=88=E5=B9=B6=E8=BD=AC=E5=8F=91=EF=BC=8C?= =?UTF-8?q?=E5=85=BC=E5=AE=B9=E6=9B=B4=E5=A4=9A=E5=8D=8F=E8=AE=AE=E7=AB=AF?= =?UTF-8?q?=20(#625)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- GenshinUID/client.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/GenshinUID/client.py b/GenshinUID/client.py index 1fcad5f7..d5496986 100644 --- a/GenshinUID/client.py +++ b/GenshinUID/client.py @@ -348,10 +348,10 @@ class GsClient: ) -def to_json(msg: str, name: str, uin: int): +def to_json(msg: list, name: str, uin: str): return { - 'type': 'node', - 'data': {'name': name, 'uin': uin, 'content': msg}, + "type": "node", + "data": {"name": name, "uin": uin, "content": msg}, } @@ -685,16 +685,20 @@ async def onebot_send( ) if node: + from nonebot.adapters.onebot.v11 import MessageSegment + messages = [ to_json( - f'[CQ:image,file={_msg["data"]}]' - if _msg['type'] == 'image' - else _msg['data'], - '小助手', - 2854196310, + [ + MessageSegment.image(_msg["data"]) + if _msg["type"] == "image" + else MessageSegment.text(_msg["data"]) + ], + "小助手", + str(2854196310), ) for _msg in node - if 'data' in _msg + if "data" in _msg ] await _send_node(messages) else: