|
45 | 45 | PhoneCodeExpired, PhoneCodeEmpty, SessionPasswordNeeded, |
46 | 46 | PasswordHashInvalid, FloodWait, PeerIdInvalid, FirstnameInvalid, PhoneNumberBanned, |
47 | 47 | VolumeLocNotFound, UserMigrate, ChannelPrivate, PhoneNumberOccupied, |
48 | | - PasswordRecoveryNa, PasswordEmpty |
| 48 | + PasswordRecoveryNa, PasswordEmpty, AuthBytesInvalid |
49 | 49 | ) |
50 | 50 | from pyrogram.session import Auth, Session |
51 | 51 | from .ext import utils, Syncer, BaseClient, Dispatcher |
@@ -1229,7 +1229,7 @@ def send(self, data: TLObject, retries: int = Session.MAX_RETRIES, timeout: floa |
1229 | 1229 | def load_config(self): |
1230 | 1230 | parser = ConfigParser() |
1231 | 1231 | parser.read(str(self.config_file)) |
1232 | | - |
| 1232 | + |
1233 | 1233 | if self.bot_token: |
1234 | 1234 | pass |
1235 | 1235 | else: |
@@ -1720,30 +1720,35 @@ def get_file( |
1720 | 1720 |
|
1721 | 1721 | if session is None: |
1722 | 1722 | if dc_id != self.storage.dc_id: |
1723 | | - exported_auth = self.send( |
1724 | | - functions.auth.ExportAuthorization( |
1725 | | - dc_id=dc_id |
1726 | | - ) |
1727 | | - ) |
1728 | | - |
1729 | 1723 | session = Session(self, dc_id, Auth(self, dc_id).create(), is_media=True) |
1730 | | - |
1731 | 1724 | session.start() |
1732 | 1725 |
|
1733 | | - self.media_sessions[dc_id] = session |
1734 | | - |
1735 | | - session.send( |
1736 | | - functions.auth.ImportAuthorization( |
1737 | | - id=exported_auth.id, |
1738 | | - bytes=exported_auth.bytes |
| 1726 | + for _ in range(3): |
| 1727 | + exported_auth = self.send( |
| 1728 | + functions.auth.ExportAuthorization( |
| 1729 | + dc_id=dc_id |
| 1730 | + ) |
1739 | 1731 | ) |
1740 | | - ) |
| 1732 | + |
| 1733 | + try: |
| 1734 | + session.send( |
| 1735 | + functions.auth.ImportAuthorization( |
| 1736 | + id=exported_auth.id, |
| 1737 | + bytes=exported_auth.bytes |
| 1738 | + ) |
| 1739 | + ) |
| 1740 | + except AuthBytesInvalid: |
| 1741 | + continue |
| 1742 | + else: |
| 1743 | + break |
| 1744 | + else: |
| 1745 | + session.stop() |
| 1746 | + raise AuthBytesInvalid |
1741 | 1747 | else: |
1742 | 1748 | session = Session(self, dc_id, self.storage.auth_key, is_media=True) |
1743 | | - |
1744 | 1749 | session.start() |
1745 | 1750 |
|
1746 | | - self.media_sessions[dc_id] = session |
| 1751 | + self.media_sessions[dc_id] = session |
1747 | 1752 |
|
1748 | 1753 | if media_type == 1: |
1749 | 1754 | location = types.InputPeerPhotoFileLocation( |
|
0 commit comments