feat(telegram): make pairing command one-click copyable in Telegram

This commit is contained in:
Ved Patel 2026-01-28 17:36:13 -07:00
parent fdcac0ccf4
commit a5bdda1ac9
2 changed files with 14 additions and 2 deletions

View File

@ -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<string, string | undefined> = process.env as Record<string, string | undefined>,
): string {
return `\`${formatCliCommand(command, env)}\``;
}

View File

@ -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 <code>"),
formatCliCommandForCopy(`moltbot pairing approve telegram ${code}`),
].join("\n"),
{ parse_mode: "Markdown" },
),
});
}