Set MTProtoSender.auth_key on its creation

This commit is contained in:
Lonami Exo
2018-10-19 13:50:11 +02:00
parent 8563b9560d
commit 945b34b103
2 changed files with 15 additions and 17 deletions

View File

@@ -41,17 +41,15 @@ class MTProtoSender:
A new authorization key will be generated on connection if no other
key exists yet.
"""
def __init__(self, loop, *,
def __init__(self, auth_key, loop, *,
retries=5, auto_reconnect=True, connect_timeout=None,
update_callback=None, auth_key=None,
auth_key_callback=None, auto_reconnect_callback=None):
update_callback=None, auto_reconnect_callback=None):
self._connection = None
self._loop = loop
self._retries = retries
self._auto_reconnect = auto_reconnect
self._connect_timeout = connect_timeout
self._update_callback = update_callback
self._auth_key_callback = auth_key_callback
self._auto_reconnect_callback = auto_reconnect_callback
# Whether the user has explicitly connected or disconnected.
@@ -107,7 +105,7 @@ class MTProtoSender:
# Public API
async def connect(self, auth_key, connection):
async def connect(self, connection):
"""
Connects to the specified given connection using the given auth key.
"""
@@ -115,7 +113,6 @@ class MTProtoSender:
__log__.info('User is already connected!')
return
self._auth_key.key = auth_key
self._connection = connection
self._user_connected = True
await self._connect()
@@ -216,9 +213,6 @@ class MTProtoSender:
self._auth_key.key, self._state.time_offset =\
await authenticator.do_authentication(plain)
if self._auth_key_callback:
await self._auth_key_callback(self._auth_key)
break
except (SecurityError, AssertionError) as e:
__log__.warning('Attempt {} at new auth_key failed: {}'