telegram.helpers Module#
This module contains convenience helper functions.
Changed in version 20.0: Previously, the contents of this module were available through the (no longer existing)
module telegram.utils.helpers.
- telegram.helpers.create_deep_linked_url(bot_username, payload=None, group=False)[source]#
Creates a deep-linked URL for this
bot_usernamewith the specifiedpayload. See https://core.telegram.org/bots#deep-linking to learn more.The
payloadmay consist of the following characters:A-Z, a-z, 0-9, _, -Note
Works well in conjunction with
CommandHandler("start", callback, filters=filters.Regex('payload'))Examples
create_deep_linked_url(bot.get_me().username, "some-params")- Parameters
- Returns
An URL to start the bot with specific parameters
- Return type
- telegram.helpers.effective_message_type(entity)[source]#
Extracts the type of message as a string identifier from a
telegram.Messageor atelegram.Update.- Parameters
entity (
telegram.Update|telegram.Message) – Theupdateormessageto extract from.- Returns
- One of
telegram.constants.MessageTypeif the entity contains a message that matches one of those types.
Noneotherwise.
- One of
- Return type
- telegram.helpers.escape_markdown(text, version=1, entity_type=None)[source]#
Helper function to escape telegram markup symbols.
- Parameters
version (
int|str) – Use to specify the version of telegrams Markdown. Either1or2. Defaults to1.entity_type (
str, optional) – For the entity types'pre','code'and the link part of'text_link', only certain characters need to be escaped in'MarkdownV2'. See the official API documentation for details. Only valid in combination withversion=2, will be ignored else.