11 lines
461 B
TypeScript
11 lines
461 B
TypeScript
export async function sendTelegram(chatId: string, text: string): Promise<void> {
|
|
const token = process.env.TELEGRAM_BOT_TOKEN;
|
|
if (!token) throw new Error("TELEGRAM_BOT_TOKEN fehlt");
|
|
const res = await fetch(`https://api.telegram.org/bot${token}/sendMessage`, {
|
|
method: "POST",
|
|
headers: { "content-type": "application/json" },
|
|
body: JSON.stringify({ chat_id: chatId, text }),
|
|
});
|
|
if (!res.ok) throw new Error(`Telegram ${res.status}`);
|
|
}
|