mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-29 05:18:10 +00:00
Merge develop -> asyncio
This commit is contained in:
commit
a46ace4e5c
@ -123,4 +123,5 @@ WEBDOCUMENT_INVALID The web document is invalid
|
|||||||
WEBDOCUMENT_URL_EMPTY The web document URL is empty
|
WEBDOCUMENT_URL_EMPTY The web document URL is empty
|
||||||
WEBDOCUMENT_URL_INVALID The web document URL is invalid
|
WEBDOCUMENT_URL_INVALID The web document URL is invalid
|
||||||
WEBDOCUMENT_MIME_INVALID The web document mime type is invalid
|
WEBDOCUMENT_MIME_INVALID The web document mime type is invalid
|
||||||
BUTTON_URL_INVALID The button url is invalid
|
BUTTON_URL_INVALID The button url is invalid
|
||||||
|
AUTH_BYTES_INVALID The authorization bytes are invalid
|
|
@ -44,7 +44,7 @@ from pyrogram.errors import (
|
|||||||
PhoneCodeExpired, PhoneCodeEmpty, SessionPasswordNeeded,
|
PhoneCodeExpired, PhoneCodeEmpty, SessionPasswordNeeded,
|
||||||
PasswordHashInvalid, FloodWait, PeerIdInvalid, FirstnameInvalid, PhoneNumberBanned,
|
PasswordHashInvalid, FloodWait, PeerIdInvalid, FirstnameInvalid, PhoneNumberBanned,
|
||||||
VolumeLocNotFound, UserMigrate, ChannelPrivate, PhoneNumberOccupied,
|
VolumeLocNotFound, UserMigrate, ChannelPrivate, PhoneNumberOccupied,
|
||||||
PasswordRecoveryNa, PasswordEmpty
|
PasswordRecoveryNa, PasswordEmpty, AuthBytesInvalid
|
||||||
)
|
)
|
||||||
from pyrogram.session import Auth, Session
|
from pyrogram.session import Auth, Session
|
||||||
from .ext import utils, Syncer, BaseClient, Dispatcher
|
from .ext import utils, Syncer, BaseClient, Dispatcher
|
||||||
@ -1238,7 +1238,7 @@ class Client(Methods, BaseClient):
|
|||||||
def load_config(self):
|
def load_config(self):
|
||||||
parser = ConfigParser()
|
parser = ConfigParser()
|
||||||
parser.read(str(self.config_file))
|
parser.read(str(self.config_file))
|
||||||
|
|
||||||
if self.bot_token:
|
if self.bot_token:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
@ -1322,7 +1322,7 @@ class Client(Methods, BaseClient):
|
|||||||
])
|
])
|
||||||
|
|
||||||
if session_empty:
|
if session_empty:
|
||||||
self.storage.dc_id = 4
|
self.storage.dc_id = 2
|
||||||
self.storage.date = 0
|
self.storage.date = 0
|
||||||
|
|
||||||
self.storage.test_mode = self.test_mode
|
self.storage.test_mode = self.test_mode
|
||||||
@ -1745,33 +1745,35 @@ class Client(Methods, BaseClient):
|
|||||||
|
|
||||||
if session is None:
|
if session is None:
|
||||||
if dc_id != self.storage.dc_id:
|
if dc_id != self.storage.dc_id:
|
||||||
exported_auth = await self.send(
|
session = Session(self, dc_id, await Auth(self, dc_id).create(), is_media=True)
|
||||||
functions.auth.ExportAuthorization(
|
|
||||||
dc_id=dc_id
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
session = Session(
|
|
||||||
self,
|
|
||||||
dc_id,
|
|
||||||
await Auth(self, dc_id).create(), is_media=True)
|
|
||||||
|
|
||||||
await session.start()
|
await session.start()
|
||||||
|
|
||||||
self.media_sessions[dc_id] = session
|
for _ in range(3):
|
||||||
|
exported_auth = await self.send(
|
||||||
await session.send(
|
functions.auth.ExportAuthorization(
|
||||||
functions.auth.ImportAuthorization(
|
dc_id=dc_id
|
||||||
id=exported_auth.id,
|
)
|
||||||
bytes=exported_auth.bytes
|
|
||||||
)
|
)
|
||||||
)
|
|
||||||
|
try:
|
||||||
|
await session.send(
|
||||||
|
functions.auth.ImportAuthorization(
|
||||||
|
id=exported_auth.id,
|
||||||
|
bytes=exported_auth.bytes
|
||||||
|
)
|
||||||
|
)
|
||||||
|
except AuthBytesInvalid:
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
await session.stop()
|
||||||
|
raise AuthBytesInvalid
|
||||||
else:
|
else:
|
||||||
session = Session(self, dc_id, self.storage.auth_key, is_media=True)
|
session = Session(self, dc_id, self.storage.auth_key, is_media=True)
|
||||||
|
|
||||||
await session.start()
|
await session.start()
|
||||||
|
|
||||||
self.media_sessions[dc_id] = session
|
self.media_sessions[dc_id] = session
|
||||||
|
|
||||||
if media_type == 1:
|
if media_type == 1:
|
||||||
location = types.InputPeerPhotoFileLocation(
|
location = types.InputPeerPhotoFileLocation(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user