telegram.error Module

This module contains classes that represent Telegram errors.

Changed in version 20.0: Replaced Unauthorized by Forbidden.

exception telegram.error.BadRequest(message)[source]

Bases: telegram.error.NetworkError

Raised when Telegram could not process the request correctly.

exception telegram.error.ChatMigrated(new_chat_id)[source]

Bases: telegram.error.TelegramError

Raised when the requested group chat migrated to supergroup and has a new chat id.

Parameters

new_chat_id (int) – The new chat id of the group.

new_chat_id[source]

The new chat id of the group.

Type

int

exception telegram.error.Conflict(message)[source]

Bases: telegram.error.TelegramError

Raised when a long poll or webhook conflicts with another one.

exception telegram.error.Forbidden(message)[source]

Bases: telegram.error.TelegramError

Raised when the bot has not enough rights to perform the requested action.

Changed in version 20.0: This class was previously named Unauthorized.

exception telegram.error.InvalidToken(message=None)[source]

Bases: telegram.error.TelegramError

Raised when the token is invalid.

Parameters

message (str, optional) –

Any additional information about the exception.

New in version 20.0.

exception telegram.error.NetworkError(message)[source]

Bases: telegram.error.TelegramError

Base class for exceptions due to networking errors.

exception telegram.error.PassportDecryptionError(message)[source]

Bases: telegram.error.TelegramError

Something went wrong with decryption.

Changed in version 20.0: This class was previously named TelegramDecryptionError and was available via telegram.TelegramDecryptionError.

exception telegram.error.RetryAfter(retry_after)[source]

Bases: telegram.error.TelegramError

Raised when flood limits where exceeded.

Changed in version 20.0: retry_after is now an integer to comply with the Bot API.

Parameters

retry_after (int) – Time in seconds, after which the bot can retry the request.

retry_after[source]

Time in seconds, after which the bot can retry the request.

Type

int

exception telegram.error.TelegramError(message)[source]

Bases: Exception

Base class for Telegram errors.

exception telegram.error.TimedOut(message=None)[source]

Bases: telegram.error.NetworkError

Raised when a request took too long to finish.

Parameters

message (str, optional) –

Any additional information about the exception.

New in version 20.0.