mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-22 09:26:37 +03:00
Avoid packing more than 1024 messages in a single container
This commit is contained in:
parent
f90dd76f4c
commit
207d5ebdcb
|
@ -53,8 +53,9 @@ class MessagePacker:
|
|||
batch = []
|
||||
size = 0
|
||||
|
||||
# Fill a new batch to return while the size is small enough
|
||||
while self._deque:
|
||||
# Fill a new batch to return while the size is small enough,
|
||||
# as long as we don't exceed the maximum length of messages.
|
||||
while self._deque and len(batch) <= MessageContainer.MAXIMUM_LENGTH:
|
||||
state = self._deque.popleft()
|
||||
size += len(state.data) + TLMessage.SIZE_OVERHEAD
|
||||
|
||||
|
|
|
@ -15,6 +15,11 @@ class MessageContainer(TLObject):
|
|||
# The overhead of the container itself is subtracted.
|
||||
MAXIMUM_SIZE = 1044456 - 8
|
||||
|
||||
# Maximum amount of messages that can't be sent inside a single
|
||||
# container, inclusive. Beyond this limit Telegram will respond
|
||||
# with BAD_MESSAGE 64 (invalid container).
|
||||
MAXIMUM_LENGTH = 1024
|
||||
|
||||
def __init__(self, messages):
|
||||
self.messages = messages
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user