From 15a77b80708246fed23e17b41c839d4230c04c43 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: Mon, 29 Jul 2024 10:24:02 +0800 Subject: [PATCH] fix: bug --- src/onebot11/constructor.ts | 1 + src/onebot11/cqcode.ts | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/onebot11/constructor.ts b/src/onebot11/constructor.ts index e1b543ef..c2565cf8 100644 --- a/src/onebot11/constructor.ts +++ b/src/onebot11/constructor.ts @@ -330,6 +330,7 @@ export class OB11Constructor { } if (message_data.type !== 'unknown' && message_data.data) { const cqCode = encodeCQCode(message_data); + if (messagePostFormat === 'string') { (resMsg.message as string) += cqCode; } diff --git a/src/onebot11/cqcode.ts b/src/onebot11/cqcode.ts index 3928ce1e..f8fdee0e 100644 --- a/src/onebot11/cqcode.ts +++ b/src/onebot11/cqcode.ts @@ -66,10 +66,10 @@ export function encodeCQCode(data: OB11MessageData) { let result = '[CQ:' + data.type; for (const name in data.data) { - const value = data.data[name]; + let value = data.data[name]; try { // Check if the value can be converted to a string - value.toString(); + value = value.toString(); } catch (error) { // If it can't be converted, skip this name-value pair // console.warn(`Skipping problematic name-value pair. Name: ${name}, Value: ${value}`);