Spaces:
Runtime error
Runtime error
Upload main.py
Browse files
main.py
CHANGED
|
@@ -75,11 +75,21 @@ async def inline_query_handler(query: types.InlineQuery):
|
|
| 75 |
)
|
| 76 |
await query.answer(results[:50], cache_time=1)
|
| 77 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
async def main():
|
| 79 |
global bot
|
| 80 |
|
| 81 |
-
#
|
| 82 |
-
|
|
|
|
| 83 |
bot = Bot(token=BOT_TOKEN, session=session)
|
| 84 |
|
| 85 |
app = web.Application()
|
|
|
|
| 75 |
)
|
| 76 |
await query.answer(results[:50], cache_time=1)
|
| 77 |
|
| 78 |
+
from aiohttp import web, TCPConnector
|
| 79 |
+
|
| 80 |
+
class StaticResolver:
|
| 81 |
+
async def resolve(self, host, port=0, family=socket.AF_INET):
|
| 82 |
+
if host == "api.telegram.org":
|
| 83 |
+
# Официальный IP адрес Telegram (один из основных)
|
| 84 |
+
return [{"hostname": host, "host": "149.154.167.220", "port": port, "family": family, "proto": 0, "flags": 0}]
|
| 85 |
+
return await asyncio.get_event_loop().getaddrinfo(host, port, family=family)
|
| 86 |
+
|
| 87 |
async def main():
|
| 88 |
global bot
|
| 89 |
|
| 90 |
+
# Создаем сессию с нашим статическим резолвером
|
| 91 |
+
connector = TCPConnector(resolver=StaticResolver())
|
| 92 |
+
session = AiohttpSession(connector=connector)
|
| 93 |
bot = Bot(token=BOT_TOKEN, session=session)
|
| 94 |
|
| 95 |
app = web.Application()
|