If you try to edit the Voice media in a message, the error line 337, in edit_media is displayed
media = INPUT_MEDIA_TYPES[new_message.media.type]( KeyError: 'voice'. It may be necessary to delete the message and send a new one to 'change' it, in the same way as 'changing' a message without media to one with media.
The way I've solved it is this:
File aiogram_dialog/manager/message_manager.py:
Added Line 62:
content_type=message_result.content_type,Edited To had_media function:
line 100-112:
def _can_edit(self, new_message: NewMessage,
old_message: OldMessage) -> bool:
# we cannot edit message if media appeared or removed
if self.had_voice(old_message):
return False
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)
)
Edited to show_message function:
line 190:
if not self._can_edit(new_message, old_message) or new_message.media.type == 'voice':
File aiogram_dialog/api/entities/new_message.py:
Added To OldMessage class:
line 25:
content_type: str
File aiogram_dialog/manager/manager.py:
Added to the _get_message_from_callback function:
line 400:
content_type=current_message.content_type,
Added to the _get_last_message function:
Line 437:
content_type=event.content_type,
And to put it simply, I added a check if they want to change the message with content_type = 'voice'. If this condition is met, all deletion will follow the chain of deleting a message without media and sending it with media
If you try to edit the Voice media in a message, the error line 337, in edit_media is displayed media = INPUT_MEDIA_TYPES[new_message.media.type]( KeyError: 'voice'. It may be necessary to delete the message and send a new one to 'change' it, in the same way as 'changing' a message without media to one with media.
The way I've solved it is this: File aiogram_dialog/manager/message_manager.py: Added Line 62:
content_type=message_result.content_type,
Edited To had_media function: line 100-112:Edited to _can_edit function: line 148:
Edited to show_message function: line 190:
if not self._can_edit(new_message, old_message) or new_message.media.type == 'voice':
File aiogram_dialog/api/entities/new_message.py: Added To OldMessage class: line 25:
content_type: str
File aiogram_dialog/manager/manager.py: Added to the _get_message_from_callback function: line 400:
content_type=current_message.content_type,
Added to the _get_last_message function: Line 437:
content_type=event.content_type,
And to put it simply, I added a check if they want to change the message with content_type = 'voice'. If this condition is met, all deletion will follow the chain of deleting a message without media and sending it with media