Add token validation and logging for Telegram bot
This commit is contained in:
@@ -10,7 +10,17 @@ class TelegramHelper
|
||||
public static function init()
|
||||
{
|
||||
self::$botToken = $_ENV['TELEGRAM_BOT_TOKEN'] ?? '';
|
||||
|
||||
if (empty(self::$botToken)) {
|
||||
self::log("ERROR: TELEGRAM_BOT_TOKEN is empty or not set in .env");
|
||||
throw new \Exception("Telegram Bot Token is not configured");
|
||||
}
|
||||
|
||||
self::$apiURL = "https://api.telegram.org/bot" . self::$botToken . "/";
|
||||
|
||||
// Log token (masked for security)
|
||||
$maskedToken = substr(self::$botToken, 0, 10) . '...' . substr(self::$botToken, -5);
|
||||
self::log("TelegramHelper initialized with token: $maskedToken");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user