fix(telegram): treat 'message not modified' as success to prevent duplication and downgrade edit failure log
This commit is contained in:
parent
89c74e636b
commit
1589dfcf72
@ -102,7 +102,7 @@ export async function deliverReplies(params: {
|
||||
});
|
||||
sentMessageId = editId;
|
||||
} catch (err) {
|
||||
logVerbose(`Telegram edit failed, falling back to new message: ${String(err)}`);
|
||||
console.warn(`Telegram edit failed, falling back to new message: ${String(err)}`);
|
||||
// Fall through to send new message
|
||||
}
|
||||
}
|
||||
|
||||
@ -59,6 +59,7 @@ type TelegramReactionOpts = {
|
||||
retry?: RetryConfig;
|
||||
};
|
||||
|
||||
const NOT_MODIFIED_RE = /message is not modified/i;
|
||||
const PARSE_ERR_RE = /can't parse entities|parse entities|find end of the entity/i;
|
||||
|
||||
function resolveToken(explicit: string | undefined, params: { accountId: string; token: string }) {
|
||||
@ -525,6 +526,10 @@ export async function editMessageTelegram(
|
||||
} catch (err) {
|
||||
// If HTML parsing fails, fall back to plain text
|
||||
const errText = formatErrorMessage(err);
|
||||
if (NOT_MODIFIED_RE.test(errText)) {
|
||||
logVerbose(`[telegram] Edit failed with 'not modified', treating as success: ${errText}`);
|
||||
return { ok: true };
|
||||
}
|
||||
if (PARSE_ERR_RE.test(errText)) {
|
||||
if (opts.verbose) {
|
||||
console.warn(`telegram HTML parse failed on edit, retrying as plain text: ${errText}`);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user