4
4
4el4elovi42021-08-27 12:45:30
Python
4el4elovi4, 2021-08-27 12:45:30

Why is the aiogram bot not working? and config doesn't see the tokenbot attribute?

Here is my code

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)


writes an error
Traceback (most recent call last):
  File "D:\Python\bot.py", line 10, in <module>
    bot = Bot(token=config.tokenbot)
AttributeError: module 'config' has no attribute 'tokenbot'

how to fix the error so that the tokenbot attribute can be seen
or I need to add it in the dir command please help

me I have a token in config.py TOKEN = '1993058803:AAELNK...'

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikita M., 2021-08-27
@4el4elovi4

From the config you import tokenbot , and in the config itself the token is written as TOKEN

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question