Skip to content

Commit c929ce3

Browse files
committed
Merge develop -> asyncio
2 parents 79a04f2 + e74521b commit c929ce3

8 files changed

Lines changed: 44 additions & 10 deletions

File tree

compiler/error/source/400_BAD_REQUEST.tsv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ WEBDOCUMENT_URL_INVALID The web document URL is invalid
125125
WEBDOCUMENT_MIME_INVALID The web document mime type is invalid
126126
BUTTON_URL_INVALID The button url is invalid
127127
AUTH_BYTES_INVALID The authorization bytes are invalid
128+
USER_ID_INVALID The user ID is invalid
128129
CHANNELS_TOO_MUCH You have joined too many channels or supergroups
129130
ADMIN_RANK_INVALID The custom administrator title is invalid or is longer than 16 characters
130131
ADMIN_RANK_EMOJI_NOT_ALLOWED Emojis are not allowed in custom administrator titles

docs/source/conf.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434
extensions = [
3535
"sphinx.ext.autodoc",
3636
"sphinx.ext.napoleon",
37-
"sphinx.ext.autosummary"
37+
"sphinx.ext.autosummary",
38+
"sphinx_copybutton"
3839
]
3940

4041
master_doc = "index"

pyrogram/client/client.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1232,6 +1232,7 @@ async def download_worker(self):
12321232
access_hash=data.access_hash,
12331233
thumb_size=data.thumb_size,
12341234
peer_id=data.peer_id,
1235+
peer_type=data.peer_type,
12351236
peer_access_hash=data.peer_access_hash,
12361237
volume_id=data.volume_id,
12371238
local_id=data.local_id,
@@ -1889,6 +1890,7 @@ async def get_file(
18891890
access_hash: int,
18901891
thumb_size: str,
18911892
peer_id: int,
1893+
peer_type: str,
18921894
peer_access_hash: int,
18931895
volume_id: int,
18941896
local_id: int,
@@ -1936,11 +1938,23 @@ async def get_file(
19361938
file_ref = utils.decode_file_ref(file_ref)
19371939

19381940
if media_type == 1:
1939-
location = types.InputPeerPhotoFileLocation(
1940-
peer=types.InputPeerUser(
1941+
if peer_type == "user":
1942+
peer = types.InputPeerUser(
19411943
user_id=peer_id,
19421944
access_hash=peer_access_hash
1943-
),
1945+
)
1946+
elif peer_type == "chat":
1947+
peer = types.InputPeerChat(
1948+
chat_id=peer_id
1949+
)
1950+
else:
1951+
peer = types.InputPeerChannel(
1952+
channel_id=peer_id,
1953+
access_hash=peer_access_hash
1954+
)
1955+
1956+
location = types.InputPeerPhotoFileLocation(
1957+
peer=peer,
19441958
volume_id=volume_id,
19451959
local_id=local_id,
19461960
big=is_big or None

pyrogram/client/ext/file_data.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,17 @@
2020
class FileData:
2121
def __init__(
2222
self, *, media_type: int = None, dc_id: int = None, document_id: int = None, access_hash: int = None,
23-
thumb_size: str = None, peer_id: int = None, peer_access_hash: int = None, volume_id: int = None,
24-
local_id: int = None, is_big: bool = None, file_size: int = None, mime_type: str = None, file_name: str = None,
25-
date: int = None, file_ref: str = None
23+
thumb_size: str = None, peer_id: int = None, peer_type: str = None, peer_access_hash: int = None,
24+
volume_id: int = None, local_id: int = None, is_big: bool = None, file_size: int = None, mime_type: str = None,
25+
file_name: str = None, date: int = None, file_ref: str = None
2626
):
2727
self.media_type = media_type
2828
self.dc_id = dc_id
2929
self.document_id = document_id
3030
self.access_hash = access_hash
3131
self.thumb_size = thumb_size
3232
self.peer_id = peer_id
33+
self.peer_type = peer_type
3334
self.peer_access_hash = peer_access_hash
3435
self.volume_id = volume_id
3536
self.local_id = local_id

pyrogram/client/methods/messages/download_media.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,23 @@ def get_existing_attributes() -> dict:
147147

148148
if media_type == 1:
149149
unpacked = struct.unpack("<iiqqqiiiqi", decoded)
150-
dc_id, photo_id, _, volume_id, size_type, peer_id, _, peer_access_hash, local_id = unpacked[1:]
150+
dc_id, photo_id, _, volume_id, size_type, peer_id, x, peer_access_hash, local_id = unpacked[1:]
151+
152+
if x == 0:
153+
peer_type = "user"
154+
elif x == -1:
155+
peer_id = -peer_id
156+
peer_type = "chat"
157+
else:
158+
peer_id = utils.get_channel_id(peer_id - 1000727379968)
159+
peer_type = "channel"
151160

152161
data = FileData(
153162
**get_existing_attributes(),
154163
media_type=media_type,
155164
dc_id=dc_id,
156165
peer_id=peer_id,
166+
peer_type=peer_type,
157167
peer_access_hash=peer_access_hash,
158168
volume_id=volume_id,
159169
local_id=local_id,

pyrogram/client/types/list.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ def __str__(self):
2727
return Object.__str__(self)
2828

2929
def __repr__(self):
30-
return "pyrogram.client.types.pyrogram_list.PyrogramList([{}])".format(
30+
return "pyrogram.client.types.list.List([{}])".format(
3131
",".join(Object.__repr__(i) for i in self)
3232
)

pyrogram/client/types/user_and_chats/chat.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ class Chat(Object):
4444
True, if this chat has been restricted. Supergroups, channels and bots only.
4545
See *restriction_reason* for details.
4646
47+
is_creator (``bool``, *optional*):
48+
True, if this chat owner is the current user. Supergroups, channels and groups only.
49+
4750
is_scam (``bool``, *optional*):
4851
True, if this chat has been flagged for scam. Supergroups, channels and bots only.
4952
@@ -108,6 +111,7 @@ def __init__(
108111
type: str,
109112
is_verified: bool = None,
110113
is_restricted: bool = None,
114+
is_creator: bool = None,
111115
is_scam: bool = None,
112116
is_support: bool = None,
113117
title: str = None,
@@ -131,6 +135,7 @@ def __init__(
131135
self.type = type
132136
self.is_verified = is_verified
133137
self.is_restricted = is_restricted
138+
self.is_creator = is_creator
134139
self.is_scam = is_scam
135140
self.is_support = is_support
136141
self.title = title
@@ -175,6 +180,7 @@ def _parse_chat_chat(client, chat: types.Chat) -> "Chat":
175180
id=peer_id,
176181
type="group",
177182
title=chat.title,
183+
is_creator=getattr(chat, "creator", None),
178184
photo=ChatPhoto._parse(client, getattr(chat, "photo", None), peer_id, 0),
179185
permissions=ChatPermissions._parse(getattr(chat, "default_banned_rights", None)),
180186
members_count=getattr(chat, "participants_count", None),
@@ -191,6 +197,7 @@ def _parse_channel_chat(client, channel: types.Channel) -> "Chat":
191197
type="supergroup" if channel.megagroup else "channel",
192198
is_verified=getattr(channel, "verified", None),
193199
is_restricted=getattr(channel, "restricted", None),
200+
is_creator=getattr(channel, "creator", None),
194201
is_scam=getattr(channel, "scam", None),
195202
title=channel.title,
196203
username=getattr(channel, "username", None),

pyrogram/client/types/user_and_chats/chat_photo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def _parse(client, chat_photo: types.UserProfilePhoto or types.ChatPhoto, peer_i
5555
if not isinstance(chat_photo, (types.UserProfilePhoto, types.ChatPhoto)):
5656
return None
5757

58-
if not peer_access_hash:
58+
if peer_access_hash is None:
5959
return None
6060

6161
photo_id = getattr(chat_photo, "photo_id", 0)

0 commit comments

Comments
 (0)