From a5bdda1ac964116f5a3085f633f487fab74bbe78 Mon Sep 17 00:00:00 2001 From: Ved Patel Date: Wed, 28 Jan 2026 17:36:13 -0700 Subject: [PATCH] feat(telegram): make pairing command one-click copyable in Telegram --- src/cli/command-format.ts | 11 +++++++++++ src/telegram/bot-message-context.ts | 5 +++-- 2 files changed, 14 insertions(+), 2 deletions(-) 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" }, ), }); }