mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-02-18 04:20:57 +03:00
Fix StringSession(None)
This commit is contained in:
parent
0011f19f8b
commit
8ce001318e
|
@ -18,16 +18,18 @@ class StringSession(MemorySession):
|
||||||
"""
|
"""
|
||||||
def __init__(self, string=None):
|
def __init__(self, string=None):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
if string and string[0] != CURRENT_VERSION:
|
if string:
|
||||||
raise ValueError('Not a valid string')
|
if string[0] != CURRENT_VERSION:
|
||||||
|
raise ValueError('Not a valid string')
|
||||||
|
|
||||||
ip_len = 4 if len(string) == 353 else 16
|
string = string[1:]
|
||||||
self._dc_id, ip, self._port, key = struct.unpack(
|
ip_len = 4 if len(string) == 352 else 16
|
||||||
'>B{}sH256s'.format(ip_len), base64.urlsafe_b64decode(string[1:]))
|
self._dc_id, ip, self._port, key = struct.unpack(
|
||||||
|
'>B{}sH256s'.format(ip_len), base64.urlsafe_b64decode(string))
|
||||||
|
|
||||||
self._server_address = ipaddress.ip_address(ip).compressed
|
self._server_address = ipaddress.ip_address(ip).compressed
|
||||||
if any(key):
|
if any(key):
|
||||||
self._auth_key = AuthKey(key)
|
self._auth_key = AuthKey(key)
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
if not self._auth_key:
|
if not self._auth_key:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user