feat: add reusable Telegram PoC helper module / 新增可重用 Telegram PoC helper 模組

This commit is contained in:
Alice (OpenClaw)
2026-05-13 12:02:48 +08:00
parent 900ea7b93f
commit bd1da4c0da
2 changed files with 94 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
import type { ReplyEndChoice, ReplyEndState, TelegramInlineButton } from "../types.js"
export function buildDefaultReplyEndButtons(): TelegramInlineButton[][] {
return [[
{ text: "A. 繼續", callback_data: "rec:continue" },
{ text: "B. 就這樣吧,不需要額外處理", callback_data: "rec:stop" },
]]
}
export function buildResolvedReplyEndButtons(choice: ReplyEndChoice): TelegramInlineButton[][] {
if (choice === "continue") {
return [[
{ text: "✅ A. 繼續", callback_data: "rec:continue" },
{ text: "B. 就這樣吧,不需要額外處理", callback_data: "rec:stop" },
]]
}
return [[
{ text: "A. 繼續", callback_data: "rec:continue" },
{ text: "⏹ B. 就這樣吧,不需要額外處理", callback_data: "rec:stop" },
]]
}
export function buildReplyEndAcknowledgement(choice: ReplyEndChoice): string {
return choice === "continue"
? "reply-end-controls: continue received"
: "reply-end-controls: stop received"
}
export function applyStopStateToInboundText(text: string, state: ReplyEndState | null): string {
if (!state || state.lastChoice !== "stop" || state.active !== true) {
return text
}
return `${text}\n\n[System: The user previously pressed reply-end-controls Stop for this conversation. Treat the previous thread as closed. Unless the user's new message contains a clear new instruction or explicit request for more work, you must NOT proactively continue, must NOT add extra checks, must NOT propose next steps, must NOT extend the task, and should answer briefly and close cleanly.]`.trim()
}