import os import time import telebot from telebot import apihelper import yt_dlp import uvicorn from fastapi import FastAPI, Request from fastapi.responses import HTMLResponse import requests # ၁။ စနစ်အတွက် အခြေခံအချက်အလက်များ TOKEN = os.getenv("BOT_TOKEN") WEBHOOK_URL = "https://armaansingh752k1-all-in-one-downloader.hf.space/webhook" # Telegram API block များအား ရာနှုန်းပြည့်ကျော်လွှားမည့် HTTPS Proxy များ PROXY_TEMPLATES = [ "https://teleapi.muhammad.workers.dev/bot{0}/{1}", "https://tgproxy.onrender.com/bot{0}/{1}", "https://telegram-api-proxy-anonymous.pages.dev/api/bot{0}/{1}" ] CURRENT_PROXY_INDEX = 0 def custom_request_sender(method, url, **kwargs): """ Hugging Face ၏ IP block အား ကျော်လွှားရန် requests အားလုံးကို Web-Proxy Gateways များမှတစ်ဆင့် ဖြတ်သန်းစေသည်။ """ global CURRENT_PROXY_INDEX for i in range(len(PROXY_TEMPLATES)): idx = (CURRENT_PROXY_INDEX + i) % len(PROXY_TEMPLATES) proxy_base = PROXY_TEMPLATES[idx] try: url_parts = url.split("/bot") if len(url_parts) > 1: method_path = f"/bot{url_parts[1]}" else: method_path = f"/bot{TOKEN}/" + url.split("/")[-1] target_url = proxy_base.split("/bot")[0] + method_path except Exception: target_url = url try: if 'timeout' not in kwargs or kwargs['timeout'] is None: kwargs['timeout'] = (10, 20) response = requests.request(method, target_url, **kwargs) if response.status_code == 200: try: res_json = response.json() if isinstance(res_json, dict) and 'ok' in res_json: CURRENT_PROXY_INDEX = idx return response except Exception: pass except Exception: continue return requests.request(method, url, **kwargs) apihelper.custom_request_sender = custom_request_sender # Bot Engine ကို စတင်တည်ဆောက်ခြင်း bot = telebot.TeleBot(TOKEN, threaded=False) # FastAPI Web Server တည်ဆောက်ခြင်း app = FastAPI() @app.get("/", response_class=HTMLResponse) def dashboard(): """ Hugging Face Space ကို ဝင်ကြည့်လျှင် မြင်တွေ့ရမည့် Live Monitor UI """ html_content = f"""
Hugging Face Real-Time Webhook Bypass
💡 လမ်းညွှန်ချက် -
၁။ အောက်ပါ အစိမ်းရောင်ခလုတ်ကို နှိပ်ပါ။
၂။ သင့်ဖုန်း Browser သည် Telegram API ဆီသို့ တိုက်ရိုက်ဆက်သွယ်ပြီး Webhook ကို အောင်မြင်စွာ တပ်ဆင်ပေးသွားမည် ဖြစ်သည်။