From e063f24a2850a4ee3ee948a1450b859e5420a0fd Mon Sep 17 00:00:00 2001 From: KimigaiiWuyi <444835641@qq.com> Date: Mon, 2 Sep 2024 04:44:57 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20=E4=BF=AE=E5=A4=8D=E5=8F=91?= =?UTF-8?q?=E9=80=81=E7=A9=BA=E6=B6=88=E6=81=AF=E5=AF=BC=E8=87=B4=E7=9A=84?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E4=BD=93=E4=B8=8D=E5=8F=AF=E8=A7=A3=E6=9E=90?= =?UTF-8?q?=20(#651)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- GenshinUID/client.py | 43 ++++++++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/GenshinUID/client.py b/GenshinUID/client.py index 8f816f78..d5644e93 100644 --- a/GenshinUID/client.py +++ b/GenshinUID/client.py @@ -346,6 +346,14 @@ class GsClient: def to_json(msg: list, name: str, uin: str): + ''' + result = [] + for i in msg: + if isinstance(i, Dict): + result.append(i) + else: + result.append(i.__dict__) + ''' return { "type": "node", "data": {"name": name, "uin": uin, "content": msg}, @@ -659,13 +667,17 @@ async def onebot_send( _temp_data = [] for i in _c.data: _temp_data.append(GsMessage(**i)) - await _send_node( + + send_forward = [ to_json( - await to_msg(_temp_data), + await to_msg([_msg]), "小助手", str(2854196310), ) - ) + for _msg in _temp_data + ] + + await _send_node(send_forward) elif _c.type == 'file': await to_file(_c.data) elif _c.type == 'at': @@ -687,18 +699,19 @@ async def onebot_send( ) result_msg = await to_msg(content) - if target_type == 'group': - await bot.call_api( - 'send_group_msg', - group_id=_target_id, - message=result_msg, - ) - else: - await bot.call_api( - 'send_private_msg', - user_id=_target_id, - message=result_msg, - ) + if result_msg: + if target_type == 'group': + await bot.call_api( + 'send_group_msg', + group_id=_target_id, + message=result_msg, + ) + else: + await bot.call_api( + 'send_private_msg', + user_id=_target_id, + message=result_msg, + ) async def onebot_red_send(