import type { ThoughtEvent } from "../events/types.js"; export const STREAM_TELEGRAM_HELP_VERSION = "stream-help-v3"; export const STREAM_TELEGRAM_FOCUS_HELP_VERSION = "stream-focus-help-v1"; export const STREAM_TELEGRAM_BOT_NAME = "The Stream"; export const STREAM_TELEGRAM_COMMANDS = [ { command: "help", description: "Show commands, feedback, and links" }, { command: "focus", description: "Propose a new focus from plain language" }, { command: "correct", description: "Reply to a message with /correct new text" }, ] as const; export const STREAM_TELEGRAM_HELP_TEXT = `The Stream Commands /help — show this menu /focus — propose a private focus from plain language /correct — reply to one of my messages to replace that answer exactly Feedback 👍 — mark a reply good 👎 — mark a reply bad Private activity and suggestions https://thought.stream/inspector/ Public docs https://thought.stream/docs The Telegram Menu button also contains /help, /focus, and /correct.`; export const STREAM_TELEGRAM_FOCUS_HELP_TEXT = `Focus proposals /focus Example /focus AI news that changes how I understand model training and agent infrastructure This creates a private inert proposal for review. It does not activate a listener, expand data access, start training, deliver focus output, or contact a third party.`; export function isTelegramHelpCommand(event: ThoughtEvent): boolean { if (event.type !== "stream.thought.source.telegram.message") return false; const text = typeof event.payload.text === "string" ? event.payload.text.trim() : ""; if (text === "/help") return true; const username = typeof event.payload.accountUsername === "string" ? event.payload.accountUsername.toLowerCase() : ""; return username.length > 0 && text.toLowerCase() === `/help@${username}`; } export function isTelegramFocusHelpCommand(event: ThoughtEvent): boolean { if (event.type !== "stream.thought.source.telegram.message") return false; const text = typeof event.payload.text === "string" ? event.payload.text.trim() : ""; if (text === "/focus") return true; const username = typeof event.payload.accountUsername === "string" ? event.payload.accountUsername.toLowerCase() : ""; return username.length > 0 && text.toLowerCase() === `/focus@${username}`; } export function telegramFocusDescription(event: ThoughtEvent): string | undefined { if (event.type !== "stream.thought.source.telegram.message") return undefined; const text = typeof event.payload.text === "string" ? event.payload.text.trim() : ""; const match = text.match(/^\/focus(?:@([A-Za-z0-9_]+))?\s+([\s\S]+)$/); if (!match) return undefined; const mention = match[1]?.toLowerCase(); const username = typeof event.payload.accountUsername === "string" ? event.payload.accountUsername.toLowerCase() : ""; if (mention && (!username || mention !== username)) return undefined; const description = match[2]?.trim(); return description ? description : undefined; }