Resets the state
Updates the message ID to a new one, used when the time offset changed.
Calculate the key based on Telegram guidelines, specifying whether it's the client or not
Writes a message containing the given data into buffer. Returns the message id.
Encrypts the given message data using the current authorization key following MTProto 2.0 guidelines core.telegram.org/mtproto/description.
Inverse of encrypt_message_data
for incoming server messages.
Updates the time offset to the correct one given a known valid message ID.
Generated using TypeDoc
telethon.network.mtprotosender.MTProtoSender
needs to hold a state in order to be able to encrypt and decrypt incoming/outgoing messages, as well as generating the message IDs. Instances of this class hold together all the required information.It doesn't make sense to use
telethon.sessions.abstract.Session
for the sender because the sender should not be concerned about storing this information to disk, as one may create as many senders as they desire to any other data center, or some CDN. Using the same session for all these is not a good idea as each need their own authkey, and the concept of "copying" sessions with the unnecessary entities or updates state for these connections doesn't make sense.While it would be possible to have a
MTProtoPlainState
that does no encryption so that it was usable through theMTProtoLayer
and thus avoid the need for aMTProtoPlainSender
, theMTProtoLayer
is more focused to efficiency and this state is also more advanced (since it supports gzipping and invoking after other message IDs). There are too many methods that would be needed to make it convenient to use for the authentication process, at which point theMTProtoPlainSender
is better