mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-25 10:53:44 +03:00
Fix connection parameters not being copied on reconnection (#129)
This commit is contained in:
parent
be33ae4e80
commit
765ae870cf
|
@ -181,7 +181,10 @@ class TelegramClient(TelegramBareClient):
|
|||
|
||||
# Create a temporary session for this IP address, which needs
|
||||
# to be different because each auth_key is unique per DC.
|
||||
session = JsonSession(None)
|
||||
#
|
||||
# Construct this session with the connection parameters
|
||||
# (system version, device model...) from the current one.
|
||||
session = JsonSession(self.session)
|
||||
session.server_address = dc.ip_address
|
||||
session.port = dc.port
|
||||
client = TelegramBareClient(session, self.api_id, self.api_hash)
|
||||
|
|
|
@ -99,14 +99,28 @@ class JsonSession:
|
|||
through an official Telegram client to revoke the authorization.
|
||||
"""
|
||||
def __init__(self, session_user_id):
|
||||
"""session_user_id should either be a string or another Session.
|
||||
Note that if another session is given, only parameters like
|
||||
those required to init a connection will be copied.
|
||||
"""
|
||||
# These values will NOT be saved
|
||||
self.session_user_id = session_user_id
|
||||
if isinstance(session_user_id, str):
|
||||
self.session_user_id = session_user_id
|
||||
|
||||
# For connection purposes
|
||||
self.device_model = platform.node()
|
||||
self.system_version = platform.system()
|
||||
self.app_version = '0'
|
||||
self.lang_code = 'en'
|
||||
# For connection purposes
|
||||
self.device_model = platform.node()
|
||||
self.system_version = platform.system()
|
||||
self.app_version = '0'
|
||||
self.lang_code = 'en'
|
||||
|
||||
elif isinstance(session_user_id, JsonSession):
|
||||
self.session_user_id = None
|
||||
|
||||
session = session_user_id
|
||||
self.device_model = session.device_model
|
||||
self.system_version = session.system_version
|
||||
self.app_version = session.app_version
|
||||
self.lang_code = session.lang_code
|
||||
|
||||
# Cross-thread safety
|
||||
self._lock = Lock()
|
||||
|
|
Loading…
Reference in New Issue
Block a user