Учусь писать ботов на языке Python, с помощью библиотеки Aiogram.
Код:
import time
import logging
from aiogram import Bot, Dispatcher, executor, types
import asyncio
TOKEN = "***"
MSG = "Программировал ли ты сегодня?, {}"
bot = Bot(token=TOKEN)
dp = Dispatcher(bot=bot)
@dp.message_handler(commands=['start'])
async def start_handler(message: types.Message):
user_id = message.from_user.id
user_name = message.from_user.first_name
user_full_name = message.from_user.full_name
logging.INFO(f'{user_id=} {user_full_name=}', {time.asctime()})
await message.reply(f'Привет, {user_full_name}!')
for i in range(10):
await asyncio.sleep(2)
await bot.send_message(user_id, MSG.format(user_name))
if __name__ == '__main__':
executor.start_polling(dp, skip_updates=True)
Ошибок не находит, но при запуске, выдает следующие ошибки:
PS C:\Users\Aleksandr> & C:/Users/Aleksandr/AppData/Local/Programs/Python/Python311/python.exe c:/Users/Aleksandr/Desktop/Bots/test.py
Updates were skipped successfully.
Task exception was never retrieved
future: <Task finished name='Task-9' coro=<Dispatcher._process_polling_updates() done, defined at C:\Users\Aleksandr\AppData\Local\Programs\Python\Python311\Lib\site-packages\aiogram\dispatcher\dispatcher.py:407> exception=TypeError("'int' object is not callable")>
Traceback (most recent call last):
File "C:\Users\Aleksandr\AppData\Local\Programs\Python\Python311\Lib\site-packages\aiogram\dispatcher\dispatcher.py", line 415, in _process_polling_updates
for responses in itertools.chain.from_iterable(await self.process_updates(updates, fast)):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Aleksandr\AppData\Local\Programs\Python\Python311\Lib\site-packages\aiogram\dispatcher\dispatcher.py", line 235, in process_updates
return await asyncio.gather(*tasks)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Aleksandr\AppData\Local\Programs\Python\Python311\Lib\site-packages\aiogram\dispatcher\handler.py", line 117, in notify
response = await handler_obj.handler(*args, **partial_data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Aleksandr\AppData\Local\Programs\Python\Python311\Lib\site-packages\aiogram\dispatcher\dispatcher.py", line 256, in process_update
return await self.message_handlers.notify(update.message)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Aleksandr\AppData\Local\Programs\Python\Python311\Lib\site-packages\aiogram\dispatcher\handler.py", line 117, in notify
response = await handler_obj.handler(*args, **partial_data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\Users\Aleksandr\Desktop\Bots\test.py", line 19, in start_handler
logging.INFO(f'{user_id=} {user_full_name=}', {time.asctime()})
TypeError: 'int' object is not callable
В чем может быть ошибка? Интепритатор указал, все установлено правильно.