diff --git a/src/cli/command-format.ts b/src/cli/command-format.ts index 156a5cd2f..789c0dcf1 100644 --- a/src/cli/command-format.ts +++ b/src/cli/command-format.ts @@ -19,3 +19,14 @@ export function formatCliCommand( } return normalizedCommand.replace(CLI_PREFIX_RE, (match) => `${match} --profile ${profile}`); } + +/** + * Format a CLI command wrapped in backticks for one-click copy in Telegram. + * When sent as a message, users can tap the monospace text to copy it. + */ +export function formatCliCommandForCopy( + command: string, + env: Record = process.env as Record, +): string { + return `\`${formatCliCommand(command, env)}\``; +} diff --git a/src/telegram/bot-message-context.ts b/src/telegram/bot-message-context.ts index 832a4413d..d1b950af0 100644 --- a/src/telegram/bot-message-context.ts +++ b/src/telegram/bot-message-context.ts @@ -19,7 +19,7 @@ import { finalizeInboundContext } from "../auto-reply/reply/inbound-context.js"; import { buildMentionRegexes, matchesMentionWithExplicit } from "../auto-reply/reply/mentions.js"; import { formatLocationText, toLocationContext } from "../channels/location.js"; import { recordInboundSession } from "../channels/session.js"; -import { formatCliCommand } from "../cli/command-format.js"; +import { formatCliCommandForCopy } from "../cli/command-format.js"; import { readSessionUpdatedAt, resolveStorePath } from "../config/sessions.js"; import type { MoltbotConfig } from "../config/config.js"; import type { DmPolicy, TelegramGroupConfig, TelegramTopicConfig } from "../config/types.js"; @@ -279,8 +279,9 @@ export const buildTelegramMessageContext = async ({ `Pairing code: ${code}`, "", "Ask the bot owner to approve with:", - formatCliCommand("moltbot pairing approve telegram "), + formatCliCommandForCopy(`moltbot pairing approve telegram ${code}`), ].join("\n"), + { parse_mode: "Markdown" }, ), }); }