This commit is contained in:
Ved Patel 2026-01-29 19:00:20 +00:00 committed by GitHub
commit 2da09fa045
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
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}`); 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 { buildMentionRegexes, matchesMentionWithExplicit } from "../auto-reply/reply/mentions.js";
import { formatLocationText, toLocationContext } from "../channels/location.js"; import { formatLocationText, toLocationContext } from "../channels/location.js";
import { recordInboundSession } from "../channels/session.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 { readSessionUpdatedAt, resolveStorePath } from "../config/sessions.js";
import type { MoltbotConfig } from "../config/config.js"; import type { MoltbotConfig } from "../config/config.js";
import type { DmPolicy, TelegramGroupConfig, TelegramTopicConfig } from "../config/types.js"; import type { DmPolicy, TelegramGroupConfig, TelegramTopicConfig } from "../config/types.js";
@ -279,8 +279,9 @@ export const buildTelegramMessageContext = async ({
`Pairing code: ${code}`, `Pairing code: ${code}`,
"", "",
"Ask the bot owner to approve with:", "Ask the bot owner to approve with:",
formatCliCommand("moltbot pairing approve telegram <code>"), formatCliCommandForCopy(`moltbot pairing approve telegram ${code}`),
].join("\n"), ].join("\n"),
{ parse_mode: "Markdown" },
), ),
}); });
} }