diff --git a/pyrogram/client/types/messages_and_media/audio.py b/pyrogram/client/types/messages_and_media/audio.py index 37f91992..3f2b3c20 100644 --- a/pyrogram/client/types/messages_and_media/audio.py +++ b/pyrogram/client/types/messages_and_media/audio.py @@ -16,7 +16,12 @@ # You should have received a copy of the GNU Lesser General Public License # along with Pyrogram. If not, see . +from struct import pack + +from pyrogram.api import types from pyrogram.api.core import Object +from .photo_size import PhotoSize +from ...ext.utils import encode class Audio(Object): @@ -53,18 +58,10 @@ class Audio(Object): ID = 0xb0700006 - def __init__( - self, - file_id: str, - duration: int, - thumb=None, - file_name: str = None, - mime_type: str = None, - file_size: int = None, - date: int = None, - performer: str = None, - title: str = None - ): + def __init__(self, file_id: str, duration: int, *, + thumb=None, file_name: str = None, mime_type: str = None, file_size: int = None, date: int = None, + performer: str = None, title: str = None, + client=None, raw=None): self.file_id = file_id self.thumb = thumb self.file_name = file_name @@ -74,3 +71,30 @@ class Audio(Object): self.duration = duration self.performer = performer self.title = title + + self._client = client + self._raw = raw + + @staticmethod + def parse(client, audio: types.Document, audio_attributes: types.DocumentAttributeAudio, file_name: str) -> "Audio": + return Audio( + file_id=encode( + pack( + ". +from pyrogram.api import types from pyrogram.api.core import Object +from ...ext.utils import encode +from struct import pack class Voice(Object): @@ -44,17 +47,36 @@ class Voice(Object): ID = 0xb0700009 - def __init__( - self, - file_id: str, - duration: int, - waveform: bytes = None, - mime_type: str = None, - file_size: int = None, - date: int = None): + def __init__(self, file_id: str, duration: int, *, + waveform: bytes = None, mime_type: str = None, file_size: int = None, date: int = None, + client=None, raw=None): self.file_id = file_id self.duration = duration self.waveform = waveform self.mime_type = mime_type self.file_size = file_size self.date = date + + self._client = client + self._raw = raw + + @staticmethod + def parse(client, voice: types.Document, attributes: types.DocumentAttributeAudio) -> "Voice": + return Voice( + file_id=encode( + pack( + "