mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-28 05:16:23 -06:00
fix(telegram): preserve exact whitespace in selected reply quotes (#129254)
This commit is contained in:
committed by
GitHub
parent
03a7e5b000
commit
474d7855e4
@@ -1960,19 +1960,35 @@ describe("handleTelegramAction", () => {
|
||||
expectedOptions: { mediaUrl: "https://example.com/image.jpg" },
|
||||
},
|
||||
{
|
||||
name: "quoteText",
|
||||
name: "quoteText preserving exact whitespace",
|
||||
params: {
|
||||
action: "sendMessage",
|
||||
to: "123456",
|
||||
content: "Replying now",
|
||||
replyToMessageId: 144,
|
||||
quoteText: "The text you want to quote",
|
||||
quoteText: " The text you want to quote\n ",
|
||||
},
|
||||
expectedTo: "123456",
|
||||
expectedContent: "Replying now",
|
||||
expectedOptions: {
|
||||
replyToMessageId: 144,
|
||||
quoteText: "The text you want to quote",
|
||||
quoteText: " The text you want to quote\n ",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "snake-case quoteText preserving exact whitespace",
|
||||
params: {
|
||||
action: "sendMessage",
|
||||
to: "123456",
|
||||
content: "Replying now",
|
||||
replyToMessageId: 144,
|
||||
quote_text: " \nThe text you want to quote ",
|
||||
},
|
||||
expectedTo: "123456",
|
||||
expectedContent: "Replying now",
|
||||
expectedOptions: {
|
||||
replyToMessageId: 144,
|
||||
quoteText: " \nThe text you want to quote ",
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
@@ -673,7 +673,7 @@ export async function handleTelegramAction(
|
||||
// Optional threading parameters for forum topics and reply chains
|
||||
const replyToMessageId = readTelegramReplyToMessageId(params);
|
||||
const messageThreadId = readTelegramThreadId(params);
|
||||
const quoteText = readStringParam(params, "quoteText");
|
||||
const quoteText = readStringParam(params, "quoteText", { trim: false });
|
||||
const token = resolveTelegramToken(cfg, { accountId }).token;
|
||||
if (!token) {
|
||||
throw new Error(
|
||||
|
||||
@@ -262,7 +262,7 @@ describe("telegram actions contract", () => {
|
||||
channel: "telegram",
|
||||
action: "send",
|
||||
cfg: {} as OpenClawConfig,
|
||||
params: { quoteText: " original message " },
|
||||
params: { quoteText: " original message\n " },
|
||||
},
|
||||
to: "123456",
|
||||
payload: {
|
||||
@@ -277,7 +277,7 @@ describe("telegram actions contract", () => {
|
||||
channelData: {
|
||||
telegram: {
|
||||
parseMode: "MarkdownV2",
|
||||
quoteText: "original message",
|
||||
quoteText: " original message\n ",
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -299,7 +299,7 @@ describe("telegram actions contract", () => {
|
||||
channel: "telegram",
|
||||
action: "send",
|
||||
cfg: {} as OpenClawConfig,
|
||||
params: { quote_text: " snake case quote " },
|
||||
params: { quote_text: " \nsnake case quote " },
|
||||
},
|
||||
to: "123456",
|
||||
payload: { text: "Chart", presentation },
|
||||
@@ -307,7 +307,7 @@ describe("telegram actions contract", () => {
|
||||
).toEqual({
|
||||
text: "Chart",
|
||||
presentation,
|
||||
channelData: { telegram: { quoteText: "snake case quote" } },
|
||||
channelData: { telegram: { quoteText: " \nsnake case quote " } },
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ async function prepareTelegramSendPayload({
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
const quoteText = readStringParam(ctx.params, "quoteText");
|
||||
const quoteText = readStringParam(ctx.params, "quoteText", { trim: false });
|
||||
if (!quoteText) {
|
||||
return payload;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user