feat: improve consumer-facing flow and payload helper / 改善可直接使用流程與 Telegram payload helper
This commit is contained in:
14
src/telegram/outbound-payload.ts
Normal file
14
src/telegram/outbound-payload.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { buildDefaultReplyEndButtons } from "../runtime/openclaw-telegram-poc.js"
|
||||
import type { TelegramInlineButton } from "../types.js"
|
||||
|
||||
export type TelegramReplyEndPayload = {
|
||||
text: string
|
||||
buttons: TelegramInlineButton[][]
|
||||
}
|
||||
|
||||
export function buildTelegramReplyEndPayload(text: string): TelegramReplyEndPayload {
|
||||
return {
|
||||
text,
|
||||
buttons: buildDefaultReplyEndButtons(),
|
||||
}
|
||||
}
|
||||
11
tests/telegram-outbound-payload.test.mjs
Normal file
11
tests/telegram-outbound-payload.test.mjs
Normal file
@@ -0,0 +1,11 @@
|
||||
import test from "node:test"
|
||||
import assert from "node:assert/strict"
|
||||
|
||||
import { buildTelegramReplyEndPayload } from "../src/telegram/outbound-payload.ts"
|
||||
|
||||
test("buildTelegramReplyEndPayload returns text plus default reply-end buttons", () => {
|
||||
const payload = buildTelegramReplyEndPayload("hello")
|
||||
assert.equal(payload.text, "hello")
|
||||
assert.equal(payload.buttons[0][0].callback_data, "rec:continue")
|
||||
assert.equal(payload.buttons[0][1].callback_data, "rec:stop")
|
||||
})
|
||||
Reference in New Issue
Block a user