惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Y
Y Combinator Blog
The GitHub Blog
The GitHub Blog
Vercel News
Vercel News
D
DataBreaches.Net
MongoDB | Blog
MongoDB | Blog
H
Help Net Security
小众软件
小众软件
美团技术团队
T
The Blog of Author Tim Ferriss
爱范儿
爱范儿
D
Docker
Martin Fowler
Martin Fowler
大猫的无限游戏
大猫的无限游戏
博客园 - 聂微东
Blog — PlanetScale
Blog — PlanetScale
H
Hackread – Cybersecurity News, Data Breaches, AI and More
罗磊的独立博客
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V
V2EX
S
SegmentFault 最新的问题
云风的 BLOG
云风的 BLOG
B
Blog
雷峰网
雷峰网
The Cloudflare Blog

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(telegram): preserve inbound text entities (#83873) · ...
jason-allen- · 2026-05-25 · via Recent Commits to openclaw:main

@@ -5,11 +5,11 @@ import {

55

buildTelegramThreadParams,

66

buildTypingThreadParams,

77

describeReplyTarget,

8-

expandTextLinks,

98

getTelegramTextParts,

109

hasBotMention,

1110

isBinaryContent,

1211

normalizeForwardedContext,

12+

renderTelegramTextEntities,

1313

resolveTelegramDirectPeerId,

1414

resolveTelegramForumFlag,

1515

resolveTelegramForumThreadId,

@@ -802,52 +802,55 @@ describe("hasBotMention", () => {

802802

).toBe(false);

803803

});

804804

});

805-

describe("expandTextLinks", () => {

806-

it("returns text unchanged when no entities are provided", () => {

807-

expect(expandTextLinks("Hello world")).toBe("Hello world");

808-

expect(expandTextLinks("Hello world", null)).toBe("Hello world");

809-

expect(expandTextLinks("Hello world", [])).toBe("Hello world");

810-

});

811805812-

it("returns text unchanged when there are no text_link entities", () => {

806+

describe("renderTelegramTextEntities", () => {

807+

it("renders Telegram formatting entities as markdown", () => {

808+

const text = "bold italic code strike underline spoiler";

813809

const entities = [

814-

{ type: "mention", offset: 0, length: 5 },

815-

{ type: "bold", offset: 6, length: 5 },

810+

{ type: "bold", offset: 0, length: 4 },

811+

{ type: "italic", offset: 5, length: 6 },

812+

{ type: "code", offset: 12, length: 4 },

813+

{ type: "strikethrough", offset: 17, length: 6 },

814+

{ type: "underline", offset: 24, length: 9 },

815+

{ type: "spoiler", offset: 34, length: 7 },

816816

];

817-

expect(expandTextLinks("@user hello", entities)).toBe("@user hello");

818-

});

819817820-

it("expands a single text_link entity", () => {

821-

const text = "Check this link for details";

822-

const entities = [{ type: "text_link", offset: 11, length: 4, url: "https://example.com" }];

823-

expect(expandTextLinks(text, entities)).toBe(

824-

"Check this [link](https://example.com) for details",

818+

expect(renderTelegramTextEntities(text, entities)).toBe(

819+

"**bold** _italic_ `code` ~~strike~~ __underline__ ||spoiler||",

825820

);

826821

});

827822828-

it("expands multiple text_link entities", () => {

829-

const text = "Visit Google or GitHub for more";

830-

const entities = [

831-

{ type: "text_link", offset: 6, length: 6, url: "https://google.com" },

832-

{ type: "text_link", offset: 16, length: 6, url: "https://github.com" },

833-

];

834-

expect(expandTextLinks(text, entities)).toBe(

835-

"Visit [Google](https://google.com) or [GitHub](https://github.com) for more",

836-

);

823+

it("renders pre entities with language fences", () => {

824+

const text = "const value = 1;";

825+

const entities = [{ type: "pre", offset: 0, length: text.length, language: "ts" }];

826+827+

expect(renderTelegramTextEntities(text, entities)).toBe("```ts\nconst value = 1;\n```");

837828

});

838829839-

it("handles adjacent text_link entities", () => {

840-

const text = "AB";

830+

it("uses a pre fence that cannot close inside content", () => {

831+

const text = "before\n```\ninside";

832+

const entities = [{ type: "pre", offset: 0, length: text.length, language: "md" }];

833+834+

expect(renderTelegramTextEntities(text, entities)).toBe("````md\nbefore\n```\ninside\n````");

835+

});

836+837+

it("renders links and formatting from original offsets", () => {

838+

const text = "Read docs now";

841839

const entities = [

842-

{ type: "text_link", offset: 0, length: 1, url: "https://a.example" },

843-

{ type: "text_link", offset: 1, length: 1, url: "https://b.example" },

840+

{ type: "bold", offset: 5, length: 4 },

841+

{ type: "text_link", offset: 5, length: 4, url: "https://docs.example" },

842+

{ type: "italic", offset: 10, length: 3 },

844843

];

845-

expect(expandTextLinks(text, entities)).toBe("[A](https://a.example)[B](https://b.example)");

844+845+

expect(renderTelegramTextEntities(text, entities)).toBe(

846+

"Read **[docs](https://docs.example)** _now_",

847+

);

846848

});

847849848-

it("preserves offsets from the original string", () => {

849-

const text = " Hello world";

850-

const entities = [{ type: "text_link", offset: 1, length: 5, url: "https://example.com" }];

851-

expect(expandTextLinks(text, entities)).toBe(" [Hello](https://example.com) world");

850+

it("uses UTF-16 Telegram offsets", () => {

851+

const text = "Hi 😀 bold";

852+

const entities = [{ type: "bold", offset: 6, length: 4 }];

853+854+

expect(renderTelegramTextEntities(text, entities)).toBe("Hi 😀 **bold**");

852855

});

853856

});