Coder Interface
- class telegram_bot_discussion.button.coder_interface.CoderInterface[source]
Bases:
ABCCoderInterface is an interface for class that serializes Button-Params values for storing them in a Button, and deserializes data from a callback query into a special Button-Params structure.
In the box Telegram-Bot-Discussion contains two realizations of CoderInterface:
store callback query data within Button as callback action Params (limited by the native Telegram protocol data length (64 bytes) and variable types — int, string, because there is no need for more in most tasks).
store unique identity of callback action Params, which are loaded when the user clicks the Button (no limits of callback data length and variables types, but external storage must work independently).
You can write your own Coder-class based on Pickle, ProtoBuf, FlatBuffers and etc. I stopped on the byte-separated values format as it is more visual and clear.
- check_signature(chat_id, signed_serialized_data, sender_id=None)[source]
- Return type:
bool- Parameters:
chat_id (int)
signed_serialized_data (str)
sender_id (int | None)
- abstractmethod extract_signature_and_deserialized_data(signed_serialized_data)[source]
- Return type:
Tuple[str,List[Any]]- Parameters:
signed_serialized_data (str)
- abstractmethod extract_signature_and_serialized_data(signed_serialized_data)[source]
- Return type:
Tuple[str,str]- Parameters:
signed_serialized_data (str)
- abstractmethod get_signature(chat_id, serialized_data, sender_id)[source]
- Return type:
str- Parameters:
chat_id (int)
serialized_data (str)
sender_id (int)
- abstractmethod sign(signature, serialized_data)[source]
- Return type:
str- Parameters:
signature (str)
serialized_data (str)
- fetch_deserialized_data(signed_serialized_data)[source]
- Return type:
List[Any]- Parameters:
signed_serialized_data (str)
- fetch_serialized_data(signed_serialized_data)[source]
- Return type:
str- Parameters:
signed_serialized_data (str)