Z
Z
zaharovmail2020-07-30 13:34:06
Python
zaharovmail, 2020-07-30 13:34:06

How to solve the problem, python bot with aiogram library does not start?

Created a simple bot for testing

import config
import logging
from aiogram import Bot, Dispatcher, executor, types

# Задаем уровень логов
logging.basicConfig(level=logging.INFO)

# Инициализация бота
bot = Bot(token=config.tokenbot)
dp = Dispatcher(bot)


# Эхо
@dp.message_handler()
async def echo(message: types.Message):
    await message.answer(message.text)


# запускаем лонг поллинг
if __name__ == '__main__':
    executor.start_polling(dp, skip_updates=True)


But on startup it gives an error

WARNING:aiogram:Goodbye!
Traceback (most recent call last):
File "C:/Users/zahar/Downloads/bot/bot.py", line 21, in
executor.start_polling(dp, skip_updates=True)
File "C:\Users\zahar\Downloads \bot\venv\lib\site-packages\aiogram\utils\executor.py", line 41, in start_polling
executor.start_polling(reset_webhook=reset_webhook, timeout=timeout, relax=relax, fast=fast)
File "C:\ Users\zahar\Downloads\bot\venv\lib\site-packages\aiogram\utils\executor.py", line 305, in start_polling
loop.run_until_complete(self._startup_polling())
File "C:\Users\zahar\AppData \Local\Programs\Python\Python38-32\lib\asyncio\base_events.py", line 616, in run_until_complete
return future.result()
File "C:\Users\zahar\Downloads\bot\venv\lib\site-packages\aiogram\utils\executor.py", line 356, in _startup_polling
await self._welcome()
File "C:\Users\zahar\ Downloads\bot\venv\lib\site-packages\aiogram\utils\executor.py", line 346, in _welcome
user = await self.dispatcher.bot.me
File "C:\Users\zahar\Downloads\bot\venv \lib\site-packages\aiogram\bot\bot.py", line 27, in me
setattr(self, '_me', await self.get_me())
File "C:\Users\zahar\Downloads\bot\venv \lib\site-packages\aiogram\bot\bot.py", line 176, in get_me
result = await self.request(api.Methods.GET_ME, payload)
File "C:\Users\zahar\Downloads\bot\venv \lib\site-packages\aiogram\bot\base.py", line 201, in request
return await api.make_request(self.session, self.__token, method, data, files,
File "C:\Users\zahar\Downloads\bot\venv\lib\site-packages\aiogram\bot\api.py", line 104, in make_request
return check_result(method, response.content_type, response.status, await response.text())
File "C:\Users\zahar\Downloads\bot\venv\lib\site-packages\aiogram\bot\ api.py", line 84, in check_result
exceptions.Unauthorized.detect(description)
File "C:\Users\zahar\Downloads\bot\venv\lib\site-packages\aiogram\utils\exceptions.py", line 137 , in detect
raise cls(description)
aiogram.utils.exceptions.Unauthorized: Unauthorized


I've read everything I could on the Internet, I can not understand what the problem is.
Several times I installed the library, everything I could update.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
SKEPTIC, 2020-07-30
@zaharovmail

Something is wrong with the token. Where did you get the token from? With bot father? Maybe I didn't copy everything?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question