From bc7b4dcc2a69008d8923eaebaf6344cf7e1ab8d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=89=8B=E7=93=9C=E4=B8=80=E5=8D=81=E9=9B=AA?= Date: Thu, 23 May 2024 15:16:35 +0800 Subject: [PATCH] build: 1.4.0-beta5 --- src/onebot11/action/msg/SendMsg/create-send-elements.ts | 8 +------- src/onebot11/constructor.ts | 7 ++++++- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/onebot11/action/msg/SendMsg/create-send-elements.ts b/src/onebot11/action/msg/SendMsg/create-send-elements.ts index 0942f0ff..e138b1d2 100644 --- a/src/onebot11/action/msg/SendMsg/create-send-elements.ts +++ b/src/onebot11/action/msg/SendMsg/create-send-elements.ts @@ -69,13 +69,7 @@ const _handlers: { context: MessageContext ) => SendMessageElement | undefined | Promise } = { - [OB11MessageDataType.text]: ({ data: { text } }) => { - //如果匹配\n \r\n失败则 将全部\r转换为\n 兼容QQ 9.7.x(非NT架构) - if (!text.match(/\r\n/g) && !text.match(/\n/g)) { - text = text.replace(/\r/g, '\n'); - } - return SendMsgElementConstructor.text(text); - }, + [OB11MessageDataType.text]: ({ data: { text } }) => SendMsgElementConstructor.text(text), [OB11MessageDataType.at]: async ({ data: { qq: atQQ } }, context) => { if (!context.group) return undefined; diff --git a/src/onebot11/constructor.ts b/src/onebot11/constructor.ts index 4a850972..1cfcaa8d 100644 --- a/src/onebot11/constructor.ts +++ b/src/onebot11/constructor.ts @@ -120,10 +120,15 @@ export class OB11Constructor { } else if (element.textElement) { message_data['type'] = 'text'; - const text = element.textElement.content; + + let text = element.textElement.content; if (!text.trim()) { continue; } + // 兼容 9.7.x 换行符 + if (text.indexOf('\n') === -1 && text.indexOf('\r\n') === -1) { + text = text.replace(/\r/g, '\n'); + } message_data['data']['text'] = text; } else if (element.replyElement) {