Skip to content

Commit a46ace4

Browse files
committed
Merge develop -> asyncio
2 parents 7f9d3ee + b42c658 commit a46ace4

File tree

2 files changed

+27
-24
lines changed

2 files changed

+27
-24
lines changed

compiler/error/source/400_BAD_REQUEST.tsv

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,4 +123,5 @@ WEBDOCUMENT_INVALID The web document is invalid
123123
WEBDOCUMENT_URL_EMPTY The web document URL is empty
124124
WEBDOCUMENT_URL_INVALID The web document URL is invalid
125125
WEBDOCUMENT_MIME_INVALID The web document mime type is invalid
126-
BUTTON_URL_INVALID The button url is invalid
126+
BUTTON_URL_INVALID The button url is invalid
127+
AUTH_BYTES_INVALID The authorization bytes are invalid

pyrogram/client/client.py

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
PhoneCodeExpired, PhoneCodeEmpty, SessionPasswordNeeded,
4545
PasswordHashInvalid, FloodWait, PeerIdInvalid, FirstnameInvalid, PhoneNumberBanned,
4646
VolumeLocNotFound, UserMigrate, ChannelPrivate, PhoneNumberOccupied,
47-
PasswordRecoveryNa, PasswordEmpty
47+
PasswordRecoveryNa, PasswordEmpty, AuthBytesInvalid
4848
)
4949
from pyrogram.session import Auth, Session
5050
from .ext import utils, Syncer, BaseClient, Dispatcher
@@ -1238,7 +1238,7 @@ async def send(self,
12381238
def load_config(self):
12391239
parser = ConfigParser()
12401240
parser.read(str(self.config_file))
1241-
1241+
12421242
if self.bot_token:
12431243
pass
12441244
else:
@@ -1322,7 +1322,7 @@ async def load_session(self):
13221322
])
13231323

13241324
if session_empty:
1325-
self.storage.dc_id = 4
1325+
self.storage.dc_id = 2
13261326
self.storage.date = 0
13271327

13281328
self.storage.test_mode = self.test_mode
@@ -1745,33 +1745,35 @@ async def get_file(self, media_type: int,
17451745

17461746
if session is None:
17471747
if dc_id != self.storage.dc_id:
1748-
exported_auth = await self.send(
1749-
functions.auth.ExportAuthorization(
1750-
dc_id=dc_id
1751-
)
1752-
)
1753-
1754-
session = Session(
1755-
self,
1756-
dc_id,
1757-
await Auth(self, dc_id).create(), is_media=True)
1758-
1748+
session = Session(self, dc_id, await Auth(self, dc_id).create(), is_media=True)
17591749
await session.start()
17601750

1761-
self.media_sessions[dc_id] = session
1762-
1763-
await session.send(
1764-
functions.auth.ImportAuthorization(
1765-
id=exported_auth.id,
1766-
bytes=exported_auth.bytes
1751+
for _ in range(3):
1752+
exported_auth = await self.send(
1753+
functions.auth.ExportAuthorization(
1754+
dc_id=dc_id
1755+
)
17671756
)
1768-
)
1757+
1758+
try:
1759+
await session.send(
1760+
functions.auth.ImportAuthorization(
1761+
id=exported_auth.id,
1762+
bytes=exported_auth.bytes
1763+
)
1764+
)
1765+
except AuthBytesInvalid:
1766+
continue
1767+
else:
1768+
break
1769+
else:
1770+
await session.stop()
1771+
raise AuthBytesInvalid
17691772
else:
17701773
session = Session(self, dc_id, self.storage.auth_key, is_media=True)
1771-
17721774
await session.start()
17731775

1774-
self.media_sessions[dc_id] = session
1776+
self.media_sessions[dc_id] = session
17751777

17761778
if media_type == 1:
17771779
location = types.InputPeerPhotoFileLocation(

0 commit comments

Comments
 (0)