validate Telegram bot token in production

This commit is contained in:
2026-09-06 18:03:39 +03:00
parent e70126b312
commit 64919270d8
3 changed files with 26 additions and 2 deletions
+5 -1
View File
@@ -10,7 +10,11 @@
const API = () => `https://api.telegram.org/bot${process.env.TELEGRAM_BOT_TOKEN}`;
export function telegramConfigured() {
return Boolean(process.env.TELEGRAM_BOT_TOKEN);
const token = String(process.env.TELEGRAM_BOT_TOKEN || '').trim();
if (!token) return false;
// Üretimde placeholder veya hatalı token ile kanalın aktif görünmesini engelle.
if (process.env.NODE_ENV === 'production') return /^\d{6,}:[A-Za-z0-9_-]{20,}$/.test(token);
return true;
}
let botOnbellek = { ad: null, zaman: 0 };