#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import os
import logging
from telegram.ext import ApplicationBuilder
from config import TOKEN
from bot import main

# Konfigurasi logging
logging.basicConfig(
    format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
    level=logging.INFO
)
logger = logging.getLogger(__name__)

if __name__ == '__main__':
    logger.info("Starting Terabox Download Bot with Ads")
    
    # Pastikan variabel lingkungan diatur dari config.py jika belum diatur
    from config import (
        GPLINKS_API_KEY, EZ4SHORT_API_KEY, DROPLINK_API_KEY, TNLINK_API_KEY,
        FORCE_CHANNEL_ID, FORCE_CHANNEL_USERNAME
    )
    
    if not os.environ.get('GPLINKS_API_KEY') and GPLINKS_API_KEY:
        os.environ['GPLINKS_API_KEY'] = GPLINKS_API_KEY
    
    if not os.environ.get('EZ4SHORT_API_KEY') and EZ4SHORT_API_KEY:
        os.environ['EZ4SHORT_API_KEY'] = EZ4SHORT_API_KEY
    
    if not os.environ.get('DROPLINK_API_KEY') and DROPLINK_API_KEY:
        os.environ['DROPLINK_API_KEY'] = DROPLINK_API_KEY
    
    if not os.environ.get('TNLINK_API_KEY') and TNLINK_API_KEY:
        os.environ['TNLINK_API_KEY'] = TNLINK_API_KEY
    
    # Jalankan bot
    main()
