2018-08-08 13:04:20 +03:00
|
|
|
import logging
|
2017-09-27 22:01:20 +03:00
|
|
|
|
2018-06-09 14:11:49 +03:00
|
|
|
from .. import TLObject
|
2017-09-27 22:01:20 +03:00
|
|
|
|
2018-08-08 13:04:20 +03:00
|
|
|
__log__ = logging.getLogger(__name__)
|
|
|
|
|
2017-09-27 22:01:20 +03:00
|
|
|
|
2017-09-28 12:59:24 +03:00
|
|
|
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
|
2018-09-29 11:58:45 +03:00
|
|
|
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
|
|
|
"""
|
2018-10-05 13:26:59 +03:00
|
|
|
SIZE_OVERHEAD = 12
|
|
|
|
|
2018-09-29 11:58:45 +03:00
|
|
|
def __init__(self, msg_id, seq_no, obj):
|
|
|
|
self.msg_id = msg_id
|
|
|
|
self.seq_no = seq_no
|
2018-06-09 14:48:27 +03:00
|
|
|
self.obj = obj
|
2018-07-07 12:46:21 +03:00
|
|
|
|
2018-06-21 10:52:47 +03:00
|
|
|
def to_dict(self):
|
2017-10-29 22:13:00 +03:00
|
|
|
return {
|
2018-06-21 10:52:47 +03:00
|
|
|
'_': 'TLMessage',
|
2017-10-29 22:13:00 +03:00
|
|
|
'msg_id': self.msg_id,
|
|
|
|
'seq_no': self.seq_no,
|
2018-09-29 11:58:45 +03:00
|
|
|
'obj': self.obj
|
2017-10-29 22:13:00 +03:00
|
|
|
}
|