mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-29 13:27:47 +00:00
Fix BadMsgNotification error_code 32
This commit is contained in:
parent
3bd3d99e6a
commit
d89d238d30
@ -51,12 +51,12 @@ class Auth:
|
|||||||
self.test_mode = test_mode
|
self.test_mode = test_mode
|
||||||
|
|
||||||
self.connection = Connection(DataCenter(dc_id, test_mode), proxy)
|
self.connection = Connection(DataCenter(dc_id, test_mode), proxy)
|
||||||
self.msg_id = MsgId()
|
|
||||||
|
|
||||||
def pack(self, data: Object) -> bytes:
|
@staticmethod
|
||||||
|
def pack(data: Object) -> bytes:
|
||||||
return (
|
return (
|
||||||
bytes(8)
|
bytes(8)
|
||||||
+ Long(self.msg_id())
|
+ Long(MsgId())
|
||||||
+ Int(len(data.write()))
|
+ Int(len(data.write()))
|
||||||
+ data.write()
|
+ data.write()
|
||||||
)
|
)
|
||||||
|
@ -26,14 +26,13 @@ not_content_related = [Ping, HttpWait, MsgsAck, MsgContainer]
|
|||||||
|
|
||||||
|
|
||||||
class MsgFactory:
|
class MsgFactory:
|
||||||
def __init__(self, msg_id: MsgId):
|
def __init__(self):
|
||||||
self.msg_id = msg_id
|
|
||||||
self.seq_no = SeqNo()
|
self.seq_no = SeqNo()
|
||||||
|
|
||||||
def __call__(self, body: Object) -> Message:
|
def __call__(self, body: Object) -> Message:
|
||||||
return Message(
|
return Message(
|
||||||
body,
|
body,
|
||||||
self.msg_id(),
|
MsgId(),
|
||||||
self.seq_no(type(body) not in not_content_related),
|
self.seq_no(type(body) not in not_content_related),
|
||||||
len(body)
|
len(body)
|
||||||
)
|
)
|
||||||
|
@ -21,17 +21,15 @@ from time import time
|
|||||||
|
|
||||||
|
|
||||||
class MsgId:
|
class MsgId:
|
||||||
def __init__(self, delta_time: float = 0.0):
|
last_time = 0
|
||||||
self.delta_time = delta_time
|
offset = 0
|
||||||
self.last_time = 0
|
lock = Lock()
|
||||||
self.offset = 0
|
|
||||||
self.lock = Lock()
|
|
||||||
|
|
||||||
def __call__(self) -> int:
|
def __new__(cls) -> int:
|
||||||
with self.lock:
|
with cls.lock:
|
||||||
now = time()
|
now = time()
|
||||||
self.offset = self.offset + 4 if now == self.last_time else 0
|
cls.offset = cls.offset + 4 if now == cls.last_time else 0
|
||||||
msg_id = int((now + self.delta_time) * 2 ** 32) + self.offset
|
msg_id = int(now * 2 ** 32) + cls.offset
|
||||||
self.last_time = now
|
cls.last_time = now
|
||||||
|
|
||||||
return msg_id
|
return msg_id
|
||||||
|
@ -89,9 +89,8 @@ class Session:
|
|||||||
self.auth_key = auth_key
|
self.auth_key = auth_key
|
||||||
self.auth_key_id = sha1(auth_key).digest()[-8:]
|
self.auth_key_id = sha1(auth_key).digest()[-8:]
|
||||||
|
|
||||||
self.msg_id = MsgId()
|
self.session_id = Long(MsgId())
|
||||||
self.session_id = Long(self.msg_id())
|
self.msg_factory = MsgFactory()
|
||||||
self.msg_factory = MsgFactory(self.msg_id)
|
|
||||||
|
|
||||||
self.current_salt = None
|
self.current_salt = None
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user