mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-29 13:27:47 +00:00
parent
2482358484
commit
51cd186559
@ -1221,6 +1221,7 @@ class Client(Methods, BaseClient):
|
|||||||
access_hash=data.access_hash,
|
access_hash=data.access_hash,
|
||||||
thumb_size=data.thumb_size,
|
thumb_size=data.thumb_size,
|
||||||
peer_id=data.peer_id,
|
peer_id=data.peer_id,
|
||||||
|
peer_type=data.peer_type,
|
||||||
peer_access_hash=data.peer_access_hash,
|
peer_access_hash=data.peer_access_hash,
|
||||||
volume_id=data.volume_id,
|
volume_id=data.volume_id,
|
||||||
local_id=data.local_id,
|
local_id=data.local_id,
|
||||||
@ -1866,6 +1867,7 @@ class Client(Methods, BaseClient):
|
|||||||
access_hash: int,
|
access_hash: int,
|
||||||
thumb_size: str,
|
thumb_size: str,
|
||||||
peer_id: int,
|
peer_id: int,
|
||||||
|
peer_type: str,
|
||||||
peer_access_hash: int,
|
peer_access_hash: int,
|
||||||
volume_id: int,
|
volume_id: int,
|
||||||
local_id: int,
|
local_id: int,
|
||||||
@ -1913,11 +1915,23 @@ class Client(Methods, BaseClient):
|
|||||||
file_ref = utils.decode_file_ref(file_ref)
|
file_ref = utils.decode_file_ref(file_ref)
|
||||||
|
|
||||||
if media_type == 1:
|
if media_type == 1:
|
||||||
location = types.InputPeerPhotoFileLocation(
|
if peer_type == "user":
|
||||||
peer=types.InputPeerUser(
|
peer = types.InputPeerUser(
|
||||||
user_id=peer_id,
|
user_id=peer_id,
|
||||||
access_hash=peer_access_hash
|
access_hash=peer_access_hash
|
||||||
),
|
)
|
||||||
|
elif peer_type == "chat":
|
||||||
|
peer = types.InputPeerChat(
|
||||||
|
chat_id=peer_id
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
peer = types.InputPeerChannel(
|
||||||
|
channel_id=peer_id,
|
||||||
|
access_hash=peer_access_hash
|
||||||
|
)
|
||||||
|
|
||||||
|
location = types.InputPeerPhotoFileLocation(
|
||||||
|
peer=peer,
|
||||||
volume_id=volume_id,
|
volume_id=volume_id,
|
||||||
local_id=local_id,
|
local_id=local_id,
|
||||||
big=is_big or None
|
big=is_big or None
|
||||||
|
@ -20,9 +20,9 @@
|
|||||||
class FileData:
|
class FileData:
|
||||||
def __init__(
|
def __init__(
|
||||||
self, *, media_type: int = None, dc_id: int = None, document_id: int = None, access_hash: int = None,
|
self, *, media_type: int = None, dc_id: int = None, document_id: int = None, access_hash: int = None,
|
||||||
thumb_size: str = None, peer_id: int = None, peer_access_hash: int = None, volume_id: int = None,
|
thumb_size: str = None, peer_id: int = None, peer_type: str = None, peer_access_hash: int = None,
|
||||||
local_id: int = None, is_big: bool = None, file_size: int = None, mime_type: str = None, file_name: str = None,
|
volume_id: int = None, local_id: int = None, is_big: bool = None, file_size: int = None, mime_type: str = None,
|
||||||
date: int = None, file_ref: str = None
|
file_name: str = None, date: int = None, file_ref: str = None
|
||||||
):
|
):
|
||||||
self.media_type = media_type
|
self.media_type = media_type
|
||||||
self.dc_id = dc_id
|
self.dc_id = dc_id
|
||||||
@ -30,6 +30,7 @@ class FileData:
|
|||||||
self.access_hash = access_hash
|
self.access_hash = access_hash
|
||||||
self.thumb_size = thumb_size
|
self.thumb_size = thumb_size
|
||||||
self.peer_id = peer_id
|
self.peer_id = peer_id
|
||||||
|
self.peer_type = peer_type
|
||||||
self.peer_access_hash = peer_access_hash
|
self.peer_access_hash = peer_access_hash
|
||||||
self.volume_id = volume_id
|
self.volume_id = volume_id
|
||||||
self.local_id = local_id
|
self.local_id = local_id
|
||||||
|
@ -146,13 +146,23 @@ class DownloadMedia(BaseClient):
|
|||||||
|
|
||||||
if media_type == 1:
|
if media_type == 1:
|
||||||
unpacked = struct.unpack("<iiqqqiiiqi", decoded)
|
unpacked = struct.unpack("<iiqqqiiiqi", decoded)
|
||||||
dc_id, photo_id, _, volume_id, size_type, peer_id, _, peer_access_hash, local_id = unpacked[1:]
|
dc_id, photo_id, _, volume_id, size_type, peer_id, x, peer_access_hash, local_id = unpacked[1:]
|
||||||
|
|
||||||
|
if x == 0:
|
||||||
|
peer_type = "user"
|
||||||
|
elif x == -1:
|
||||||
|
peer_id = -peer_id
|
||||||
|
peer_type = "chat"
|
||||||
|
else:
|
||||||
|
peer_id = utils.get_channel_id(peer_id - 1000727379968)
|
||||||
|
peer_type = "channel"
|
||||||
|
|
||||||
data = FileData(
|
data = FileData(
|
||||||
**get_existing_attributes(),
|
**get_existing_attributes(),
|
||||||
media_type=media_type,
|
media_type=media_type,
|
||||||
dc_id=dc_id,
|
dc_id=dc_id,
|
||||||
peer_id=peer_id,
|
peer_id=peer_id,
|
||||||
|
peer_type=peer_type,
|
||||||
peer_access_hash=peer_access_hash,
|
peer_access_hash=peer_access_hash,
|
||||||
volume_id=volume_id,
|
volume_id=volume_id,
|
||||||
local_id=local_id,
|
local_id=local_id,
|
||||||
|
@ -55,7 +55,7 @@ class ChatPhoto(Object):
|
|||||||
if not isinstance(chat_photo, (types.UserProfilePhoto, types.ChatPhoto)):
|
if not isinstance(chat_photo, (types.UserProfilePhoto, types.ChatPhoto)):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if not peer_access_hash:
|
if peer_access_hash is None:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
photo_id = getattr(chat_photo, "photo_id", 0)
|
photo_id = getattr(chat_photo, "photo_id", 0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user