🐛 修复ntchat解析消息和reply问题 (#478)

* 修复ntchat消息解析和reply获取失败

* 增加re依赖

* 修复re匹配bug

* 🚨 `pre-commit-ci`修复格式错误

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Small_yu 2023-03-31 16:35:46 +08:00 committed by GitHub
parent 52e66b243a
commit d5ee87eaf0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,3 +1,4 @@
import re
from typing import Any, List, Literal, Optional
from nonebot.log import logger
@ -85,9 +86,18 @@ async def send_char_adv(bot: Bot, ev: Event):
user_id = raw_data['author_id']
msg_id = raw_data['message_id']
# ntchat
elif not messages and 'message' in raw_data:
elif 'data' in raw_data and 'from_wxid' in raw_data['data']:
messages = raw_data['message']
msg_id = str(raw_data['data']['msgid'])
if (
'raw_msg' in raw_data['data']
and 'xml' in raw_data['data']['raw_msg']
):
match = re.search(
r'<svrid>(\d+)</svrid>', raw_data['data']['raw_msg']
)
if match:
message.append(Message('reply', match.group(1)))
# onebot
elif 'sender' in raw_data:
if (