File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2020from hashlib import sha256
2121from io import BytesIO
2222from os import urandom
23- from typing import List , Tuple
23+ from typing import List
2424
2525from pyrogram .raw .core import Message , Long
2626from . import aes
@@ -60,8 +60,8 @@ def unpack(
6060 auth_key : bytes ,
6161 auth_key_id : bytes ,
6262 stored_msg_ids : List [int ]
63- ) -> Tuple [ Message , bool ] :
64- assert b .read (8 ) == auth_key_id , b . getvalue ()
63+ ) -> Message :
64+ assert b .read (8 ) == auth_key_id
6565
6666 msg_key = b .read (16 )
6767 aes_key , aes_iv = kdf (auth_key , msg_key , False )
@@ -105,22 +105,22 @@ def unpack(
105105 if stored_msg_ids :
106106 # Ignored message: msg_id is lower than all of the stored values
107107 if message .msg_id < stored_msg_ids [0 ]:
108- return message , False
108+ assert False
109109
110110 # Ignored message: msg_id is equal to any of the stored values
111111 if message .msg_id in stored_msg_ids :
112- return message , False
112+ assert False
113113
114114 time_diff = (message .msg_id - MsgId ()) / 2 ** 32
115115
116116 # Ignored message: msg_id belongs over 30 seconds in the future
117117 if time_diff > 30 :
118- return message , False
118+ assert False
119119
120120 # Ignored message: msg_id belongs over 300 seconds in the past
121121 if time_diff < - 300 :
122- return message , False
122+ assert False
123123
124124 bisect .insort (stored_msg_ids , message .msg_id )
125125
126- return message , True
126+ return message
Original file line number Diff line number Diff line change @@ -221,7 +221,7 @@ async def restart(self):
221221
222222 async def handle_packet (self , packet ):
223223 try :
224- data , ok = await self .loop .run_in_executor (
224+ data = await self .loop .run_in_executor (
225225 pyrogram .crypto_executor ,
226226 mtproto .unpack ,
227227 BytesIO (packet ),
@@ -234,10 +234,6 @@ async def handle_packet(self, packet):
234234 self .connection .close ()
235235 return
236236
237- if not ok :
238- self .connection .close ()
239- return
240-
241237 messages = (
242238 data .body .messages
243239 if isinstance (data .body , MsgContainer )
You can’t perform that action at this time.
0 commit comments