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