Expand description
A storage of state per message.
The Messages
storage can be used to store state for each message
separately. For example, when a chatting bot broadcasts a message from
Alice to Bob, it can store the ID of the broadcasted message in state
for the original message’s ID, and if Alice edits her message, the bot
can edit the corresponding message on Bob’s side.
Messages
has a similar API to the API of Chats
— all of the methods
from the latter are adapted for the former, except that the key is a special
structure MessageId
, which contains a message’s and its chat’s IDs.
In addition, for each method working with all records, Messages
provides
additional methods with the in_chat[_by_id]
postfix that work only with
messages with the specified chat ID. For example, len
returns the amount
of all records, while len_in_chat
returns the amount of records with
the specified chat (which is inferred from the context in the case of this
method; len_in_chat_by_id
, on the other hand, takes a chat ID directly).