<?php
// ============================================================
//  M3U8 → MP4 Telegram Bot — Konfiguratsiya
// ============================================================

// 1. BotFather dan olgan tokeningizni kiriting
define('BOT_TOKEN', '8173620019:AAGokCx3SYiE_wh-pravnNkrnMlGXWQygxA');

// 2. Telegram API base URL (o'zgartirmang)
define('API_URL', 'https://api.telegram.org/bot' . BOT_TOKEN . '/');

// 3. Webhook so'rovlarini himoya qilish uchun maxfiy kalit
//    Webhook URL: https://yoursite.com/videoupload/bot.php?secret=WEBHOOK_SECRET
define('WEBHOOK_SECRET', 'my_super_secret_key_2024');

// 11. Admin ID (monitoring yoki admin buyruqlari uchun)
define('ADMIN_ID', 7585045867);

// 4. FFmpeg yo'li
//    Windows XAMPP: ffmpeg.exe ni yuklab, masalan C:\ffmpeg\bin\ ga joylashtiring
//    Linux/Mac:     odatda 'ffmpeg' (PATH da bo'lsa)
define('FFMPEG_PATH', 'C:\\ffmpeg\\bin\\ffmpeg.exe');

// 5. PHP CLI yo'li (background jarayon uchun)
//    Windows XAMPP: odatda C:\xampp\php\php.exe
define('PHP_PATH', 'C:\\xampp\\php\\php.exe');

// 6. Yuklab olingan fayllar saqlanadigan papka (mutlaq yo'l)
define('DOWNLOAD_DIR', __DIR__ . DIRECTORY_SEPARATOR . 'downloads');

// 7. Log fayllari papkasi
define('LOG_DIR', __DIR__ . DIRECTORY_SEPARATOR . 'logs');

// 8. Telegram orqali yuborish uchun fayl hajmi chegarasi (bayt)
//    50 MB = 50 * 1024 * 1024 = 52428800
//    Bundan katta fayllar sendDocument sifatida yuboriladi
define('MAX_SEND_SIZE', 50 * 1024 * 1024);

// 9. Maksimal ruxsat etilgan video davomiyligi (soniya), 0 = cheksiz
//    Katta hajmli videolar serverda joy egallashini oldini olish uchun
define('MAX_DURATION_SEC', 0);

// 10. FFmpeg konvertatsiya parametrlari
//     scale=1920:1080 → 1080p, -2 nisbatni saqlaydi
define('FFMPEG_VIDEO_OPTS', '-vf "scale=1920:-2" -c:v libx264 -preset fast -crf 23');
define('FFMPEG_AUDIO_OPTS', '-c:a aac -b:a 192k');
define('FFMPEG_EXTRA_OPTS', '-movflags +faststart -threads 4');

// ============================================================
//  MadelineProto UserBot sozlamalari (katta fayllar uchun)
// ============================================================

// my.telegram.org → API Development Tools → App api_id va api_hash
define('MADELINE_API_ID',   39890609);
define('MADELINE_API_HASH', '327ba3971a7a85bb44eb5510aa04d0d8');

// Session fayl nomi (.madeline kengaytmasi avtomatik qo'shiladi)
define('MADELINE_SESSION_NAME', 'userbot');

// ============================================================
//  Papkalarni avtomatik yaratish
// ============================================================
foreach ([DOWNLOAD_DIR, LOG_DIR, __DIR__ . '/madeline_session'] as $dir) {
    if (!is_dir($dir)) {
        mkdir($dir, 0755, true);
    }
}

// madeline_session papkasini veb dan himoya qilish
$htaccess = __DIR__ . '/madeline_session/.htaccess';
if (!file_exists($htaccess)) {
    file_put_contents($htaccess, "Deny from all\n");
}
