diff --git a/backend/marketing_engine/telegram_scraper.php b/backend/marketing_engine/telegram_scraper.php index 4396019c..cfad2a75 100644 --- a/backend/marketing_engine/telegram_scraper.php +++ b/backend/marketing_engine/telegram_scraper.php @@ -4,6 +4,19 @@ if (php_sapi_name() !== 'cli') { die("This script must be run from the command line (Terminal).\n"); } +// Load .env for CLI +$envPath = __DIR__ . '/../.env'; +if (file_exists($envPath)) { + $lines = file($envPath, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); + foreach ($lines as $line) { + if (strpos(trim($line), '#') === 0) continue; + $parts = explode('=', $line, 2); + if (count($parts) === 2) { + putenv(trim($parts[0]) . '=' . trim($parts[1])); + } + } +} + require_once __DIR__ . '/../core/Services/SiroGeminiService.php'; require_once __DIR__ . '/../core/Database/Database.php';