Files
openclaw/extensions/telegram/src/native-command-callback-data.ts
Soham Patankar 400be62f76 feat(codex): add portable Codex command pickers (#82224)
Refactor Codex slash-command pickers so the Codex plugin owns the native command tree and returns portable presentation buttons for channels to render. Telegram now maps portable slash-command buttons to `tgcmd:` native callbacks while preserving approval callback shortening/bypass behavior, and the old Telegram-specific Codex callback menu path is gone.

Verification:
- `node scripts/run-vitest.mjs extensions/codex/src/command-plugins-management.test.ts extensions/codex/src/commands.test.ts extensions/telegram/src/button-types.test.ts`
- `node scripts/run-vitest.mjs extensions/telegram/src/bot.test.ts extensions/telegram/src/button-types.test.ts extensions/telegram/src/bot-native-commands.test.ts extensions/telegram/src/shared.test.ts`
- `node scripts/run-vitest.mjs run --config test/vitest/vitest.media-understanding.config.ts --reporter=verbose`
- `pnpm check:test-types`
- `pnpm tsgo:prod`
- `pnpm lint --threads=8`
- `git diff --check`
- `.agents/skills/autoreview/scripts/autoreview --mode branch --base origin/main`
- CI `26714121462`

Co-authored-by: Soham Patankar <102520430+yaanfpv@users.noreply.github.com>
2026-05-31 14:45:10 +01:00

18 lines
622 B
TypeScript

const TELEGRAM_NATIVE_COMMAND_CALLBACK_PREFIX = "tgcmd:";
export function buildTelegramNativeCommandCallbackData(commandText: string): string {
return `${TELEGRAM_NATIVE_COMMAND_CALLBACK_PREFIX}${commandText}`;
}
export function parseTelegramNativeCommandCallbackData(data?: string | null): string | null {
if (!data) {
return null;
}
const trimmed = data.trim();
if (!trimmed.startsWith(TELEGRAM_NATIVE_COMMAND_CALLBACK_PREFIX)) {
return null;
}
const commandText = trimmed.slice(TELEGRAM_NATIVE_COMMAND_CALLBACK_PREFIX.length).trim();
return commandText.startsWith("/") ? commandText : null;
}