bot.utils Module#
Utility methods for the bot functionality.
- bot.utils.FALLBACK_HANDLER = TypeHandler[callback=conversation_fallback]
A handler that can be used in the fallbacks for conversations.
- Type:
- bot.utils.TIMEOUT_HANDLER = TypeHandler[callback=conversation_timeout]
A handler that can be used in the timeout state for conversations.
- Type:
- async bot.utils.conversation_fallback(update, context)
Informs the user that the input was invalid, calls
remove_reply_markup()
and ends the conversation.
- async bot.utils.conversation_timeout(update, context)
Informs the user that the operation has timed out, calls
remove_reply_markup()
and ends the conversation.- Parameters:
update (
Update
) – The Telegram update.context (
CallbackContext
[ExtBot
,UserData
,dict
,dict
]) – The callback context as provided by the application.
- Returns:
- Return type:
- async bot.utils.default_message(update, _)
Answers any message with a note that it could not be parsed.
- async bot.utils.get_sticker_photo_stream(text, user, context, event=None)
Gives the sticker ID for the requested sticker.
- Parameters:
text (
str
) – The text to display on the tweet.user (
User
) – The user the tweet is created for.context (
CallbackContext
[ExtBot
,UserData
,dict
,dict
]) – The callback context as provided by the application.event (
Event
) – Optional. If passed,event.is_set()
will be checked before the time consuming parts of the sticker creation and if the event is set, the creation will be terminated.
- Returns:
The stickers unique file ID and file ID
- Return type:
- async bot.utils.remove_reply_markup(context)
Removes the reply markup of the message stored in
context.chat_data[REMOVE_KEYBOARD]
, if any.- Parameters:
context (
CallbackContext
[ExtBot
,UserData
,dict
,dict
]) – The callback context as provided by the application.- Return type: