validate Telegram bot token in production
This commit is contained in:
+5
-1
@@ -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 };
|
||||
|
||||
Reference in New Issue
Block a user