mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-26 19:33:45 +03:00
Fix MTProtoSender should not send content-related queries
This commit is contained in:
parent
145d4b7105
commit
d9d586171f
|
@ -170,7 +170,6 @@ class TelegramBaseClient(abc.ABC):
|
||||||
self._connection = connection
|
self._connection = connection
|
||||||
self._sender = MTProtoSender(
|
self._sender = MTProtoSender(
|
||||||
state, connection, self._loop,
|
state, connection, self._loop,
|
||||||
first_query=self._init_with(functions.help.GetConfigRequest()),
|
|
||||||
update_callback=self._handle_update
|
update_callback=self._handle_update
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -231,6 +230,9 @@ class TelegramBaseClient(abc.ABC):
|
||||||
await self._sender.connect(
|
await self._sender.connect(
|
||||||
self.session.server_address, self.session.port)
|
self.session.server_address, self.session.port)
|
||||||
|
|
||||||
|
await self._sender.send(self._init_with(
|
||||||
|
functions.help.GetConfigRequest()))
|
||||||
|
|
||||||
if not had_auth:
|
if not had_auth:
|
||||||
self.session.auth_key = self._sender.state.auth_key
|
self.session.auth_key = self._sender.state.auth_key
|
||||||
self.session.save()
|
self.session.save()
|
||||||
|
|
|
@ -45,16 +45,14 @@ class MTProtoSender:
|
||||||
A new authorization key will be generated on connection if no other
|
A new authorization key will be generated on connection if no other
|
||||||
key exists yet.
|
key exists yet.
|
||||||
"""
|
"""
|
||||||
def __init__(self, state, connection, loop, *, retries=5,
|
def __init__(self, state, connection, loop, *,
|
||||||
first_query=None, update_callback=None):
|
retries=5, update_callback=None):
|
||||||
self.state = state
|
self.state = state
|
||||||
self._connection = connection
|
self._connection = connection
|
||||||
self._loop = loop
|
self._loop = loop
|
||||||
self._ip = None
|
self._ip = None
|
||||||
self._port = None
|
self._port = None
|
||||||
self._retries = retries
|
self._retries = retries
|
||||||
self._first_query = first_query
|
|
||||||
self._is_first_query = bool(first_query)
|
|
||||||
self._update_callback = update_callback
|
self._update_callback = update_callback
|
||||||
|
|
||||||
# Whether the user has explicitly connected or disconnected.
|
# Whether the user has explicitly connected or disconnected.
|
||||||
|
@ -225,7 +223,6 @@ class MTProtoSender:
|
||||||
|
|
||||||
__log__.debug('Connection success!')
|
__log__.debug('Connection success!')
|
||||||
if self.state.auth_key is None:
|
if self.state.auth_key is None:
|
||||||
self._is_first_query = bool(self._first_query)
|
|
||||||
plain = MTProtoPlainSender(self._connection)
|
plain = MTProtoPlainSender(self._connection)
|
||||||
for retry in range(1, self._retries + 1):
|
for retry in range(1, self._retries + 1):
|
||||||
try:
|
try:
|
||||||
|
@ -248,11 +245,6 @@ class MTProtoSender:
|
||||||
__log__.debug('Starting receive loop')
|
__log__.debug('Starting receive loop')
|
||||||
self._recv_loop_handle = self._loop.create_task(self._recv_loop())
|
self._recv_loop_handle = self._loop.create_task(self._recv_loop())
|
||||||
|
|
||||||
if self._is_first_query:
|
|
||||||
__log__.debug('Running first query')
|
|
||||||
self._is_first_query = False
|
|
||||||
await self.send(self._first_query)
|
|
||||||
|
|
||||||
__log__.info('Connection to {} complete!'.format(self._ip))
|
__log__.info('Connection to {} complete!'.format(self._ip))
|
||||||
|
|
||||||
async def _reconnect(self):
|
async def _reconnect(self):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user