@venzo24
Изучаю язык python

Не могу задеплоить бота на pythonanywhere.com что делать?

Вот мой КОД:

import logging



from aiogram import Bot, Dispatcher, executor, types
from aiogram.contrib.fsm_storage.memory import MemoryStorage

token1 = "токен типа"



logging.basicConfig(level=logging.INFO)

bot = Bot(token=token1)
storage = MemoryStorage()
dp = Dispatcher(bot, storage=storage)





@dp.message_handler(content_types=["new_chat_members"])
async def on_user_joined(message: types.Message):
    await message.delete()


#фильтры--------------------
@dp.message_handler()
async def filter_messages(message: types.Message):
    if "дик"  in message.text:
        await message.delete()
    if "/dick"  in message.text:
        await message.delete()
    if "Расти страну"  in message.text:
        await message.delete()
    if "/iq"  in message.text:
        await message.delete()
    if "mq"  in message.text:
        await message.delete()
    if "Поздравляем! Вы подписались на Новости."  in message.text:
        await message.delete()



if __name__ == "__main__":
    executor.start_polling(dp, skip_updates=True)


А вот такую ошибку выдает:
вот такую ошибку

WARNING:aiogram:Goodbye!
Traceback (most recent call last):
File "/home/venzo/.local/lib/python3.10/site-packages/aiohttp/connector.py", line 980, in _wrap_create_connection
return await self._loop.create_connection(*args, **kwargs) # type: ignore[return-value] # noqa
File "/usr/local/lib/python3.10/asyncio/base_events.py", line 1064, in create_connection
raise exceptions[0]
File "/usr/local/lib/python3.10/asyncio/base_events.py", line 1049, in create_connection
sock = await self._connect_sock(
File "/usr/local/lib/python3.10/asyncio/base_events.py", line 960, in _connect_sock
await self.sock_connect(sock, address)
File "/usr/local/lib/python3.10/asyncio/selector_events.py", line 500, in sock_connect
return await fut
File "/usr/local/lib/python3.10/asyncio/selector_events.py", line 505, in _sock_connect
sock.connect(address)
OSError: [Errno 101] Network is unreachable
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/venzo/.local/lib/python3.10/site-packages/aiogram/bot/api.py", line 139, in make_request
async with session.post(url, data=req, **kwargs) as response:
File "/home/venzo/.local/lib/python3.10/site-packages/aiohttp/client.py", line 1141, in __aenter__
self._resp = await self._coro
File "/home/venzo/.local/lib/python3.10/site-packages/aiohttp/client.py", line 536, in _request
conn = await self._connector.connect(
File "/home/venzo/.local/lib/python3.10/site-packages/aiohttp/connector.py", line 540, in connect
proto = await self._create_connection(req, traces, timeout)
File "/home/venzo/.local/lib/python3.10/site-packages/aiohttp/connector.py", line 901, in _create_connection
_, proto = await self._create_direct_connection(req, traces, timeout)
File "/home/venzo/.local/lib/python3.10/site-packages/aiohttp/connector.py", line 1206, in _create_direct_connection
raise last_exc
File "/home/venzo/.local/lib/python3.10/site-packages/aiohttp/connector.py", line 1175, in _create_direct_connection
transp, proto = await self._wrap_create_connection(
File "/home/venzo/.local/lib/python3.10/site-packages/aiohttp/connector.py", line 988, in _wrap_create_connection
raise client_error(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host api.telegram.org:443 ssl:default [Network is unreachable]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/venzo/bot1/bot.py", line 46, in
executor.start_polling(dp, skip_updates=True)
File "/home/venzo/.local/lib/python3.10/site-packages/aiogram/utils/executor.py", line 45, in start_polling
executor.start_polling(
File "/home/venzo/.local/lib/python3.10/site-packages/aiogram/utils/executor.py", line 320, in start_polling
loop.run_until_complete(self._startup_polling())
File "/usr/local/lib/python3.10/asyncio/base_events.py", line 646, in run_until_complete
return future.result()
File "/home/venzo/.local/lib/python3.10/site-packages/aiogram/utils/executor.py", line 372, in _startup_polling
await self._welcome()
File "/home/venzo/.local/lib/python3.10/site-packages/aiogram/utils/executor.py", line 361, in _welcome
user = await self.dispatcher.bot.me
File "/home/venzo/.local/lib/python3.10/site-packages/aiogram/bot/bot.py", line 30, in me
setattr(self, '_me', await self.get_me())
File "/home/venzo/.local/lib/python3.10/site-packages/aiogram/bot/bot.py", line 233, in get_me
result = await self.request(api.Methods.GET_ME, payload)
File "/home/venzo/.local/lib/python3.10/site-packages/aiogram/bot/base.py", line 236, in request
return await api.make_request(await self.get_session(), self.server, self.__token, method, data, files,
File "/home/venzo/.local/lib/python3.10/site-packages/aiogram/bot/api.py", line 142, in make_request
raise exceptions.NetworkError(f"aiohttp client throws an error: {e.__class__.__name__}: {e}")
aiogram.utils.exceptions.NetworkError: Aiohttp client throws an error: ClientConnectorError: Cannot connect to host api.telegram.org:443 ssl:default [Network is unreachable]
>>>

  • Вопрос задан
  • 309 просмотров
Пригласить эксперта
Ответы на вопрос 1
@igor6130
Поиск по ошибке в гугле первой ссылкой выдал это:

https://stackoverflow.com/questions/63347818/aioht...
Explanation: Free accounts on PythonAnywhere must use a proxy to connect to the public internet, but aiohttp, by default, does not connect to a proxy accessible from an environment variable.


И вторая ссылка конкретно про телеграм: https://www.pythonanywhere.com/forums/topic/28845/
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы
23 нояб. 2024, в 00:16
2000 руб./за проект
22 нояб. 2024, в 23:55
3000 руб./за проект
22 нояб. 2024, в 22:26
3500 руб./за проект