diff --git a/src/aiogram_dialog/manager/message_manager.py b/src/aiogram_dialog/manager/message_manager.py index 773c9cb2..0c0a766d 100644 --- a/src/aiogram_dialog/manager/message_manager.py +++ b/src/aiogram_dialog/manager/message_manager.py @@ -132,11 +132,12 @@ def _message_changed( def _can_edit(self, new_message: NewMessage, old_message: OldMessage) -> bool: - # we cannot edit message if media appeared or removed - return ( - self.had_media(old_message) == self.need_media(new_message) and - not self.had_reply_keyboard(old_message) and - not self.need_reply_keyboard(new_message) + # we cannot edit message if media removed + if self.had_media(old_message) and not self.need_media(new_message): + return False + return not ( + self.had_reply_keyboard(old_message) or + self.need_reply_keyboard(new_message) ) async def show_message( @@ -293,7 +294,10 @@ async def edit_message( self, bot: Bot, new_message: NewMessage, old_message: OldMessage, ) -> Message: if new_message.media: - if new_message.media.file_id == old_message.media_id: + if ( + old_message.media_id is not None and + new_message.media.file_id == old_message.media_id + ): return await self.edit_caption(bot, new_message, old_message) return await self.edit_media(bot, new_message, old_message) else: