Spaces:
Runtime error
Runtime error
Upload folder using huggingface_hub
Browse files
main.py
CHANGED
|
@@ -7,7 +7,7 @@ from aiogram.client.default import DefaultBotProperties
|
|
| 7 |
from aiogram.client.session.aiohttp import AiohttpSession
|
| 8 |
from aiogram.enums import ParseMode
|
| 9 |
from aiogram.fsm.storage.memory import MemoryStorage
|
| 10 |
-
from aiohttp import TCPConnector, web
|
| 11 |
from config import BOT_TOKEN
|
| 12 |
from database.db import init_db
|
| 13 |
from handlers import user, payment, admin
|
|
@@ -21,6 +21,17 @@ logging.basicConfig(
|
|
| 21 |
logger = logging.getLogger(__name__)
|
| 22 |
|
| 23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
async def start_web_server():
|
| 25 |
"""Hugging Face Spaces port tekshiruvidan o'tishi uchun dummy web server."""
|
| 26 |
async def handle(request):
|
|
@@ -43,9 +54,7 @@ async def main():
|
|
| 43 |
logger.info("✅ Ma'lumotlar bazasi tayyor.")
|
| 44 |
|
| 45 |
# Hugging Face-da IPv6 ulanish xatolarining oldini olish uchun faqat IPv4 ni majburlaymiz
|
| 46 |
-
session =
|
| 47 |
-
connector=TCPConnector(family=socket.AF_INET)
|
| 48 |
-
)
|
| 49 |
|
| 50 |
# Bot va Dispatcher yaratish
|
| 51 |
bot = Bot(
|
|
|
|
| 7 |
from aiogram.client.session.aiohttp import AiohttpSession
|
| 8 |
from aiogram.enums import ParseMode
|
| 9 |
from aiogram.fsm.storage.memory import MemoryStorage
|
| 10 |
+
from aiohttp import TCPConnector, ClientSession, web
|
| 11 |
from config import BOT_TOKEN
|
| 12 |
from database.db import init_db
|
| 13 |
from handlers import user, payment, admin
|
|
|
|
| 21 |
logger = logging.getLogger(__name__)
|
| 22 |
|
| 23 |
|
| 24 |
+
class IPv4OnlyAiohttpSession(AiohttpSession):
|
| 25 |
+
"""Hugging Face Spaces-da IPv6 ulanish xatolarini chetlab o'tish uchun faqat IPv4-ni ishlatuvchi session."""
|
| 26 |
+
async def create_session(self) -> ClientSession:
|
| 27 |
+
if self._session is None or self._session.closed:
|
| 28 |
+
self._session = ClientSession(
|
| 29 |
+
connector=TCPConnector(family=socket.AF_INET),
|
| 30 |
+
json_serialize=self.json_dumps
|
| 31 |
+
)
|
| 32 |
+
return self._session
|
| 33 |
+
|
| 34 |
+
|
| 35 |
async def start_web_server():
|
| 36 |
"""Hugging Face Spaces port tekshiruvidan o'tishi uchun dummy web server."""
|
| 37 |
async def handle(request):
|
|
|
|
| 54 |
logger.info("✅ Ma'lumotlar bazasi tayyor.")
|
| 55 |
|
| 56 |
# Hugging Face-da IPv6 ulanish xatolarining oldini olish uchun faqat IPv4 ni majburlaymiz
|
| 57 |
+
session = IPv4OnlyAiohttpSession()
|
|
|
|
|
|
|
| 58 |
|
| 59 |
# Bot va Dispatcher yaratish
|
| 60 |
bot = Bot(
|