mirror of
https://github.com/KimigaiiWuyi/GenshinUID.git
synced 2025-05-11 22:45:51 +08:00
🐛 修复发送空消息导致的消息体不可解析 (#651)
This commit is contained in:
parent
071adb7efc
commit
e063f24a28
@ -346,6 +346,14 @@ class GsClient:
|
|||||||
|
|
||||||
|
|
||||||
def to_json(msg: list, name: str, uin: str):
|
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 {
|
return {
|
||||||
"type": "node",
|
"type": "node",
|
||||||
"data": {"name": name, "uin": uin, "content": msg},
|
"data": {"name": name, "uin": uin, "content": msg},
|
||||||
@ -659,13 +667,17 @@ async def onebot_send(
|
|||||||
_temp_data = []
|
_temp_data = []
|
||||||
for i in _c.data:
|
for i in _c.data:
|
||||||
_temp_data.append(GsMessage(**i))
|
_temp_data.append(GsMessage(**i))
|
||||||
await _send_node(
|
|
||||||
|
send_forward = [
|
||||||
to_json(
|
to_json(
|
||||||
await to_msg(_temp_data),
|
await to_msg([_msg]),
|
||||||
"小助手",
|
"小助手",
|
||||||
str(2854196310),
|
str(2854196310),
|
||||||
)
|
)
|
||||||
)
|
for _msg in _temp_data
|
||||||
|
]
|
||||||
|
|
||||||
|
await _send_node(send_forward)
|
||||||
elif _c.type == 'file':
|
elif _c.type == 'file':
|
||||||
await to_file(_c.data)
|
await to_file(_c.data)
|
||||||
elif _c.type == 'at':
|
elif _c.type == 'at':
|
||||||
@ -687,18 +699,19 @@ async def onebot_send(
|
|||||||
)
|
)
|
||||||
|
|
||||||
result_msg = await to_msg(content)
|
result_msg = await to_msg(content)
|
||||||
if target_type == 'group':
|
if result_msg:
|
||||||
await bot.call_api(
|
if target_type == 'group':
|
||||||
'send_group_msg',
|
await bot.call_api(
|
||||||
group_id=_target_id,
|
'send_group_msg',
|
||||||
message=result_msg,
|
group_id=_target_id,
|
||||||
)
|
message=result_msg,
|
||||||
else:
|
)
|
||||||
await bot.call_api(
|
else:
|
||||||
'send_private_msg',
|
await bot.call_api(
|
||||||
user_id=_target_id,
|
'send_private_msg',
|
||||||
message=result_msg,
|
user_id=_target_id,
|
||||||
)
|
message=result_msg,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
async def onebot_red_send(
|
async def onebot_red_send(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user