mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 18:24:35 +00:00
fix(telegram): land #31067 first-chunk voice-fallback reply refs (@xdanger)
Landed from contributor PR #31067 by @xdanger. Co-authored-by: Kros Dai <xdanger@gmail.com>
This commit is contained in:
@@ -459,20 +459,35 @@ describe("deliverReplies", () => {
|
||||
text: "chunk-one\n\nchunk-two",
|
||||
replyToId: "77",
|
||||
audioAsVoice: true,
|
||||
channelData: {
|
||||
telegram: {
|
||||
buttons: [[{ text: "Ack", callback_data: "ack" }]],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
runtime,
|
||||
bot,
|
||||
replyToMode: "first",
|
||||
replyQuoteText: "quoted context",
|
||||
textLimit: 12,
|
||||
});
|
||||
|
||||
expect(sendVoice).toHaveBeenCalledTimes(1);
|
||||
expect(sendMessage.mock.calls.length).toBeGreaterThanOrEqual(2);
|
||||
expect(sendMessage.mock.calls[0][2]).toEqual(
|
||||
expect.objectContaining({
|
||||
reply_to_message_id: 77,
|
||||
reply_markup: {
|
||||
inline_keyboard: [[{ text: "Ack", callback_data: "ack" }]],
|
||||
},
|
||||
}),
|
||||
);
|
||||
expect(sendMessage.mock.calls[1][2]).not.toEqual(
|
||||
expect.objectContaining({ reply_to_message_id: 77 }),
|
||||
);
|
||||
expect(sendMessage.mock.calls[1][2]).not.toHaveProperty("reply_to_message_id");
|
||||
expect(sendMessage.mock.calls[1][2]).not.toHaveProperty("reply_parameters");
|
||||
expect(sendMessage.mock.calls[1][2]).not.toHaveProperty("reply_markup");
|
||||
});
|
||||
|
||||
it("rethrows non-VOICE_MESSAGES_FORBIDDEN errors from sendVoice", async () => {
|
||||
|
||||
@@ -682,15 +682,16 @@ async function sendTelegramVoiceFallbackText(opts: {
|
||||
let appliedReplyTo = false;
|
||||
for (let i = 0; i < chunks.length; i += 1) {
|
||||
const chunk = chunks[i];
|
||||
// Only apply reply reference, quote text, and buttons to the first chunk.
|
||||
const replyToForChunk = !appliedReplyTo ? opts.replyToId : undefined;
|
||||
await sendTelegramText(opts.bot, opts.chatId, chunk.html, opts.runtime, {
|
||||
replyToMessageId: replyToForChunk,
|
||||
replyQuoteText: opts.replyQuoteText,
|
||||
replyQuoteText: !appliedReplyTo ? opts.replyQuoteText : undefined,
|
||||
thread: opts.thread,
|
||||
textMode: "html",
|
||||
plainText: chunk.text,
|
||||
linkPreview: opts.linkPreview,
|
||||
replyMarkup: i === 0 ? opts.replyMarkup : undefined,
|
||||
replyMarkup: !appliedReplyTo ? opts.replyMarkup : undefined,
|
||||
});
|
||||
if (replyToForChunk) {
|
||||
appliedReplyTo = true;
|
||||
|
||||
Reference in New Issue
Block a user