最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

python - INFO:aiogram.event:Update id=??????????? is not handled - Stack Overflow

programmeradmin6浏览0评论

I have a big telegram bot project. Today, he suddenly stopped showing signs of life. I don't know exactly what changes led to this result. The problem is that the handler has stopped responding to commands.

INFO:aiogram.dispatcher:Start polling
INFO:aiogram.dispatcher:Run polling for bot ...
INFO:aiogram.event:Update id=????? is not handled. Duration 0 ms by bot id=?????

I've reduced the code to basic, but it still doesn't work, what could be the reason?

main.py

import logging
import asyncio
from aiogram.types import Message, FSInputFile
from aiogram.filters import CommandStart
from aiogram import Bot, Dispatcher


bot = Bot(token="79127??????????????????fXTNyc")
dp = Dispatcher()


async def main():
    await dp.start_polling(bot)


if __name__ == '__main__':
    logging.basicConfig(level=logging.INFO)
    asyncio.run(main())


logo_photo = FSInputFile('212649.png')


@dp.message(CommandStart())
async def cmd_start(message: Message):
    await message.answer_photo(photo=logo_photo, caption='текст')

PS: the id and token are hidden intentionally

I have a big telegram bot project. Today, he suddenly stopped showing signs of life. I don't know exactly what changes led to this result. The problem is that the handler has stopped responding to commands.

INFO:aiogram.dispatcher:Start polling
INFO:aiogram.dispatcher:Run polling for bot ...
INFO:aiogram.event:Update id=????? is not handled. Duration 0 ms by bot id=?????

I've reduced the code to basic, but it still doesn't work, what could be the reason?

main.py

import logging
import asyncio
from aiogram.types import Message, FSInputFile
from aiogram.filters import CommandStart
from aiogram import Bot, Dispatcher


bot = Bot(token="79127??????????????????fXTNyc")
dp = Dispatcher()


async def main():
    await dp.start_polling(bot)


if __name__ == '__main__':
    logging.basicConfig(level=logging.INFO)
    asyncio.run(main())


logo_photo = FSInputFile('212649.png')


@dp.message(CommandStart())
async def cmd_start(message: Message):
    await message.answer_photo(photo=logo_photo, caption='текст')

PS: the id and token are hidden intentionally

Share Improve this question edited Nov 17, 2024 at 12:20 Maurice Meyer 18.1k4 gold badges35 silver badges52 bronze badges asked Nov 17, 2024 at 12:18 Илья ДьяченкоИлья Дьяченко 1
Add a comment  | 

1 Answer 1

Reset to default 0

Your function cmd_start just cannot be handled because when your bot started polling, the cmd_start wasn't declared. You should place the cmd_start before you run the main function. You should have the code like this at least:

import logging
import asyncio
from aiogram.types import Message, FSInputFile
from aiogram.filters import CommandStart
from aiogram import Bot, Dispatcher


bot = Bot(token="79127??????????????????fXTNyc")
dp = Dispatcher()


logo_photo = FSInputFile('212649.png')

# the function is declared before entering the main working loop
@dp.message(CommandStart())
async def cmd_start(message: Message):
    await message.answer_photo(photo=logo_photo, caption='текст')

async def main():
    await dp.start_polling(bot)

# all handlers are declared and now you can run the bot
if __name__ == '__main__':
    logging.basicConfig(level=logging.INFO)
    asyncio.run(main())
发布评论

评论列表(0)

  1. 暂无评论