diff --git a/extensions/qqbot/src/channel.setup.ts b/extensions/qqbot/src/channel.setup.ts index 269649f3b43..8c4c3deb3ce 100644 --- a/extensions/qqbot/src/channel.setup.ts +++ b/extensions/qqbot/src/channel.setup.ts @@ -156,7 +156,8 @@ export const qqbotSetupPlugin: ChannelPlugin = { }), }, setup: { - resolveAccountId: ({ accountId }) => accountId?.trim().toLowerCase() || DEFAULT_ACCOUNT_ID, + resolveAccountId: ({ cfg, accountId }) => + accountId?.trim().toLowerCase() || resolveDefaultQQBotAccountId(cfg), applyAccountName: ({ cfg, accountId, name }) => applyAccountNameToChannelSection({ cfg, diff --git a/extensions/qqbot/src/channel.ts b/extensions/qqbot/src/channel.ts index bbd36a534a7..913f55915a0 100644 --- a/extensions/qqbot/src/channel.ts +++ b/extensions/qqbot/src/channel.ts @@ -109,7 +109,8 @@ export const qqbotPlugin: ChannelPlugin = { .map((entry) => entry.toUpperCase()), }, setup: { - resolveAccountId: ({ accountId }) => accountId?.trim().toLowerCase() || DEFAULT_ACCOUNT_ID, + resolveAccountId: ({ cfg, accountId }) => + accountId?.trim().toLowerCase() || resolveDefaultQQBotAccountId(cfg), applyAccountName: ({ cfg, accountId, name }) => applyAccountNameToChannelSection({ cfg, diff --git a/extensions/qqbot/src/config.test.ts b/extensions/qqbot/src/config.test.ts index 55eda7e3b37..23544a15051 100644 --- a/extensions/qqbot/src/config.test.ts +++ b/extensions/qqbot/src/config.test.ts @@ -345,6 +345,27 @@ describe("qqbot config", () => { }); }); + it("uses configured defaultAccount when runtime setup accountId is omitted", () => { + const runtimeSetup = qqbotPlugin.setup; + expect(runtimeSetup).toBeDefined(); + + expect( + runtimeSetup!.resolveAccountId?.({ + cfg: { + channels: { + qqbot: { + defaultAccount: "bot2", + accounts: { + bot2: { appId: "123456" }, + }, + }, + }, + } as OpenClawConfig, + accountId: undefined, + } as never), + ).toBe("bot2"); + }); + it("rejects --use-env for named accounts across setup paths", () => { const runtimeSetup = qqbotPlugin.setup; const lightweightSetup = qqbotSetupPlugin.setup; diff --git a/extensions/qqbot/src/setup.test.ts b/extensions/qqbot/src/setup.test.ts index 75ea18cd7cb..985d423cb7f 100644 --- a/extensions/qqbot/src/setup.test.ts +++ b/extensions/qqbot/src/setup.test.ts @@ -127,4 +127,25 @@ describe("qqbot setup", () => { } as never), ).toBe("bot2"); }); + + it("uses configured defaultAccount when setup accountId is omitted", () => { + const setup = qqbotSetupPlugin.setup; + expect(setup).toBeDefined(); + + expect( + setup!.resolveAccountId?.({ + cfg: { + channels: { + qqbot: { + defaultAccount: "bot2", + accounts: { + bot2: { appId: "123456" }, + }, + }, + }, + } as OpenClawConfig, + accountId: undefined, + } as never), + ).toBe("bot2"); + }); });