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

推荐订阅源

H
Help Net Security
爱范儿
爱范儿
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园 - 三生石上(FineUI控件)
大猫的无限游戏
大猫的无限游戏
Hugging Face - Blog
Hugging Face - Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Vercel News
Vercel News
人人都是产品经理
人人都是产品经理
G
Google Developers Blog
WordPress大学
WordPress大学
S
SegmentFault 最新的问题
雷峰网
雷峰网
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Jina AI
Jina AI
博客园 - 叶小钗
D
DataBreaches.Net
D
Docker
月光博客
月光博客
博客园 - 司徒正美
Last Week in AI
Last Week in AI
有赞技术团队
有赞技术团队
腾讯CDC
酷 壳 – CoolShell
酷 壳 – CoolShell

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): honor outbound reaction directives (#94977...
hugenshen · 2026-06-22 · via Recent Commits to openclaw:main

@@ -5,10 +5,12 @@ import { beforeEach, describe, expect, it, vi } from "vitest";

5566

const sendMessageTelegramMock = vi.fn();

77

const pinMessageTelegramMock = vi.fn();

8+

const reactMessageTelegramMock = vi.fn();

89

const sendPollTelegramMock = vi.fn();

9101011

vi.mock("./send.js", () => ({

1112

pinMessageTelegram: (...args: unknown[]) => pinMessageTelegramMock(...args),

13+

reactMessageTelegram: (...args: unknown[]) => reactMessageTelegramMock(...args),

1214

sendPollTelegram: (...args: unknown[]) => sendPollTelegramMock(...args),

1315

sendMessageTelegram: (...args: unknown[]) => sendMessageTelegramMock(...args),

1416

}));

@@ -60,6 +62,7 @@ function callOptionsFromEnd(

6062

describe("telegramOutbound", () => {

6163

beforeEach(() => {

6264

pinMessageTelegramMock.mockReset();

65+

reactMessageTelegramMock.mockReset();

6366

sendPollTelegramMock.mockReset();

6467

sendMessageTelegramMock.mockReset();

6568

});

@@ -155,6 +158,151 @@ describe("telegramOutbound", () => {

155158

expect(result).toEqual({ channel: "telegram", messageId: "tg-buttons", chatId: "12345" });

156159

});

157160161+

it("applies reaction-only payloads without sending empty Telegram text", async () => {

162+

reactMessageTelegramMock.mockResolvedValueOnce({ ok: true });

163+164+

const result = await telegramOutbound.sendPayload!({

165+

cfg: {} as never,

166+

to: "12345",

167+

text: "",

168+

replyToId: "777",

169+

payload: {

170+

channelData: {

171+

telegram: {

172+

reaction: { emoji: "🔥" },

173+

},

174+

},

175+

},

176+

deps: { sendTelegram: sendMessageTelegramMock },

177+

});

178+179+

expect(reactMessageTelegramMock).toHaveBeenCalledWith("12345", 777, "🔥", {

180+

cfg: {},

181+

verbose: false,

182+

accountId: undefined,

183+

gatewayClientScopes: undefined,

184+

});

185+

expect(sendMessageTelegramMock).not.toHaveBeenCalled();

186+

expect(result).toEqual({ channel: "telegram", messageId: "777", chatId: "12345" });

187+

});

188+189+

it("applies reaction payloads before sending visible text", async () => {

190+

reactMessageTelegramMock.mockResolvedValueOnce({ ok: true });

191+

sendMessageTelegramMock.mockResolvedValueOnce({ messageId: "tg-text", chatId: "12345" });

192+193+

await telegramOutbound.sendPayload!({

194+

cfg: {} as never,

195+

to: "12345",

196+

text: "",

197+

accountId: "ops",

198+

replyToId: "777",

199+

payload: {

200+

text: "Done",

201+

channelData: {

202+

telegram: {

203+

reaction: { emoji: "✅" },

204+

},

205+

},

206+

},

207+

deps: { sendTelegram: sendMessageTelegramMock },

208+

});

209+210+

expect(reactMessageTelegramMock).toHaveBeenCalledWith(

211+

"12345",

212+

777,

213+

"✅",

214+

expect.objectContaining({ accountId: "ops" }),

215+

);

216+

expect(sendMessageTelegramMock).toHaveBeenCalledWith(

217+

"12345",

218+

"Done",

219+

expect.objectContaining({ accountId: "ops", replyToMessageId: 777 }),

220+

);

221+

expect(reactMessageTelegramMock.mock.invocationCallOrder[0]).toBeLessThan(

222+

sendMessageTelegramMock.mock.invocationCallOrder[0],

223+

);

224+

});

225+226+

it("rejects text plus reaction payloads without a reply target", async () => {

227+

await expect(

228+

telegramOutbound.sendPayload!({

229+

cfg: {} as never,

230+

to: "12345",

231+

text: "",

232+

payload: {

233+

text: "Done",

234+

channelData: { telegram: { reaction: { emoji: "🔥" } } },

235+

},

236+

deps: { sendTelegram: sendMessageTelegramMock },

237+

}),

238+

).rejects.toThrow("Telegram reaction requires a reply target");

239+240+

expect(reactMessageTelegramMock).not.toHaveBeenCalled();

241+

expect(sendMessageTelegramMock).not.toHaveBeenCalled();

242+

});

243+244+

it("rejects text plus reaction payloads when Telegram refuses the emoji", async () => {

245+

reactMessageTelegramMock.mockResolvedValueOnce({

246+

ok: false,

247+

warning: "Reaction unavailable: not-supported",

248+

});

249+250+

await expect(

251+

telegramOutbound.sendPayload!({

252+

cfg: {} as never,

253+

to: "12345",

254+

text: "",

255+

replyToId: "777",

256+

payload: {

257+

text: "Done",

258+

channelData: { telegram: { reaction: { emoji: "not-supported" } } },

259+

},

260+

deps: { sendTelegram: sendMessageTelegramMock },

261+

}),

262+

).rejects.toThrow("Reaction unavailable: not-supported");

263+264+

expect(sendMessageTelegramMock).not.toHaveBeenCalled();

265+

});

266+267+

it("rejects reaction-only payloads without a reply target", async () => {

268+

await expect(

269+

telegramOutbound.sendPayload!({

270+

cfg: {} as never,

271+

to: "12345",

272+

text: "",

273+

payload: {

274+

channelData: { telegram: { reaction: { emoji: "🔥" } } },

275+

},

276+

deps: { sendTelegram: sendMessageTelegramMock },

277+

}),

278+

).rejects.toThrow("Telegram reaction requires a reply target");

279+280+

expect(reactMessageTelegramMock).not.toHaveBeenCalled();

281+

expect(sendMessageTelegramMock).not.toHaveBeenCalled();

282+

});

283+284+

it("rejects reaction-only payloads when Telegram refuses the emoji", async () => {

285+

reactMessageTelegramMock.mockResolvedValueOnce({

286+

ok: false,

287+

warning: "Reaction unavailable: not-supported",

288+

});

289+290+

await expect(

291+

telegramOutbound.sendPayload!({

292+

cfg: {} as never,

293+

to: "12345",

294+

text: "",

295+

replyToId: "777",

296+

payload: {

297+

channelData: { telegram: { reaction: { emoji: "not-supported" } } },

298+

},

299+

deps: { sendTelegram: sendMessageTelegramMock },

300+

}),

301+

).rejects.toThrow("Reaction unavailable: not-supported");

302+303+

expect(sendMessageTelegramMock).not.toHaveBeenCalled();

304+

});

305+158306

it("uses presentation button labels as fallback text for presentation-only payloads", async () => {

159307

sendMessageTelegramMock.mockResolvedValueOnce({

160308

messageId: "tg-presentation-buttons",