Telethon/telethon/tl/core/tlmessage.py

39 lines
1.1 KiB
Python
Raw Normal View History

import logging
from .. import TLObject
__log__ = logging.getLogger(__name__)
class TLMessage(TLObject):
2018-06-07 11:30:20 +03:00
"""
https://core.telegram.org/mtproto/service_messages#simple-container.
Messages are what's ultimately sent to Telegram:
message msg_id:long seqno:int bytes:int body:bytes = Message;
Each message has its own unique identifier, and the body is simply
the serialized request that should be executed on the server, or
the response object from Telegram. Since the body is always a valid
object, it makes sense to store the object and not the bytes to
ease working with them.
There is no need to add serializing logic here since that can be
inlined and is unlikely to change. Thus these are only needed to
encapsulate responses.
2018-06-07 11:30:20 +03:00
"""
SIZE_OVERHEAD = 12
def __init__(self, msg_id, seq_no, obj):
self.msg_id = msg_id
self.seq_no = seq_no
self.obj = obj
2018-06-21 10:52:47 +03:00
def to_dict(self):
return {
2018-06-21 10:52:47 +03:00
'_': 'TLMessage',
'msg_id': self.msg_id,
'seq_no': self.seq_no,
'obj': self.obj
}