mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-09 13:29:47 +00:00
Completely refactored unit tests, removed unused code
This commit is contained in:
@@ -13,10 +13,9 @@ from tl.all_tlobjects import tlobjects
|
||||
|
||||
class MtProtoSender:
|
||||
"""MTProto Mobile Protocol sender (https://core.telegram.org/mtproto/description)"""
|
||||
def __init__(self, transport, session, swallow_errors=True):
|
||||
def __init__(self, transport, session):
|
||||
self.transport = transport
|
||||
self.session = session
|
||||
self.swallow_errors = swallow_errors
|
||||
|
||||
self.need_confirmation = [] # Message IDs that need confirmation
|
||||
self.on_update_handlers = []
|
||||
@@ -59,18 +58,11 @@ class MtProtoSender:
|
||||
def receive(self, request):
|
||||
"""Receives the specified MTProtoRequest ("fills in it" the received data)"""
|
||||
while not request.confirm_received:
|
||||
try:
|
||||
message, remote_msg_id, remote_sequence = self.decode_msg(self.transport.receive().body)
|
||||
|
||||
with BinaryReader(message) as reader:
|
||||
self.process_msg(remote_msg_id, remote_sequence, reader, request)
|
||||
|
||||
except RPCError as error:
|
||||
if self.swallow_errors:
|
||||
print('A RPC error occurred when decoding a message: {}'.format(error))
|
||||
else:
|
||||
raise error
|
||||
seq, body = self.transport.receive()
|
||||
message, remote_msg_id, remote_sequence = self.decode_msg(body)
|
||||
|
||||
with BinaryReader(message) as reader:
|
||||
self.process_msg(remote_msg_id, remote_sequence, reader, request)
|
||||
|
||||
# endregion
|
||||
|
||||
|
Reference in New Issue
Block a user