Spaces:
Runtime error
Runtime error
Update football_analysis_system_v2/betting_system/modules/telegram_bot.py
Browse files
football_analysis_system_v2/betting_system/modules/telegram_bot.py
CHANGED
|
@@ -3,23 +3,19 @@ Telegram Bot Module
|
|
| 3 |
Sends analysis notifications to Telegram
|
| 4 |
"""
|
| 5 |
|
| 6 |
-
import
|
| 7 |
-
import httpx
|
| 8 |
from telegram.request import HTTPXRequest
|
| 9 |
|
| 10 |
-
#
|
| 11 |
-
class IPv4Resolver(httpx.AsyncHTTPTransport):
|
| 12 |
-
async def handle_async_request(self, request):
|
| 13 |
-
request.url = request.url.copy_with(host="api.telegram.org")
|
| 14 |
-
return await super().handle_async_request(request)
|
| 15 |
|
| 16 |
request = HTTPXRequest(
|
| 17 |
-
connect_timeout=
|
| 18 |
-
read_timeout=
|
| 19 |
-
write_timeout=
|
| 20 |
-
pool_timeout=
|
| 21 |
)
|
| 22 |
|
|
|
|
| 23 |
import asyncio
|
| 24 |
import os
|
| 25 |
from typing import Dict, Any, Optional
|
|
@@ -55,6 +51,7 @@ class TelegramBot:
|
|
| 55 |
# Simple initialization without custom request object
|
| 56 |
self.bot = Bot(
|
| 57 |
token=self.bot_token,
|
|
|
|
| 58 |
request=request
|
| 59 |
)
|
| 60 |
|
|
|
|
| 3 |
Sends analysis notifications to Telegram
|
| 4 |
"""
|
| 5 |
|
| 6 |
+
from telegram import Bot
|
|
|
|
| 7 |
from telegram.request import HTTPXRequest
|
| 8 |
|
| 9 |
+
TELEGRAM_IP = "149.154.167.220" # Telegram API IPv4
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
request = HTTPXRequest(
|
| 12 |
+
connect_timeout=20,
|
| 13 |
+
read_timeout=20,
|
| 14 |
+
write_timeout=20,
|
| 15 |
+
pool_timeout=20,
|
| 16 |
)
|
| 17 |
|
| 18 |
+
|
| 19 |
import asyncio
|
| 20 |
import os
|
| 21 |
from typing import Dict, Any, Optional
|
|
|
|
| 51 |
# Simple initialization without custom request object
|
| 52 |
self.bot = Bot(
|
| 53 |
token=self.bot_token,
|
| 54 |
+
base_url=f"https://{TELEGRAM_IP}/bot",
|
| 55 |
request=request
|
| 56 |
)
|
| 57 |
|