|
1 | 1 | // Telegram plugin module implements button types behavior. |
2 | 2 | import { parseExecApprovalCommandText } from "openclaw/plugin-sdk/approval-reply-runtime"; |
3 | 3 | import { |
4 | | - reduceLegacyInteractiveReply, |
| 4 | + legacyInteractiveReplyToPresentation, |
5 | 5 | isMessagePresentationInteractiveBlock, |
6 | 6 | normalizeMessagePresentation, |
7 | 7 | normalizeLegacyInteractiveReply, |
8 | 8 | renderMessagePresentationFallbackText, |
9 | 9 | resolveMessagePresentationButtonAction, |
10 | | - type LegacyInteractiveReply, |
11 | 10 | type MessagePresentation, |
12 | 11 | type MessagePresentationButton, |
13 | 12 | } from "openclaw/plugin-sdk/interactive-runtime"; |
@@ -228,38 +227,6 @@ function chunkInteractiveButtons( |
228 | 227 | } |
229 | 228 | } |
230 | 229 |
|
231 | | -/** |
232 | | - * @deprecated Use buildTelegramPresentationButtons with MessagePresentation. |
233 | | - */ |
234 | | -function buildTelegramInteractiveButtons( |
235 | | - interactive?: LegacyInteractiveReply, |
236 | | - options?: TelegramButtonBuildOptions, |
237 | | -): TelegramInlineButtons | undefined { |
238 | | - const rows = reduceLegacyInteractiveReply( |
239 | | - interactive, |
240 | | - [] as TelegramInlineButton[][], |
241 | | - (state, block) => { |
242 | | - if (block.type === "buttons") { |
243 | | - chunkInteractiveButtons(block.buttons, state, options); |
244 | | - return state; |
245 | | - } |
246 | | - if (block.type === "select") { |
247 | | - chunkInteractiveButtons( |
248 | | - block.options.map((option) => ({ |
249 | | - label: option.label, |
250 | | - action: option.action, |
251 | | - value: option.value, |
252 | | - })), |
253 | | - state, |
254 | | - options, |
255 | | - ); |
256 | | - } |
257 | | - return state; |
258 | | - }, |
259 | | - ); |
260 | | - return rows.length > 0 ? rows : undefined; |
261 | | -} |
262 | | - |
263 | 230 | /** Convert portable presentation controls to Telegram inline keyboard rows. */ |
264 | 231 | export function buildTelegramPresentationButtons( |
265 | 232 | presentation?: MessagePresentation, |
@@ -296,9 +263,16 @@ export function resolveTelegramInlineButtons( |
296 | 263 | }, |
297 | 264 | options?: TelegramButtonBuildOptions, |
298 | 265 | ): TelegramInlineButtons | undefined { |
| 266 | + if (params.buttons) { |
| 267 | + return params.buttons; |
| 268 | + } |
| 269 | + |
| 270 | + const interactive = normalizeLegacyInteractiveReply(params.interactive); |
299 | 271 | return ( |
300 | | - params.buttons ?? |
301 | | - buildTelegramInteractiveButtons(normalizeLegacyInteractiveReply(params.interactive), options) ?? |
| 272 | + buildTelegramPresentationButtons( |
| 273 | + interactive ? legacyInteractiveReplyToPresentation(interactive) : undefined, |
| 274 | + options, |
| 275 | + ) ?? |
302 | 276 | buildTelegramPresentationButtons(normalizeMessagePresentation(params.presentation), options) |
303 | 277 | ); |
304 | 278 | } |
0 commit comments