fix: harden sessions_spawn delivery params and telegram account routing (#31000, #31110)

This commit is contained in:
Peter Steinberger
2026-03-02 02:35:26 +00:00
parent 684ac44b71
commit b0c7f1ebe2
6 changed files with 89 additions and 2 deletions

View File

@@ -911,6 +911,39 @@ describe("createTelegramBot", () => {
expect(payload.AccountId).toBe("opie");
expect(payload.SessionKey).toBe("agent:opie:main");
});
it("drops non-default account DMs without explicit bindings", async () => {
loadConfig.mockReturnValue({
channels: {
telegram: {
accounts: {
opie: {
botToken: "tok-opie",
dmPolicy: "open",
},
},
},
},
});
createTelegramBot({ token: "tok", accountId: "opie" });
const handler = getOnHandler("message") as (ctx: Record<string, unknown>) => Promise<void>;
await handler({
message: {
chat: { id: 123, type: "private" },
from: { id: 999, username: "testuser" },
text: "hello",
date: 1736380800,
message_id: 42,
},
me: { username: "openclaw_bot" },
getFile: async () => ({ download: async () => new Uint8Array() }),
});
expect(replySpy).not.toHaveBeenCalled();
});
it("applies group mention overrides and fallback behavior", async () => {
const cases: Array<{
config: Record<string, unknown>;