From d5ee87eaf0570bf57b0fa470c02c2f79e4741bcc Mon Sep 17 00:00:00 2001 From: Small_yu Date: Fri, 31 Mar 2023 16:35:46 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20=E4=BF=AE=E5=A4=8Dntchat?= =?UTF-8?q?=E8=A7=A3=E6=9E=90=E6=B6=88=E6=81=AF=E5=92=8Creply=E9=97=AE?= =?UTF-8?q?=E9=A2=98=20(#478)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 修复ntchat消息解析和reply获取失败 * 增加re依赖 * 修复re匹配bug * 🚨 `pre-commit-ci`修复格式错误 --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- GenshinUID/__init__.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/GenshinUID/__init__.py b/GenshinUID/__init__.py index a78ac012..4cd08347 100644 --- a/GenshinUID/__init__.py +++ b/GenshinUID/__init__.py @@ -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'(\d+)', raw_data['data']['raw_msg'] + ) + if match: + message.append(Message('reply', match.group(1))) # onebot elif 'sender' in raw_data: if (