fix: honor qqbot setup default account

This commit is contained in:
Tak Hoffman
2026-04-03 13:10:42 -05:00
parent 181bd6327f
commit 5c4551458f
4 changed files with 46 additions and 2 deletions

View File

@@ -156,7 +156,8 @@ export const qqbotSetupPlugin: ChannelPlugin<ResolvedQQBotAccount> = {
}),
},
setup: {
resolveAccountId: ({ accountId }) => accountId?.trim().toLowerCase() || DEFAULT_ACCOUNT_ID,
resolveAccountId: ({ cfg, accountId }) =>
accountId?.trim().toLowerCase() || resolveDefaultQQBotAccountId(cfg),
applyAccountName: ({ cfg, accountId, name }) =>
applyAccountNameToChannelSection({
cfg,

View File

@@ -109,7 +109,8 @@ export const qqbotPlugin: ChannelPlugin<ResolvedQQBotAccount> = {
.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,

View File

@@ -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;

View File

@@ -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");
});
});