Answer the question
In order to leave comments, you need to log in
How to get bot message ID in python TelegramBotApi or aiogram?
I need the bot to determine the ID of its last message so that it can be deleted later.
Answer the question
In order to leave comments, you need to log in
The only option that comes to mind is the user's last message + 1.
That is:
@dp.message_handler()
async def other_command(message: types.Message):
next_id = message.message_id + 1
For a bot that will be used by more than 1 person, it is better not to resort to the method:
@dp.message_handler()
async def other_command(message: types.Message):
next_id = message.message_id + 1
@dp.message_handler()
async def bot_answer(message: types.Message):
msg = await message.answer('Последнее сообщение бота')
next_id = msg.message_id
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question