refactor: 移除消息目标解析逻辑并设置默认权限

This commit is contained in:
sliverp
2026-02-05 20:35:12 +08:00
parent 0c22a89c6a
commit 611b4f4323
2 changed files with 10 additions and 12 deletions

View File

@@ -172,18 +172,6 @@ export const qqbotPlugin: ChannelPlugin<ResolvedQQBotAccount> = {
}); });
}, },
}, },
// 新增:消息目标解析
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: "<openid> or group:<groupOpenid>",
},
},
outbound: { outbound: {
deliveryMode: "direct", deliveryMode: "direct",
chunker: chunkText, chunker: chunkText,

View File

@@ -128,11 +128,16 @@ export function applyQQBotAccountConfig(
const next = { ...cfg }; const next = { ...cfg };
if (accountId === DEFAULT_ACCOUNT_ID) { if (accountId === DEFAULT_ACCOUNT_ID) {
// 如果没有设置过 allowFrom默认设置为 ["*"]
const existingConfig = (next.channels?.qqbot as QQBotChannelConfig) || {};
const allowFrom = existingConfig.allowFrom ?? ["*"];
next.channels = { next.channels = {
...next.channels, ...next.channels,
qqbot: { qqbot: {
...(next.channels?.qqbot as Record<string, unknown> || {}), ...(next.channels?.qqbot as Record<string, unknown> || {}),
enabled: true, enabled: true,
allowFrom,
...(input.appId ? { appId: input.appId } : {}), ...(input.appId ? { appId: input.appId } : {}),
...(input.clientSecret ...(input.clientSecret
? { clientSecret: input.clientSecret } ? { clientSecret: input.clientSecret }
@@ -144,6 +149,10 @@ export function applyQQBotAccountConfig(
}, },
}; };
} else { } else {
// 如果没有设置过 allowFrom默认设置为 ["*"]
const existingAccountConfig = (next.channels?.qqbot as QQBotChannelConfig)?.accounts?.[accountId] || {};
const allowFrom = existingAccountConfig.allowFrom ?? ["*"];
next.channels = { next.channels = {
...next.channels, ...next.channels,
qqbot: { qqbot: {
@@ -154,6 +163,7 @@ export function applyQQBotAccountConfig(
[accountId]: { [accountId]: {
...((next.channels?.qqbot as QQBotChannelConfig)?.accounts?.[accountId] || {}), ...((next.channels?.qqbot as QQBotChannelConfig)?.accounts?.[accountId] || {}),
enabled: true, enabled: true,
allowFrom,
...(input.appId ? { appId: input.appId } : {}), ...(input.appId ? { appId: input.appId } : {}),
...(input.clientSecret ...(input.clientSecret
? { clientSecret: input.clientSecret } ? { clientSecret: input.clientSecret }