fix: prevent duplicate Telegram messages on "not modified" edit (#254)

* fix: prevent duplicate Telegram messages on "not modified" edit

When streaming completes and the final editMessage call sends identical
content, Telegram returns "message is not modified". The catch block
treated this as a real failure and bubbled up to bot.ts, which fell back
to sending the response as a brand-new message -- causing duplicates.

Now the Telegram adapter silently returns on "message is not modified"
since the content is already correct.

Written by Cameron ◯ Letta Code

"The simplest fix is the one that doesn't fight the API."

* fix: update package-lock.json for remark/mdast dependencies

PR #234 (Slack mrkdwn formatter) added remark-gfm and related mdast
packages but the lockfile wasn't regenerated, causing npm ci to fail
in CI with "Missing from lock file" errors.

Written by Cameron ◯ Letta Code

"The lockfile remembers what package.json forgets."
This commit is contained in:
Cameron
2026-02-10 11:53:51 -08:00
committed by GitHub
parent a4934a77d4
commit dad510150a
2 changed files with 1166 additions and 5 deletions

1167
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -504,7 +504,9 @@ export class TelegramAdapter implements ChannelAdapter {
try {
const formatted = await markdownToTelegramV2(text);
await this.bot.api.editMessageText(chatId, Number(messageId), formatted, { parse_mode: 'MarkdownV2' });
} catch (e) {
} catch (e: any) {
// "message is not modified" means content is already up-to-date -- harmless, don't retry
if (e?.description?.includes('message is not modified')) return;
// If MarkdownV2 fails, fall back to plain text (mirrors sendMessage fallback)
console.warn('[Telegram] MarkdownV2 edit failed, falling back to raw text:', e);
await this.bot.api.editMessageText(chatId, Number(messageId), text);