diff --git a/backend/marketing_engine/telegram_scraper.php b/backend/marketing_engine/telegram_scraper.php index 7484b4ef..82ca0bc2 100644 --- a/backend/marketing_engine/telegram_scraper.php +++ b/backend/marketing_engine/telegram_scraper.php @@ -4,9 +4,28 @@ if (php_sapi_name() !== 'cli') { die("This script must be run from the command line (Terminal).\n"); } -// Load core bootstrap (which handles .env, dependencies, database, etc.) -require_once __DIR__ . '/../core/bootstrap.php'; +// Load .env for CLI +$envPaths = [__DIR__ . '/../.env', __DIR__ . '/../../.env']; +foreach ($envPaths as $envPath) { + if (file_exists($envPath)) { + $lines = file($envPath, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); + foreach ($lines as $line) { + $line = trim($line); + if (empty($line) || strpos($line, '#') === 0) continue; + $parts = explode('=', $line, 2); + if (count($parts) === 2) { + $key = trim($parts[0]); + $val = trim(trim($parts[1]), "\"'"); + putenv("$key=$val"); + $_ENV[$key] = $val; + } + } + break; + } +} + require_once __DIR__ . '/../core/Services/SiroGeminiService.php'; +require_once __DIR__ . '/../core/Database/Database.php'; if (!file_exists(__DIR__ . '/madeline.php')) { die("Error: madeline.php not found. Please run telegram_setup.php first.\n");