fix(telegram): cron and heartbeat messages land in wrong chat instead of target topic (#19367)

Merged via /review-pr -> /prepare-pr -> /merge-pr.

Prepared head SHA: bf02bbf9ce
Co-authored-by: Lukavyi <1013690+Lukavyi@users.noreply.github.com>
Co-authored-by: obviyus <22031114+obviyus@users.noreply.github.com>
Reviewed-by: @obviyus
This commit is contained in:
Taras Lukavyi
2026-02-18 11:01:01 +01:00
committed by GitHub
parent 114736ed1a
commit d833dcd731
11 changed files with 441 additions and 15 deletions

View File

@@ -305,6 +305,46 @@ describe("resolveHeartbeatDeliveryTarget", () => {
});
});
it("keeps explicit telegram targets", () => {
const cfg: OpenClawConfig = {
agents: { defaults: { heartbeat: { target: "telegram", to: "123" } } },
};
expect(resolveHeartbeatDeliveryTarget({ cfg, entry: baseEntry })).toEqual({
channel: "telegram",
to: "123",
accountId: undefined,
lastChannel: undefined,
lastAccountId: undefined,
});
});
it("parses threadId from :topic: suffix in heartbeat to", () => {
const cfg: OpenClawConfig = {
agents: {
defaults: {
heartbeat: { target: "telegram", to: "-100111:topic:42" },
},
},
};
const result = resolveHeartbeatDeliveryTarget({ cfg, entry: baseEntry });
expect(result.channel).toBe("telegram");
expect(result.to).toBe("-100111");
expect(result.threadId).toBe(42);
});
it("heartbeat to without :topic: has no threadId", () => {
const cfg: OpenClawConfig = {
agents: {
defaults: {
heartbeat: { target: "telegram", to: "-100111" },
},
},
};
const result = resolveHeartbeatDeliveryTarget({ cfg, entry: baseEntry });
expect(result.to).toBe("-100111");
expect(result.threadId).toBeUndefined();
});
it("uses explicit heartbeat accountId when provided", () => {
const cfg: OpenClawConfig = {
agents: {