telegram.utils.helpers Module¶
This module contains helper functions.
-
telegram.utils.helpers.decode_conversations_from_json(json_string)¶ Helper method to decode a conversations dict (that uses tuples as keys) from a JSON-string created with
_encode_conversations_to_json.Parameters: json_string ( str) – The conversations dict as JSON string.Returns: The conversations dict after decoding Return type: dict
-
telegram.utils.helpers.decode_user_chat_data_from_json(data)¶ Helper method to decode chat or user data (that uses ints as keys) from a JSON-string.
Parameters: data ( str) – The user/chat_data dict as JSON string.Returns: The user/chat_data defaultdict after decoding Return type: dict
-
telegram.utils.helpers.effective_message_type(entity)¶ Extracts the type of message as a string identifier from a
telegram.Messageor atelegram.Update.Parameters: entity ( Update|Message) –Returns: One of Message.MESSAGE_TYPESReturn type: str
-
telegram.utils.helpers.enocde_conversations_to_json(conversations)¶ Helper method to encode a conversations dict (that uses tuples as keys) to a JSON-serializable way. Use
_decode_conversations_from_jsonto decode.Parameters: conversations ( dict) – The conversations dict to transofrm to JSON.Returns: The JSON-serialized conversations dict Return type: str
-
telegram.utils.helpers.escape_markdown(text)¶ Helper function to escape telegram markup symbols.
-
telegram.utils.helpers.from_timestamp(unixtime)¶ Parameters: unixtime (int) – Returns: Return type: datetime.datetime
-
telegram.utils.helpers.get_signal_name(signum)¶ Returns the signal name of the given signal number.
-
telegram.utils.helpers.mention_html(user_id, name)¶ Parameters: - user_id (
int) – - name (
str) –
Returns: The inline mention for the user as html.
Return type: str- user_id (
-
telegram.utils.helpers.mention_markdown(user_id, name)¶ Parameters: - user_id (
int) – - name (
str) –
Returns: The inline mention for the user as markdown.
Return type: str- user_id (
-
telegram.utils.helpers.to_timestamp(dt_obj)¶ Parameters: dt_obj ( datetime.datetime) –Returns: Return type: int