@@ -1250,7 +1250,7 @@ describe("createTelegramBot", () => {
|
1250 | 1250 | } |
1251 | 1251 | }); |
1252 | 1252 | |
1253 | | -it("routes callback_query payloads as messages and answers callbacks", async () => { |
| 1253 | +it("routes generic callback_query payloads as callback_data messages and answers callbacks", async () => { |
1254 | 1254 | createTelegramBot({ token: "tok" }); |
1255 | 1255 | const callbackHandler = requireValue( |
1256 | 1256 | onSpy.mock.calls.find((call) => call[0] === "callback_query")?.[1] as |
@@ -1276,10 +1276,41 @@ describe("createTelegramBot", () => {
|
1276 | 1276 | |
1277 | 1277 | expect(replySpy).toHaveBeenCalledTimes(1); |
1278 | 1278 | const payload = requireValue(replySpy.mock.calls.at(0), "replySpy call")[0]; |
1279 | | -expect(payload.Body).toContain("cmd:option_a"); |
| 1279 | +expect(payload.Body).toContain("callback_data: cmd:option_a"); |
1280 | 1280 | expect(answerCallbackQuerySpy).toHaveBeenCalledWith("cbq-1"); |
1281 | 1281 | }); |
1282 | 1282 | |
| 1283 | +it("preserves raw slash callback_query payloads as command text", async () => { |
| 1284 | +createTelegramBot({ token: "tok" }); |
| 1285 | +const callbackHandler = requireValue( |
| 1286 | +onSpy.mock.calls.find((call) => call[0] === "callback_query")?.[1] as |
| 1287 | +| ((ctx: Record<string, unknown>) => Promise<void>) |
| 1288 | +| undefined, |
| 1289 | +"callback_query handler", |
| 1290 | +); |
| 1291 | + |
| 1292 | +await callbackHandler({ |
| 1293 | +callbackQuery: { |
| 1294 | +id: "cbq-slash-1", |
| 1295 | +data: "/fast status", |
| 1296 | +from: { id: 9, first_name: "Ada", username: "ada_bot" }, |
| 1297 | +message: { |
| 1298 | +chat: { id: 1234, type: "private" }, |
| 1299 | +date: 1736380800, |
| 1300 | +message_id: 10, |
| 1301 | +}, |
| 1302 | +}, |
| 1303 | +me: { username: "openclaw_bot" }, |
| 1304 | +getFile: async () => ({ download: async () => new Uint8Array() }), |
| 1305 | +}); |
| 1306 | + |
| 1307 | +expect(replySpy).toHaveBeenCalledTimes(1); |
| 1308 | +const payload = requireValue(replySpy.mock.calls.at(0), "replySpy call")[0]; |
| 1309 | +expect(payload.Body).toContain("/fast status"); |
| 1310 | +expect(payload.Body).not.toContain("callback_data: /fast status"); |
| 1311 | +expect(answerCallbackQuerySpy).toHaveBeenCalledWith("cbq-slash-1"); |
| 1312 | +}); |
| 1313 | + |
1283 | 1314 | it("does not route opaque callback_query payloads as synthetic commands", async () => { |
1284 | 1315 | createTelegramBot({ token: "tok" }); |
1285 | 1316 | const callbackHandler = requireValue( |
|