mirror of
https://github.com/moltbot/moltbot.git
synced 2026-04-27 00:17:29 +00:00
fix: preserve explicit Telegram topic targets on replies (#59634) (thanks @dashhuang)
This commit is contained in:
@@ -17,7 +17,7 @@ describe("resolveTelegramAutoThreadId", () => {
|
||||
it("matches chats across Telegram target formats", () => {
|
||||
expect(
|
||||
resolveTelegramAutoThreadId({
|
||||
to: "telegram:group:-100123:topic:77",
|
||||
to: "telegram:group:-100123",
|
||||
toolContext: createToolContext(),
|
||||
}),
|
||||
).toBe("thread-1");
|
||||
@@ -36,4 +36,13 @@ describe("resolveTelegramAutoThreadId", () => {
|
||||
}),
|
||||
).toBeUndefined();
|
||||
});
|
||||
|
||||
it("does not override an explicit target topic", () => {
|
||||
expect(
|
||||
resolveTelegramAutoThreadId({
|
||||
to: "telegram:group:-100123:topic:77",
|
||||
toolContext: createToolContext(),
|
||||
}),
|
||||
).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -9,6 +9,9 @@ export function resolveTelegramAutoThreadId(params: {
|
||||
return undefined;
|
||||
}
|
||||
const parsedTo = parseTelegramTarget(params.to);
|
||||
if (parsedTo.messageThreadId != null) {
|
||||
return undefined;
|
||||
}
|
||||
const parsedChannel = parseTelegramTarget(context.currentChannelId);
|
||||
if (parsedTo.chatId.toLowerCase() !== parsedChannel.chatId.toLowerCase()) {
|
||||
return undefined;
|
||||
|
||||
@@ -268,6 +268,20 @@ describe("telegramPlugin threading", () => {
|
||||
|
||||
expect(resolved).toBe("533274");
|
||||
});
|
||||
|
||||
it("does not override an explicit target topic when replyToId is present", () => {
|
||||
const resolved = telegramPlugin.threading?.resolveAutoThreadId?.({
|
||||
cfg: createCfg(),
|
||||
to: "telegram:-1001:topic:99",
|
||||
replyToId: "4103",
|
||||
toolContext: {
|
||||
currentChannelId: "telegram:-1001:topic:77",
|
||||
currentThreadTs: "77",
|
||||
},
|
||||
});
|
||||
|
||||
expect(resolved).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe("telegramPlugin bindings", () => {
|
||||
|
||||
Reference in New Issue
Block a user