From 033119e9b8f1b56f19b897f89d35c2b4d975556f Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Fri, 20 Oct 2017 22:07:45 +0200 Subject: [PATCH] Make MtProtoSender._need_confirmation a set This will avoid adding duplicated items to it --- telethon/network/mtproto_sender.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/telethon/network/mtproto_sender.py b/telethon/network/mtproto_sender.py index 61e60484..8c73390f 100644 --- a/telethon/network/mtproto_sender.py +++ b/telethon/network/mtproto_sender.py @@ -39,7 +39,7 @@ class MtProtoSender: self._logger = logging.getLogger(__name__) # Message IDs that need confirmation - self._need_confirmation = [] + self._need_confirmation = set() # Requests (as msg_id: Message) sent waiting to be received self._pending_receive = {} @@ -74,7 +74,7 @@ class MtProtoSender: # Pack everything in the same container if we need to send AckRequests if self._need_confirmation: messages.append( - TLMessage(self.session, MsgsAck(self._need_confirmation)) + TLMessage(self.session, MsgsAck(list(self._need_confirmation))) ) self._need_confirmation.clear() @@ -183,7 +183,7 @@ class MtProtoSender: ) return False - self._need_confirmation.append(msg_id) + self._need_confirmation.add(msg_id) code = reader.read_int(signed=False) reader.seek(-4)