telegram.ext.ExtBot¶
- class telegram.ext.ExtBot(*args, **kwargs)[source]¶
Bases:
telegram.Bot
This object represents a Telegram Bot with convenience extensions.
Warning
Not to be confused with
telegram.Bot
.For the documentation of the arguments, methods and attributes, please see
telegram.Bot
.New in version 13.6.
- Parameters
defaults (
telegram.ext.Defaults
, optional) – An object containing default values to be used if not set explicitly in the bot methods.arbitrary_callback_data (
bool
|int
, optional) – Whether to allow arbitrary objects as callback data fortelegram.InlineKeyboardButton
. Pass an integer to specify the maximum number of objects cached in memory. For more details, please see our wiki. Defaults toFalse
.
- arbitrary_callback_data[source]¶
Whether this bot instance allows to use arbitrary objects as callback data for
telegram.InlineKeyboardButton
.
- callback_data_cache[source]¶
The cache for objects passed as callback data for
telegram.InlineKeyboardButton
.
- insert_callback_data(self, update)[source]¶
If this bot allows for arbitrary callback data, this inserts the cached data into all corresponding buttons within this update.
Note
Checks
telegram.Message.via_bot
andtelegram.Message.from_user
to figure out if a) a reply markup exists and b) it was actually sent by this bot. If not, the message will be returned unchanged.Note that this will fail for channel posts, as
telegram.Message.from_user
isNone
for those! In the corresponding reply markups, the callback data will be replaced bytelegram.ext.InvalidCallbackData
.Warning
In place, i.e. the passed
telegram.Message
will be changed!- Parameters
update (
telegram.Update
) – The update.