2
0
mirror of https://github.com/pyrogram/pyrogram synced 2025-08-29 05:18:10 +00:00

Update the order in which media messages are parsed

This commit is contained in:
Dan 2022-12-06 18:09:42 +01:00
parent d734fbb180
commit 3cf1ac7d92

View File

@ -364,7 +364,7 @@ class Message(Object, Update):
pinned_message: "Message" = None, pinned_message: "Message" = None,
game_high_score: int = None, game_high_score: int = None,
views: int = None, views: int = None,
forwards: int = None, forwards: int = None,
via_bot: "types.User" = None, via_bot: "types.User" = None,
outgoing: bool = None, outgoing: bool = None,
matches: List[Match] = None, matches: List[Match] = None,
@ -687,16 +687,7 @@ class Message(Object, Update):
), "file_name", None ), "file_name", None
) )
if raw.types.DocumentAttributeAudio in attributes: if raw.types.DocumentAttributeAnimated in attributes:
audio_attributes = attributes[raw.types.DocumentAttributeAudio]
if audio_attributes.voice:
voice = types.Voice._parse(client, doc, audio_attributes)
media_type = enums.MessageMediaType.VOICE
else:
audio = types.Audio._parse(client, doc, audio_attributes, file_name)
media_type = enums.MessageMediaType.AUDIO
elif raw.types.DocumentAttributeAnimated in attributes:
video_attributes = attributes.get(raw.types.DocumentAttributeVideo, None) video_attributes = attributes.get(raw.types.DocumentAttributeVideo, None)
animation = types.Animation._parse(client, doc, video_attributes, file_name) animation = types.Animation._parse(client, doc, video_attributes, file_name)
media_type = enums.MessageMediaType.ANIMATION media_type = enums.MessageMediaType.ANIMATION
@ -712,6 +703,15 @@ class Message(Object, Update):
else: else:
video = types.Video._parse(client, doc, video_attributes, file_name, media.ttl_seconds) video = types.Video._parse(client, doc, video_attributes, file_name, media.ttl_seconds)
media_type = enums.MessageMediaType.VIDEO media_type = enums.MessageMediaType.VIDEO
elif raw.types.DocumentAttributeAudio in attributes:
audio_attributes = attributes[raw.types.DocumentAttributeAudio]
if audio_attributes.voice:
voice = types.Voice._parse(client, doc, audio_attributes)
media_type = enums.MessageMediaType.VOICE
else:
audio = types.Audio._parse(client, doc, audio_attributes, file_name)
media_type = enums.MessageMediaType.AUDIO
else: else:
document = types.Document._parse(client, doc, file_name) document = types.Document._parse(client, doc, file_name)
media_type = enums.MessageMediaType.DOCUMENT media_type = enums.MessageMediaType.DOCUMENT