const BOT_TOKEN = process.env.TELEGRAM_BOT_TOKEN ?? ""; const CHAT_ID = process.env.TELEGRAM_CHAT_ID ?? ""; export async function sendTelegramMessage(text: string): Promise { if (!BOT_TOKEN || !CHAT_ID) { console.warn("[telegram] TELEGRAM_BOT_TOKEN/TELEGRAM_CHAT_ID not set, skipping notification:", text); return; } const url = `https://api.telegram.org/bot${BOT_TOKEN}/sendMessage`; const res = await fetch(url, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ chat_id: CHAT_ID, text, parse_mode: "Markdown" }), }); if (!res.ok) { console.error("[telegram] failed to send message:", res.status, await res.text()); } }