Spaces:
Running
Running
Foydalanuvchi commited on
Commit ·
dc6242c
1
Parent(s): 31868d9
Apply DNS Monkey Patch for Telegram IP
Browse files
main.py
CHANGED
|
@@ -36,7 +36,20 @@ from database import db
|
|
| 36 |
from concurrent.futures import ThreadPoolExecutor
|
| 37 |
from apscheduler.schedulers.asyncio import AsyncIOScheduler
|
| 38 |
|
| 39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
load_dotenv()
|
| 41 |
TOKEN = os.getenv("TELEGRAM_BOT_TOKEN")
|
| 42 |
|
|
@@ -49,7 +62,7 @@ logger = logging.getLogger(__name__)
|
|
| 49 |
|
| 50 |
# Global media storage
|
| 51 |
media_storage = {}
|
| 52 |
-
processing_semaphore = asyncio.Semaphore(2)
|
| 53 |
executor = ThreadPoolExecutor(max_workers=4)
|
| 54 |
base_dir = os.path.dirname(os.path.abspath(__file__))
|
| 55 |
|
|
|
|
| 36 |
from concurrent.futures import ThreadPoolExecutor
|
| 37 |
from apscheduler.schedulers.asyncio import AsyncIOScheduler
|
| 38 |
|
| 39 |
+
import socket
|
| 40 |
+
|
| 41 |
+
# --- Hugging Face DNS Patch Start ---
|
| 42 |
+
# Server DNS xatosini chetlab o'tish uchun Telegram IP manzillarini qattiq bog'laymiz
|
| 43 |
+
_original_getaddrinfo = socket.getaddrinfo
|
| 44 |
+
def _patched_getaddrinfo(host, port, family=0, type=0, proto=0, flags=0):
|
| 45 |
+
if host == "api.telegram.org":
|
| 46 |
+
# Telegramning rasmiy IP manzillaridan biri
|
| 47 |
+
return [(socket.AF_INET, socket.SOCK_STREAM, 6, '', ('149.154.167.220', port))]
|
| 48 |
+
return _original_getaddrinfo(host, port, family, type, proto, flags)
|
| 49 |
+
socket.getaddrinfo = _patched_getaddrinfo
|
| 50 |
+
# --- Hugging Face DNS Patch End ---
|
| 51 |
+
|
| 52 |
+
# muhit o'zgaruvchilari
|
| 53 |
load_dotenv()
|
| 54 |
TOKEN = os.getenv("TELEGRAM_BOT_TOKEN")
|
| 55 |
|
|
|
|
| 62 |
|
| 63 |
# Global media storage
|
| 64 |
media_storage = {}
|
| 65 |
+
processing_semaphore = asyncio.Semaphore(2)
|
| 66 |
executor = ThreadPoolExecutor(max_workers=4)
|
| 67 |
base_dir = os.path.dirname(os.path.abspath(__file__))
|
| 68 |
|