Skip to content

Commit 474d785

Browse files
authored
fix(telegram): preserve exact whitespace in selected reply quotes (#129254)
1 parent 03a7e5b commit 474d785

4 files changed

Lines changed: 25 additions & 9 deletions

File tree

‎extensions/telegram/src/action-runtime.test.ts‎

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1960,19 +1960,35 @@ describe("handleTelegramAction", () => {
19601960
expectedOptions: { mediaUrl: "https://example.com/image.jpg" },
19611961
},
19621962
{
1963-
name: "quoteText",
1963+
name: "quoteText preserving exact whitespace",
19641964
params: {
19651965
action: "sendMessage",
19661966
to: "123456",
19671967
content: "Replying now",
19681968
replyToMessageId: 144,
1969-
quoteText: "The text you want to quote",
1969+
quoteText: " The text you want to quote\n ",
19701970
},
19711971
expectedTo: "123456",
19721972
expectedContent: "Replying now",
19731973
expectedOptions: {
19741974
replyToMessageId: 144,
1975-
quoteText: "The text you want to quote",
1975+
quoteText: " The text you want to quote\n ",
1976+
},
1977+
},
1978+
{
1979+
name: "snake-case quoteText preserving exact whitespace",
1980+
params: {
1981+
action: "sendMessage",
1982+
to: "123456",
1983+
content: "Replying now",
1984+
replyToMessageId: 144,
1985+
quote_text: " \nThe text you want to quote ",
1986+
},
1987+
expectedTo: "123456",
1988+
expectedContent: "Replying now",
1989+
expectedOptions: {
1990+
replyToMessageId: 144,
1991+
quoteText: " \nThe text you want to quote ",
19761992
},
19771993
},
19781994
{

‎extensions/telegram/src/action-runtime.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ export async function handleTelegramAction(
673673
// Optional threading parameters for forum topics and reply chains
674674
const replyToMessageId = readTelegramReplyToMessageId(params);
675675
const messageThreadId = readTelegramThreadId(params);
676-
const quoteText = readStringParam(params, "quoteText");
676+
const quoteText = readStringParam(params, "quoteText", { trim: false });
677677
const token = resolveTelegramToken(cfg, { accountId }).token;
678678
if (!token) {
679679
throw new Error(

‎extensions/telegram/src/channel-actions.contract.test.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ describe("telegram actions contract", () => {
262262
channel: "telegram",
263263
action: "send",
264264
cfg: {} as OpenClawConfig,
265-
params: { quoteText: " original message " },
265+
params: { quoteText: " original message\n " },
266266
},
267267
to: "123456",
268268
payload: {
@@ -277,7 +277,7 @@ describe("telegram actions contract", () => {
277277
channelData: {
278278
telegram: {
279279
parseMode: "MarkdownV2",
280-
quoteText: "original message",
280+
quoteText: " original message\n ",
281281
},
282282
},
283283
});
@@ -299,15 +299,15 @@ describe("telegram actions contract", () => {
299299
channel: "telegram",
300300
action: "send",
301301
cfg: {} as OpenClawConfig,
302-
params: { quote_text: " snake case quote " },
302+
params: { quote_text: " \nsnake case quote " },
303303
},
304304
to: "123456",
305305
payload: { text: "Chart", presentation },
306306
}),
307307
).toEqual({
308308
text: "Chart",
309309
presentation,
310-
channelData: { telegram: { quoteText: "snake case quote" } },
310+
channelData: { telegram: { quoteText: " \nsnake case quote " } },
311311
});
312312
});
313313

‎extensions/telegram/src/channel-actions.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ async function prepareTelegramSendPayload({
8484
) {
8585
return null;
8686
}
87-
const quoteText = readStringParam(ctx.params, "quoteText");
87+
const quoteText = readStringParam(ctx.params, "quoteText", { trim: false });
8888
if (!quoteText) {
8989
return payload;
9090
}

0 commit comments

Comments
 (0)