From 611b4f43232ef92a1894e8bdac1e97363ad5e390 Mon Sep 17 00:00:00 2001 From: sliverp Date: Thu, 5 Feb 2026 20:35:12 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E7=A7=BB=E9=99=A4=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E7=9B=AE=E6=A0=87=E8=A7=A3=E6=9E=90=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E5=B9=B6=E8=AE=BE=E7=BD=AE=E9=BB=98=E8=AE=A4=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/channel.ts | 12 ------------ src/config.ts | 10 ++++++++++ 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/channel.ts b/src/channel.ts index 80fe138..f824c1d 100644 --- a/src/channel.ts +++ b/src/channel.ts @@ -172,18 +172,6 @@ export const qqbotPlugin: ChannelPlugin = { }); }, }, - // 新增:消息目标解析 - messaging: { - normalizeTarget: (target) => { - // 支持格式: qqbot:openid, qqbot:group:xxx, openid, group:xxx - const normalized = target.replace(/^qqbot:/i, ""); - return { ok: true, to: normalized }; - }, - targetResolver: { - looksLikeId: (id) => /^[A-F0-9]{32}$/i.test(id) || id.startsWith("group:") || id.startsWith("channel:"), - hint: " or group:", - }, - }, outbound: { deliveryMode: "direct", chunker: chunkText, diff --git a/src/config.ts b/src/config.ts index 99678d2..0b92dc1 100644 --- a/src/config.ts +++ b/src/config.ts @@ -128,11 +128,16 @@ export function applyQQBotAccountConfig( const next = { ...cfg }; if (accountId === DEFAULT_ACCOUNT_ID) { + // 如果没有设置过 allowFrom,默认设置为 ["*"] + const existingConfig = (next.channels?.qqbot as QQBotChannelConfig) || {}; + const allowFrom = existingConfig.allowFrom ?? ["*"]; + next.channels = { ...next.channels, qqbot: { ...(next.channels?.qqbot as Record || {}), enabled: true, + allowFrom, ...(input.appId ? { appId: input.appId } : {}), ...(input.clientSecret ? { clientSecret: input.clientSecret } @@ -144,6 +149,10 @@ export function applyQQBotAccountConfig( }, }; } else { + // 如果没有设置过 allowFrom,默认设置为 ["*"] + const existingAccountConfig = (next.channels?.qqbot as QQBotChannelConfig)?.accounts?.[accountId] || {}; + const allowFrom = existingAccountConfig.allowFrom ?? ["*"]; + next.channels = { ...next.channels, qqbot: { @@ -154,6 +163,7 @@ export function applyQQBotAccountConfig( [accountId]: { ...((next.channels?.qqbot as QQBotChannelConfig)?.accounts?.[accountId] || {}), enabled: true, + allowFrom, ...(input.appId ? { appId: input.appId } : {}), ...(input.clientSecret ? { clientSecret: input.clientSecret }