Handle Voice type

This commit is contained in:
Dan 2018-04-04 22:27:05 +02:00
parent 70fa667ef9
commit c1e6f9c2ca

View File

@ -139,6 +139,7 @@ def parse_message(message: types.Message, users: dict, chats: dict):
location = None
contact = None
audio = None
voice = None
video = None
video_note = None
@ -207,6 +208,22 @@ def parse_message(message: types.Message, users: dict, chats: dict):
if types.DocumentAttributeAudio in attributes:
audio_attributes = attributes[types.DocumentAttributeAudio]
if audio_attributes.voice:
voice = pyrogram.Voice(
file_id=encode(
pack(
"<iiqq",
3,
doc.dc_id,
doc.id,
doc.access_hash
)
),
duration=audio_attributes.duration,
mime_type=doc.mime_type,
file_size=doc.size
)
else:
audio = pyrogram.Audio(
file_id=encode(
pack(
@ -281,6 +298,7 @@ def parse_message(message: types.Message, users: dict, chats: dict):
location=location,
contact=contact,
audio=audio,
voice=voice,
video=video,
video_note=video_note
)