mirror of https://github.com/openclaw/openclaw.git
fix(telegram): add allow_sending_without_reply to prevent lost messages
When a Telegram message that OpenClaw is replying to gets deleted before delivery, the Telegram API rejects the entire sendMessage call with "message to be replied not found". This causes the bot's response to be silently lost and stuck in the failed delivery queue permanently. Setting allow_sending_without_reply: true tells Telegram to deliver the message as a standalone message if the reply target no longer exists, instead of failing the entire request. Applied to all 6 locations across 4 source files where reply_to_message_id is set: - send.ts: buildTelegramReplyParams (both reply_parameters and plain reply) - bot/delivery.send.ts: buildTelegramSendParams - draft-stream.ts: draft stream reply params - bot-handlers.runtime.ts: error reply messages (file too large, media download failed) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
3547b5fd1e
commit
d264c761cb
|
|
@ -1017,6 +1017,7 @@ export const registerTelegramHandlers = ({
|
|||
fn: () =>
|
||||
bot.api.sendMessage(chatId, `⚠️ File too large. Maximum size is ${limitMb}MB.`, {
|
||||
reply_to_message_id: msg.message_id,
|
||||
allow_sending_without_reply: true,
|
||||
}),
|
||||
}).catch(() => {});
|
||||
}
|
||||
|
|
@ -1030,6 +1031,7 @@ export const registerTelegramHandlers = ({
|
|||
fn: () =>
|
||||
bot.api.sendMessage(chatId, "⚠️ Failed to download media. Please try again.", {
|
||||
reply_to_message_id: msg.message_id,
|
||||
allow_sending_without_reply: true,
|
||||
}),
|
||||
}).catch(() => {});
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -82,6 +82,7 @@ export function buildTelegramSendParams(opts?: {
|
|||
const params: Record<string, unknown> = {};
|
||||
if (opts?.replyToMessageId) {
|
||||
params.reply_to_message_id = opts.replyToMessageId;
|
||||
params.allow_sending_without_reply = true;
|
||||
}
|
||||
if (threadParams) {
|
||||
params.message_thread_id = threadParams.message_thread_id;
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ export function createTelegramDraftStream(params: {
|
|||
const threadParams = buildTelegramThreadParams(params.thread);
|
||||
const replyParams =
|
||||
params.replyToMessageId != null
|
||||
? { ...threadParams, reply_to_message_id: params.replyToMessageId }
|
||||
? { ...threadParams, reply_to_message_id: params.replyToMessageId, allow_sending_without_reply: true }
|
||||
: threadParams;
|
||||
const resolvedDraftApi = prefersDraftTransport
|
||||
? resolveSendMessageDraftApi(params.api)
|
||||
|
|
|
|||
|
|
@ -394,9 +394,11 @@ function buildTelegramThreadReplyParams(params: {
|
|||
threadParams.reply_parameters = {
|
||||
message_id: replyToMessageId,
|
||||
quote: params.quoteText.trim(),
|
||||
allow_sending_without_reply: true,
|
||||
};
|
||||
} else {
|
||||
threadParams.reply_to_message_id = replyToMessageId;
|
||||
threadParams.allow_sending_without_reply = true;
|
||||
}
|
||||
}
|
||||
return threadParams;
|
||||
|
|
|
|||
Loading…
Reference in New Issue