Уведомления

Группа в Telegram: @pythonsu

#1 Март 4, 2022 23:28:16

plove
Зарегистрирован: 2022-03-04
Сообщения: 1
Репутация: +  0  -
Профиль   Отправить e-mail  

Не запускается простой telegram echo bot, в чём причина?

Только учусь писать что то в подобном роде для себя и вот импортировал в Pycharm библиотеку aiogram, с сайта аиограма переписал простейшего это бота, но при нажатии в telegram он никак не реагирует и через секунд 20-30 вылазят такие ошибки в пайчарме.
Сам код:
import logging
from aiogram import Bot, Dispatcher, executor, types
API_TOKEN = ‘тут мой токен с ботфатера’
logging.basicConfig(level=logging.INFO)
bot = Bot(token=API_TOKEN)
dp = Dispatcher(bot)
@dp.message_handler(commands
async def send_welcome(message: types.Message):
await message.reply(“Hi!\nI'm EchoBot!\nPowered by aiogram.”)
@dp.message_handler()
async def echo(message: types.Message):
await message.answer(message.text)
if __name__ == ‘__main__’:
executor.start_polling(dp, skip_updates=True)


ошибки такие
iogram:Goodbye!
Traceback (most recent call last):
File “C:\Users\Nursultan\PycharmProjects\pythonProject4\venv\lib\site-packages\aiohttp\connector.py”, line 986, in _wrap_create_connection
return await self._loop.create_connection(*args, **kwargs) # type: ignore # noqa
File “C:\Users\Nursultan\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py”, line 1055, in create_connection
raise exceptions
File “C:\Users\Nursultan\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py”, line 1040, in create_connection
sock = await self._connect_sock(
File “C:\Users\Nursultan\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py”, line 954, in _connect_sock
await self.sock_connect(sock, address)
File “C:\Users\Nursultan\AppData\Local\Programs\Python\Python310\lib\asyncio\proactor_events.py”, line 704, in sock_connect
return await self._proactor.connect(sock, address)
File “C:\Users\Nursultan\AppData\Local\Programs\Python\Python310\lib\asyncio\windows_events.py”, line 817, in _poll
value = callback(transferred, key, ov)
File “C:\Users\Nursultan\AppData\Local\Programs\Python\Python310\lib\asyncio\windows_events.py”, line 604, in finish_connect
ov.getresult()
OSError: Превышен таймаут семафора

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “C:\Users\Nursultan\PycharmProjects\pythonProject4\venv\lib\site-packages\aiogram\bot\api.py”, line 139, in make_request
async with session.post(url, data=req, **kwargs) as response:
File “C:\Users\Nursultan\PycharmProjects\pythonProject4\venv\lib\site-packages\aiohttp\client.py”, line 1138, in __aenter__
self._resp = await self._coro
File “C:\Users\Nursultan\PycharmProjects\pythonProject4\venv\lib\site-packages\aiohttp\client.py”, line 535, in _request
conn = await self._connector.connect(
File “C:\Users\Nursultan\PycharmProjects\pythonProject4\venv\lib\site-packages\aiohttp\connector.py”, line 542, in connect
proto = await self._create_connection(req, traces, timeout)
File “C:\Users\Nursultan\PycharmProjects\pythonProject4\venv\lib\site-packages\aiohttp\connector.py”, line 907, in _create_connection
_, proto = await self._create_direct_connection(req, traces, timeout)
File “C:\Users\Nursultan\PycharmProjects\pythonProject4\venv\lib\site-packages\aiohttp\connector.py”, line 1206, in _create_direct_connection
raise last_exc
File “C:\Users\Nursultan\PycharmProjects\pythonProject4\venv\lib\site-packages\aiohttp\connector.py”, line 1175, in _create_direct_connection
transp, proto = await self._wrap_create_connection(
File “C:\Users\Nursultan\PycharmProjects\pythonProject4\venv\lib\site-packages\aiohttp\connector.py”, line 992, 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

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “C:\Users\Nursultan\PycharmProjects\pythonProject4\main.py”, line 14, in <module>
executor.start_polling(dp, skip_updates=True)
File “C:\Users\Nursultan\PycharmProjects\pythonProject4\venv\lib\site-packages\aiogram\utils\executor.py”, line 45, in start_polling
executor.start_polling(
File “C:\Users\Nursultan\PycharmProjects\pythonProject4\venv\lib\site-packages\aiogram\utils\executor.py”, line 320, in start_polling
loop.run_until_complete(self._startup_polling())
File “C:\Users\Nursultan\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py”, line 641, in run_until_complete
return future.result()
File “C:\Users\Nursultan\PycharmProjects\pythonProject4\venv\lib\site-packages\aiogram\utils\executor.py”, line 372, in _startup_polling
await self._welcome()
File “C:\Users\Nursultan\PycharmProjects\pythonProject4\venv\lib\site-packages\aiogram\utils\executor.py”, line 361, in _welcome
user = await self.dispatcher.bot.me
File “C:\Users\Nursultan\PycharmProjects\pythonProject4\venv\lib\site-packages\aiogram\bot\bot.py”, line 30, in me
setattr(self, ‘_me’, await self.get_me())
File “C:\Users\Nursultan\PycharmProjects\pythonProject4\venv\lib\site-packages\aiogram\bot\bot.py”, line 228, in get_me
result = await self.request(api.Methods.GET_ME, payload)
File “C:\Users\Nursultan\PycharmProjects\pythonProject4\venv\lib\site-packages\aiogram\bot\base.py”, line 231, in request
return await api.make_request(await self.get_session(), self.server, self.__token, method, data, files,
File “C:\Users\Nursultan\PycharmProjects\pythonProject4\venv\lib\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

Process finished with exit code 1

Прикреплённый файлы:
attachment 2022-03-05_00-06-22.png (42,7 KБ)

Офлайн

#2 Март 5, 2022 20:57:22

xam1816
Зарегистрирован: 2020-05-11
Сообщения: 1360
Репутация: +  119  -
Профиль   Отправить e-mail  

Не запускается простой telegram echo bot, в чём причина?

[code python]код писать между этими тегами[/code]

Офлайн

Board footer

Модераторировать

Powered by DjangoBB

Lo-Fi Version