telegram.ext.ExtBot

class telegram.ext.ExtBot(*args, **kwargs)[source]

Bases: telegram.Bot, typing.Generic

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.

All API methods of this class have an additional keyword argument rate_limit_args. This can be used to pass additional information to the rate limiter, specifically to telegram.ext.BaseRateLimiter.process_request.rate_limit_args.

Warning

  • The keyword argument rate_limit_args can not be used, if rate_limiter is None.

  • The method get_updates() is the only method that does not have the additional argument, as this method will never be rate limited.

New in version 13.6.

Parameters
arbitrary_callback_data[source]

Whether this bot instance allows to use arbitrary objects as callback data for telegram.InlineKeyboardButton.

Type

bool | int

callback_data_cache[source]

The cache for objects passed as callback data for telegram.InlineKeyboardButton.

Type

telegram.ext.CallbackDataCache

property defaults[source]

The telegram.ext.Defaults used by this bot, if any.

async initialize()[source]

See telegram.Bot.initialize(). Also initializes the ExtBot.rate_limiter (if set) by calling telegram.ext.BaseRateLimiter.initialize().

insert_callback_data(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 and telegram.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 is None for those! In the corresponding reply markups, the callback data will be replaced by telegram.ext.InvalidCallbackData.

Warning

In place, i.e. the passed telegram.Message will be changed!

Parameters

update (telegram.Update) – The update.

property rate_limiter[source]

The telegram.ext.BaseRateLimiter used by this bot, if any.

New in version 20.0.

async shutdown()[source]

See telegram.Bot.shutdown(). Also shuts down the ExtBot.rate_limiter (if set) by calling telegram.ext.BaseRateLimiter.shutdown().