<?php

Env::load(__DIR__ . '/.env');

define('BOT_TOKEN', Env::get('BOT_TOKEN'));
define('API_URL', 'https://api.telegram.org/bot' . BOT_TOKEN . '/');

define('DB_HOST', Env::get('DB_HOST'));
define('DB_NAME', Env::get('DB_NAME'));
define('DB_USER', Env::get('DB_USER'));
define('DB_PASS', Env::get('DB_PASS'));
define('DB_CHARSET', Env::get('DB_CHARSET', 'utf8mb4'));

define('ADMIN_IDS', array_map('intval', explode(',', Env::get('ADMIN_IDS', ''))));

$bot_username = Env::get('BOT_USERNAME');

try {
    $pdo = new PDO(
        "mysql:host=" . DB_HOST . ";dbname=" . DB_NAME . ";charset=" . DB_CHARSET,
        DB_USER,
        DB_PASS,
        [
            PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
            PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
        ]
    );
} catch (PDOException $e) {
    throw new RuntimeException("DB connection failed: " . $e->getMessage());
}
