telegram.constants Module

This module contains several constants that are relevant for working with the Bot API.

Unless noted otherwise, all constants in this module were extracted from the Telegram Bots FAQ and Telegram Bots API.

Most of the following constants are related to specific classes or topics and are grouped into enums. If they are related to a specific class, then they are also available as attributes of those classes.

Changed in version 20.0:

  • Most of the constants in this module are grouped into enums.

class telegram.constants.AccentColor(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

This enum contains the available accent colors for telegram.Chat.accent_color_id. The members of this enum are named tuples with the following attributes:

  • identifier (int): The identifier of the accent color.

  • name (str): Optional. The name of the accent color.

  • light_colors (Tuple[str]): Optional. The light colors of the accent color as HEX value.

  • dark_colors (Tuple[str]): Optional. The dark colors of the accent color as HEX value.

Since Telegram gives no exact specification for the accent colors, future accent colors might have a different data type.

New in version 20.8.

COLOR_000 = (0, 'red', (), ())[source]

Accent color 0. This color can be customized by app themes.

COLOR_001 = (1, 'orange', (), ())[source]

Accent color 1. This color can be customized by app themes.

COLOR_002 = (2, 'purple/violet', (), ())[source]

Accent color 2. This color can be customized by app themes.

COLOR_003 = (3, 'green', (), ())[source]

Accent color 3. This color can be customized by app themes.

COLOR_004 = (4, 'cyan', (), ())[source]

Accent color 4. This color can be customized by app themes.

COLOR_005 = (5, 'blue', (), ())[source]

Accent color 5. This color can be customized by app themes.

COLOR_006 = (6, 'pink', (), ())[source]

Accent color 6. This color can be customized by app themes.

COLOR_007 = (7, None, (14766162, 16363107), (16749440, 10039095))[source]

Accent color 7. This contains two light colors


and two dark colors


COLOR_008 = (8, None, (14712875, 16434484), (15511630, 12801812))[source]

Accent color 8. This contains two light colors


and two dark colors


COLOR_009 = (9, None, (10510323, 16027647), (13015039, 6173128))[source]

Accent color 9. This contains two light colors


and two dark colors


COLOR_010 = (10, None, (2599184, 11000919), (11004782, 1474093))[source]

Accent color 10. This contains two light colors


and two dark colors


COLOR_011 = (11, None, (2600142, 8579286), (4249808, 285823))[source]

Accent color 11. This contains two light colors


and two dark colors


COLOR_012 = (12, None, (3379668, 8246256), (5423103, 742548))[source]

Accent color 12. This contains two light colors


and two dark colors


COLOR_013 = (13, None, (14500721, 16760479), (16746150, 9320046))[source]

Accent color 13. This contains two light colors


and two dark colors


COLOR_014 = (14, None, (2391021, 15747158, 16777215), (4170494, 15024719, 16777215))[source]

Accent color 14. This contains three light colors


and three dark colors


COLOR_015 = (15, None, (14055202, 2007057, 16777215), (16748638, 3319079, 16777215))[source]

Accent color 15. This contains three light colors


and three dark colors


COLOR_016 = (16, None, (1547842, 15223359, 16777215), (6738788, 13976655, 16777215))[source]

Accent color 16. This contains three light colors


and three dark colors


COLOR_017 = (17, None, (2659503, 7324758, 16777215), (2276578, 4039232, 16777215))[source]

Accent color 17. This contains three light colors


and three dark colors


COLOR_018 = (18, None, (826035, 16756117, 16770741), (2276578, 16750456, 16767595))[source]

Accent color 18. This contains three light colors


and three dark colors


COLOR_019 = (19, None, (7821270, 16225808, 16768654), (9933311, 15889181, 16767833))[source]

Accent color 19. This contains three light colors


and three dark colors


COLOR_020 = (20, None, (1410511, 15903517, 16777215), (4040427, 15639837, 16777215))[source]

Accent color 20. This contains three light colors


and three dark colors


telegram.constants.BOT_API_VERSION = '7.0'[source]

Telegram Bot API version supported by this version of python-telegram-bot. Also available as telegram.__bot_api_version__.

New in version 13.4.

Type:

str

telegram.constants.BOT_API_VERSION_INFO = (7, 0)[source]

The components can also be accessed by name, so BOT_API_VERSION_INFO[0] is equivalent to BOT_API_VERSION_INFO.major and so on. Also available as telegram.__bot_api_version_info__.

New in version 20.0.

class telegram.constants.BotCommandLimit(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: enum.IntEnum

This enum contains limitations for telegram.BotCommand and telegram.Bot.set_my_commands(). The enum members of this enumeration are instances of int and can be treated as such.

New in version 20.0.

MAX_COMMAND = 32[source]

Maximum value allowed for command parameter of telegram.BotCommand.

Type:

int

MAX_COMMAND_NUMBER = 100[source]

Maximum number of bot commands passed in a list to the commands parameter of telegram.Bot.set_my_commands().

Type:

int

MAX_DESCRIPTION = 256[source]

Maximum value allowed for description parameter of telegram.BotCommand.

Type:

int

MIN_COMMAND = 1[source]

Minimum value allowed for command parameter of telegram.BotCommand.

Type:

int

MIN_DESCRIPTION = 1[source]

Minimum value allowed for description parameter of telegram.BotCommand.

Type:

int

__abs__()[source]

abs(self)

__add__(value, /)[source]

Return self+value.

__and__(value, /)[source]

Return self&value.

__bool__()[source]

True if self else False

__ceil__()[source]

Ceiling of an Integral returns itself.

__divmod__(value, /)[source]

Return divmod(self, value).

__eq__(value, /)[source]

Return self==value.

__float__()[source]

float(self)

__floor__()[source]

Flooring an Integral returns itself.

__floordiv__(value, /)[source]

Return self//value.

__format__(format_spec, /)[source]

Convert to a string according to format_spec.

__ge__(value, /)[source]

Return self>=value.

__getattribute__(name, /)[source]

Return getattr(self, name).

__gt__(value, /)[source]

Return self>value.

__hash__()[source]

Return hash(self).

__index__()[source]

Return self converted to an integer, if self is suitable for use as an index into a list.

__int__()[source]

int(self)

__invert__()[source]

~self

__le__(value, /)[source]

Return self<=value.

__lshift__(value, /)[source]

Return self<<value.

__lt__(value, /)[source]

Return self<value.

__mod__(value, /)[source]

Return self%value.

__mul__(value, /)[source]

Return self*value.

__ne__(value, /)[source]

Return self!=value.

__neg__()[source]

-self

__new__(value)[source]
__or__(value, /)[source]

Return self|value.

__pos__()[source]

+self

__pow__(value, mod=None, /)[source]

Return pow(self, value, mod).

__radd__(value, /)[source]

Return value+self.

__rand__(value, /)[source]

Return value&self.

__rdivmod__(value, /)[source]

Return divmod(value, self).

__repr__()[source]

Return repr(self).

__rfloordiv__(value, /)[source]

Return value//self.

__rlshift__(value, /)[source]

Return value<<self.

__rmod__(value, /)[source]

Return value%self.

__rmul__(value, /)[source]

Return value*self.

__ror__(value, /)[source]

Return value|self.

__round__()[source]

Rounding an Integral returns itself.

Rounding with an ndigits argument also returns an integer.

__rpow__(value, mod=None, /)[source]

Return pow(value, self, mod).

__rrshift__(value, /)[source]

Return value>>self.

__rshift__(value, /)[source]

Return self>>value.

__rsub__(value, /)[source]

Return value-self.

__rtruediv__(value, /)[source]

Return value/self.

__rxor__(value, /)[source]

Return value^self.

__sizeof__()[source]

Returns size in memory, in bytes.

__str__()[source]

Return repr(self).

__sub__(value, /)[source]

Return self-value.

__truediv__(value, /)[source]

Return self/value.

__trunc__()[source]

Truncating an Integral returns itself.

__xor__(value, /)[source]

Return self^value.

as_integer_ratio()[source]

Return a pair of integers, whose ratio is equal to the original int.

The ratio is in lowest terms and has a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
bit_count()[source]

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
bit_length()[source]

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
conjugate()[source]

Returns self, the complex conjugate of any int.

denominator[source]

the denominator of a rational number in lowest terms

from_bytes(byteorder='big', *, signed=False)[source]

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

imag[source]

the imaginary part of a complex number

is_integer()[source]

Returns True. Exists for duck type compatibility with float.is_integer.

numerator[source]

the numerator of a rational number in lowest terms

real[source]

the real part of a complex number

to_bytes(length=1, byteorder='big', *, signed=False)[source]

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

class telegram.constants.BotCommandScopeType(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: str, enum.Enum

This enum contains the available types of telegram.BotCommandScope. The enum members of this enumeration are instances of str and can be treated as such.

New in version 20.0.

ALL_CHAT_ADMINISTRATORS = 'all_chat_administrators'[source]

The type of telegram.BotCommandScopeAllChatAdministrators.

Type:

str

ALL_GROUP_CHATS = 'all_group_chats'[source]

The type of telegram.BotCommandScopeAllGroupChats.

Type:

str

ALL_PRIVATE_CHATS = 'all_private_chats'[source]

The type of telegram.BotCommandScopeAllPrivateChats.

Type:

str

CHAT = 'chat'[source]

The type of telegram.BotCommandScopeChat.

Type:

str

CHAT_ADMINISTRATORS = 'chat_administrators'[source]

The type of telegram.BotCommandScopeChatAdministrators.

Type:

str

CHAT_MEMBER = 'chat_member'[source]

The type of telegram.BotCommandScopeChatMember.

Type:

str

DEFAULT = 'default'[source]

The type of telegram.BotCommandScopeDefault.

Type:

str

__add__(value, /)[source]

Return self+value.

__contains__(key, /)[source]

Return bool(key in self).

__eq__(value, /)[source]

Return self==value.

__format__(format_spec)[source]

Return a formatted version of the string as described by format_spec.

__ge__(value, /)[source]

Return self>=value.

__getattribute__(name, /)[source]

Return getattr(self, name).

__getitem__(key, /)[source]

Return self[key].

__gt__(value, /)[source]

Return self>value.

__hash__()[source]

Return hash(self).

__iter__()[source]

Implement iter(self).

__le__(value, /)[source]

Return self<=value.

__len__()[source]

Return len(self).

__lt__(value, /)[source]

Return self<value.

__mod__(value, /)[source]

Return self%value.

__mul__(value, /)[source]

Return self*value.

__ne__(value, /)[source]

Return self!=value.

__new__(value)[source]
__repr__()[source]

Return repr(self).

__rmod__(value, /)[source]

Return value%self.

__rmul__(value, /)[source]

Return value*self.

__sizeof__()[source]

Return the size of the string in memory, in bytes.

__str__()[source]

Return str(self).

capitalize()[source]

Return a capitalized version of the string.

More specifically, make the first character have upper case and the rest lower case.

casefold()[source]

Return a version of the string suitable for caseless comparisons.

center(width, fillchar=' ', /)[source]

Return a centered string of length width.

Padding is done using the specified fill character (default is a space).

count(sub[, start[, end]]) int[source]

Return the number of non-overlapping occurrences of substring sub in string S[start:end]. Optional arguments start and end are interpreted as in slice notation.

encode(encoding='utf-8', errors='strict')[source]

Encode the string using the codec registered for encoding.

encoding

The encoding in which to encode the string.

errors

The error handling scheme to use for encoding errors. The default is ‘strict’ meaning that encoding errors raise a UnicodeEncodeError. Other possible values are ‘ignore’, ‘replace’ and ‘xmlcharrefreplace’ as well as any other name registered with codecs.register_error that can handle UnicodeEncodeErrors.

endswith(suffix[, start[, end]]) bool[source]

Return True if S ends with the specified suffix, False otherwise. With optional start, test S beginning at that position. With optional end, stop comparing S at that position. suffix can also be a tuple of strings to try.

expandtabs(tabsize=8)[source]

Return a copy where all tab characters are expanded using spaces.

If tabsize is not given, a tab size of 8 characters is assumed.

find(sub[, start[, end]]) int[source]

Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Return -1 on failure.

format(*args, **kwargs) str[source]

Return a formatted version of S, using substitutions from args and kwargs. The substitutions are identified by braces (‘{’ and ‘}’).

format_map(mapping) str[source]

Return a formatted version of S, using substitutions from mapping. The substitutions are identified by braces (‘{’ and ‘}’).

index(sub[, start[, end]]) int[source]

Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Raises ValueError when the substring is not found.

isalnum()[source]

Return True if the string is an alpha-numeric string, False otherwise.

A string is alpha-numeric if all characters in the string are alpha-numeric and there is at least one character in the string.

isalpha()[source]

Return True if the string is an alphabetic string, False otherwise.

A string is alphabetic if all characters in the string are alphabetic and there is at least one character in the string.

isascii()[source]

Return True if all characters in the string are ASCII, False otherwise.

ASCII characters have code points in the range U+0000-U+007F. Empty string is ASCII too.

isdecimal()[source]

Return True if the string is a decimal string, False otherwise.

A string is a decimal string if all characters in the string are decimal and there is at least one character in the string.

isdigit()[source]

Return True if the string is a digit string, False otherwise.

A string is a digit string if all characters in the string are digits and there is at least one character in the string.

isidentifier()[source]

Return True if the string is a valid Python identifier, False otherwise.

Call keyword.iskeyword(s) to test whether string s is a reserved identifier, such as “def” or “class”.

islower()[source]

Return True if the string is a lowercase string, False otherwise.

A string is lowercase if all cased characters in the string are lowercase and there is at least one cased character in the string.

isnumeric()[source]

Return True if the string is a numeric string, False otherwise.

A string is numeric if all characters in the string are numeric and there is at least one character in the string.

isprintable()[source]

Return True if the string is printable, False otherwise.

A string is printable if all of its characters are considered printable in repr() or if it is empty.

isspace()[source]

Return True if the string is a whitespace string, False otherwise.

A string is whitespace if all characters in the string are whitespace and there is at least one character in the string.

istitle()[source]

Return True if the string is a title-cased string, False otherwise.

In a title-cased string, upper- and title-case characters may only follow uncased characters and lowercase characters only cased ones.

isupper()[source]

Return True if the string is an uppercase string, False otherwise.

A string is uppercase if all cased characters in the string are uppercase and there is at least one cased character in the string.

join(iterable, /)[source]

Concatenate any number of strings.

The string whose method is called is inserted in between each given string. The result is returned as a new string.

Example: ‘.’.join([‘ab’, ‘pq’, ‘rs’]) -> ‘ab.pq.rs’

ljust(width, fillchar=' ', /)[source]

Return a left-justified string of length width.

Padding is done using the specified fill character (default is a space).

lower()[source]

Return a copy of the string converted to lowercase.

lstrip(chars=None, /)[source]

Return a copy of the string with leading whitespace removed.

If chars is given and not None, remove characters in chars instead.

static maketrans()[source]

Return a translation table usable for str.translate().

If there is only one argument, it must be a dictionary mapping Unicode ordinals (integers) or characters to Unicode ordinals, strings or None. Character keys will be then converted to ordinals. If there are two arguments, they must be strings of equal length, and in the resulting dictionary, each character in x will be mapped to the character at the same position in y. If there is a third argument, it must be a string, whose characters will be mapped to None in the result.

partition(sep, /)[source]

Partition the string into three parts using the given separator.

This will search for the separator in the string. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.

If the separator is not found, returns a 3-tuple containing the original string and two empty strings.

removeprefix(prefix, /)[source]

Return a str with the given prefix string removed if present.

If the string starts with the prefix string, return string[len(prefix):]. Otherwise, return a copy of the original string.

removesuffix(suffix, /)[source]

Return a str with the given suffix string removed if present.

If the string ends with the suffix string and that suffix is not empty, return string[:-len(suffix)]. Otherwise, return a copy of the original string.

replace(old, new, count=-1, /)[source]

Return a copy with all occurrences of substring old replaced by new.

count

Maximum number of occurrences to replace. -1 (the default value) means replace all occurrences.

If the optional argument count is given, only the first count occurrences are replaced.

rfind(sub[, start[, end]]) int[source]

Return the highest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Return -1 on failure.

rindex(sub[, start[, end]]) int[source]

Return the highest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Raises ValueError when the substring is not found.

rjust(width, fillchar=' ', /)[source]

Return a right-justified string of length width.

Padding is done using the specified fill character (default is a space).

rpartition(sep, /)[source]

Partition the string into three parts using the given separator.

This will search for the separator in the string, starting at the end. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.

If the separator is not found, returns a 3-tuple containing two empty strings and the original string.

rsplit(sep=None, maxsplit=-1)[source]

Return a list of the substrings in the string, using sep as the separator string.

sep

The separator used to split the string.

When set to None (the default value), will split on any whitespace character (including n r t f and spaces) and will discard empty strings from the result.

maxsplit

Maximum number of splits (starting from the left). -1 (the default value) means no limit.

Splitting starts at the end of the string and works to the front.

rstrip(chars=None, /)[source]

Return a copy of the string with trailing whitespace removed.

If chars is given and not None, remove characters in chars instead.

split(sep=None, maxsplit=-1)[source]

Return a list of the substrings in the string, using sep as the separator string.

sep

The separator used to split the string.

When set to None (the default value), will split on any whitespace character (including n r t f and spaces) and will discard empty strings from the result.

maxsplit

Maximum number of splits (starting from the left). -1 (the default value) means no limit.

Note, str.split() is mainly useful for data that has been intentionally delimited. With natural text that includes punctuation, consider using the regular expression module.

splitlines(keepends=False)[source]

Return a list of the lines in the string, breaking at line boundaries.

Line breaks are not included in the resulting list unless keepends is given and true.

startswith(prefix[, start[, end]]) bool[source]

Return True if S starts with the specified prefix, False otherwise. With optional start, test S beginning at that position. With optional end, stop comparing S at that position. prefix can also be a tuple of strings to try.

strip(chars=None, /)[source]

Return a copy of the string with leading and trailing whitespace removed.

If chars is given and not None, remove characters in chars instead.

swapcase()[source]

Convert uppercase characters to lowercase and lowercase characters to uppercase.

title()[source]

Return a version of the string where each word is titlecased.

More specifically, words start with uppercased characters and all remaining cased characters have lower case.

translate(table, /)[source]

Replace each character in the string using the given translation table.

table

Translation table, which must be a mapping of Unicode ordinals to Unicode ordinals, strings, or None.

The table must implement lookup/indexing via __getitem__, for instance a dictionary or list. If this operation raises LookupError, the character is left untouched. Characters mapped to None are deleted.

upper()[source]

Return a copy of the string converted to uppercase.

zfill(width, /)[source]

Pad a numeric string with zeros on the left, to fill a field of the given width.

The string is never truncated.

class telegram.constants.BotDescriptionLimit(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: enum.IntEnum

This enum contains limitations for the methods telegram.Bot.set_my_description() and telegram.Bot.set_my_short_description(). The enum members of this enumeration are instances of int and can be treated as such.

New in version 20.2.

MAX_DESCRIPTION_LENGTH = 512[source]

Maximum length for the parameter description of telegram.Bot.set_my_description()

Type:

int

MAX_SHORT_DESCRIPTION_LENGTH = 120[source]

Maximum length for the parameter short_description of telegram.Bot.set_my_short_description()

Type:

int

__abs__()[source]

abs(self)

__add__(value, /)[source]

Return self+value.

__and__(value, /)[source]

Return self&value.

__bool__()[source]

True if self else False

__ceil__()[source]

Ceiling of an Integral returns itself.

__divmod__(value, /)[source]

Return divmod(self, value).

__eq__(value, /)[source]

Return self==value.

__float__()[source]

float(self)

__floor__()[source]

Flooring an Integral returns itself.

__floordiv__(value, /)[source]

Return self//value.

__format__(format_spec, /)[source]

Convert to a string according to format_spec.

__ge__(value, /)[source]

Return self>=value.

__getattribute__(name, /)[source]

Return getattr(self, name).

__gt__(value, /)[source]

Return self>value.

__hash__()[source]

Return hash(self).

__index__()[source]

Return self converted to an integer, if self is suitable for use as an index into a list.

__int__()[source]

int(self)

__invert__()[source]

~self

__le__(value, /)[source]

Return self<=value.

__lshift__(value, /)[source]

Return self<<value.

__lt__(value, /)[source]

Return self<value.

__mod__(value, /)[source]

Return self%value.

__mul__(value, /)[source]

Return self*value.

__ne__(value, /)[source]

Return self!=value.

__neg__()[source]

-self

__new__(value)[source]
__or__(value, /)[source]

Return self|value.

__pos__()[source]

+self

__pow__(value, mod=None, /)[source]

Return pow(self, value, mod).

__radd__(value, /)[source]

Return value+self.

__rand__(value, /)[source]

Return value&self.

__rdivmod__(value, /)[source]

Return divmod(value, self).

__repr__()[source]

Return repr(self).

__rfloordiv__(value, /)[source]

Return value//self.

__rlshift__(value, /)[source]

Return value<<self.

__rmod__(value, /)[source]

Return value%self.

__rmul__(value, /)[source]

Return value*self.

__ror__(value, /)[source]

Return value|self.

__round__()[source]

Rounding an Integral returns itself.

Rounding with an ndigits argument also returns an integer.

__rpow__(value, mod=None, /)[source]

Return pow(value, self, mod).

__rrshift__(value, /)[source]

Return value>>self.

__rshift__(value, /)[source]

Return self>>value.

__rsub__(value, /)[source]

Return value-self.

__rtruediv__(value, /)[source]

Return value/self.

__rxor__(value, /)[source]

Return value^self.

__sizeof__()[source]

Returns size in memory, in bytes.

__str__()[source]

Return repr(self).

__sub__(value, /)[source]

Return self-value.

__truediv__(value, /)[source]

Return self/value.

__trunc__()[source]

Truncating an Integral returns itself.

__xor__(value, /)[source]

Return self^value.

as_integer_ratio()[source]

Return a pair of integers, whose ratio is equal to the original int.

The ratio is in lowest terms and has a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
bit_count()[source]

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
bit_length()[source]

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
conjugate()[source]

Returns self, the complex conjugate of any int.

denominator[source]

the denominator of a rational number in lowest terms

from_bytes(byteorder='big', *, signed=False)[source]

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

imag[source]

the imaginary part of a complex number

is_integer()[source]

Returns True. Exists for duck type compatibility with float.is_integer.

numerator[source]

the numerator of a rational number in lowest terms

real[source]

the real part of a complex number

to_bytes(length=1, byteorder='big', *, signed=False)[source]

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

class telegram.constants.BotNameLimit(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: enum.IntEnum

This enum contains limitations for the methods telegram.Bot.set_my_name(). The enum members of this enumeration are instances of int and can be treated as such.

New in version 20.3.

MAX_NAME_LENGTH = 64[source]

Maximum length for the parameter name of telegram.Bot.set_my_name()

Type:

int

__abs__()[source]

abs(self)

__add__(value, /)[source]

Return self+value.

__and__(value, /)[source]

Return self&value.

__bool__()[source]

True if self else False

__ceil__()[source]

Ceiling of an Integral returns itself.

__divmod__(value, /)[source]

Return divmod(self, value).

__eq__(value, /)[source]

Return self==value.

__float__()[source]

float(self)

__floor__()[source]

Flooring an Integral returns itself.

__floordiv__(value, /)[source]

Return self//value.

__format__(format_spec, /)[source]

Convert to a string according to format_spec.

__ge__(value, /)[source]

Return self>=value.

__getattribute__(name, /)[source]

Return getattr(self, name).

__gt__(value, /)[source]

Return self>value.

__hash__()[source]

Return hash(self).

__index__()[source]

Return self converted to an integer, if self is suitable for use as an index into a list.

__int__()[source]

int(self)

__invert__()[source]

~self

__le__(value, /)[source]

Return self<=value.

__lshift__(value, /)[source]

Return self<<value.

__lt__(value, /)[source]

Return self<value.

__mod__(value, /)[source]

Return self%value.

__mul__(value, /)[source]

Return self*value.

__ne__(value, /)[source]

Return self!=value.

__neg__()[source]

-self

__new__(value)[source]
__or__(value, /)[source]

Return self|value.

__pos__()[source]

+self

__pow__(value, mod=None, /)[source]

Return pow(self, value, mod).

__radd__(value, /)[source]

Return value+self.

__rand__(value, /)[source]

Return value&self.

__rdivmod__(value, /)[source]

Return divmod(value, self).

__repr__()[source]

Return repr(self).

__rfloordiv__(value, /)[source]

Return value//self.

__rlshift__(value, /)[source]

Return value<<self.

__rmod__(value, /)[source]

Return value%self.

__rmul__(value, /)[source]

Return value*self.

__ror__(value, /)[source]

Return value|self.

__round__()[source]

Rounding an Integral returns itself.

Rounding with an ndigits argument also returns an integer.

__rpow__(value, mod=None, /)[source]

Return pow(value, self, mod).

__rrshift__(value, /)[source]

Return value>>self.

__rshift__(value, /)[source]

Return self>>value.

__rsub__(value, /)[source]

Return value-self.

__rtruediv__(value, /)[source]

Return value/self.

__rxor__(value, /)[source]

Return value^self.

__sizeof__()[source]

Returns size in memory, in bytes.

__str__()[source]

Return repr(self).

__sub__(value, /)[source]

Return self-value.

__truediv__(value, /)[source]

Return self/value.

__trunc__()[source]

Truncating an Integral returns itself.

__xor__(value, /)[source]

Return self^value.

as_integer_ratio()[source]

Return a pair of integers, whose ratio is equal to the original int.

The ratio is in lowest terms and has a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
bit_count()[source]

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
bit_length()[source]

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
conjugate()[source]

Returns self, the complex conjugate of any int.

denominator[source]

the denominator of a rational number in lowest terms

from_bytes(byteorder='big', *, signed=False)[source]

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

imag[source]

the imaginary part of a complex number

is_integer()[source]

Returns True. Exists for duck type compatibility with float.is_integer.

numerator[source]

the numerator of a rational number in lowest terms

real[source]

the real part of a complex number

to_bytes(length=1, byteorder='big', *, signed=False)[source]

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

class telegram.constants.BulkRequestLimit(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: enum.IntEnum

This enum contains limitations for telegram.Bot.delete_messages(), telegram.Bot.forward_messages() and telegram.Bot.copy_messages(). The enum members of this enumeration are instances of int and can be treated as such.

New in version 20.8.

MAX_LIMIT = 100[source]

Maximum number of messages required for bulk actions.

Type:

int

MIN_LIMIT = 1[source]

Minimum number of messages required for bulk actions.

Type:

int

__abs__()[source]

abs(self)

__add__(value, /)[source]

Return self+value.

__and__(value, /)[source]

Return self&value.

__bool__()[source]

True if self else False

__ceil__()[source]

Ceiling of an Integral returns itself.

__divmod__(value, /)[source]

Return divmod(self, value).

__eq__(value, /)[source]

Return self==value.

__float__()[source]

float(self)

__floor__()[source]

Flooring an Integral returns itself.

__floordiv__(value, /)[source]

Return self//value.

__format__(format_spec, /)[source]

Convert to a string according to format_spec.

__ge__(value, /)[source]

Return self>=value.

__getattribute__(name, /)[source]

Return getattr(self, name).

__gt__(value, /)[source]

Return self>value.

__hash__()[source]

Return hash(self).

__index__()[source]

Return self converted to an integer, if self is suitable for use as an index into a list.

__int__()[source]

int(self)

__invert__()[source]

~self

__le__(value, /)[source]

Return self<=value.

__lshift__(value, /)[source]

Return self<<value.

__lt__(value, /)[source]

Return self<value.

__mod__(value, /)[source]

Return self%value.

__mul__(value, /)[source]

Return self*value.

__ne__(value, /)[source]

Return self!=value.

__neg__()[source]

-self

__new__(value)[source]
__or__(value, /)[source]

Return self|value.

__pos__()[source]

+self

__pow__(value, mod=None, /)[source]

Return pow(self, value, mod).

__radd__(value, /)[source]

Return value+self.

__rand__(value, /)[source]

Return value&self.

__rdivmod__(value, /)[source]

Return divmod(value, self).

__repr__()[source]

Return repr(self).

__rfloordiv__(value, /)[source]

Return value//self.

__rlshift__(value, /)[source]

Return value<<self.

__rmod__(value, /)[source]

Return value%self.

__rmul__(value, /)[source]

Return value*self.

__ror__(value, /)[source]

Return value|self.

__round__()[source]

Rounding an Integral returns itself.

Rounding with an ndigits argument also returns an integer.

__rpow__(value, mod=None, /)[source]

Return pow(value, self, mod).

__rrshift__(value, /)[source]

Return value>>self.

__rshift__(value, /)[source]

Return self>>value.

__rsub__(value, /)[source]

Return value-self.

__rtruediv__(value, /)[source]

Return value/self.

__rxor__(value, /)[source]

Return value^self.

__sizeof__()[source]

Returns size in memory, in bytes.

__str__()[source]

Return repr(self).

__sub__(value, /)[source]

Return self-value.

__truediv__(value, /)[source]

Return self/value.

__trunc__()[source]

Truncating an Integral returns itself.

__xor__(value, /)[source]

Return self^value.

as_integer_ratio()[source]

Return a pair of integers, whose ratio is equal to the original int.

The ratio is in lowest terms and has a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
bit_count()[source]

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
bit_length()[source]

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
conjugate()[source]

Returns self, the complex conjugate of any int.

denominator[source]

the denominator of a rational number in lowest terms

from_bytes(byteorder='big', *, signed=False)[source]

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

imag[source]

the imaginary part of a complex number

is_integer()[source]

Returns True. Exists for duck type compatibility with float.is_integer.

numerator[source]

the numerator of a rational number in lowest terms

real[source]

the real part of a complex number

to_bytes(length=1, byteorder='big', *, signed=False)[source]

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

class telegram.constants.CallbackQueryLimit(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: enum.IntEnum

This enum contains limitations for telegram.CallbackQuery/ telegram.Bot.answer_callback_query(). The enum members of this enumeration are instances of int and can be treated as such.

New in version 20.0.

ANSWER_CALLBACK_QUERY_TEXT_LENGTH = 200[source]

Maximum number of characters in a str passed as the text parameter of telegram.Bot.answer_callback_query().

Type:

int

__abs__()[source]

abs(self)

__add__(value, /)[source]

Return self+value.

__and__(value, /)[source]

Return self&value.

__bool__()[source]

True if self else False

__ceil__()[source]

Ceiling of an Integral returns itself.

__divmod__(value, /)[source]

Return divmod(self, value).

__eq__(value, /)[source]

Return self==value.

__float__()[source]

float(self)

__floor__()[source]

Flooring an Integral returns itself.

__floordiv__(value, /)[source]

Return self//value.

__format__(format_spec, /)[source]

Convert to a string according to format_spec.

__ge__(value, /)[source]

Return self>=value.

__getattribute__(name, /)[source]

Return getattr(self, name).

__gt__(value, /)[source]

Return self>value.

__hash__()[source]

Return hash(self).

__index__()[source]

Return self converted to an integer, if self is suitable for use as an index into a list.

__int__()[source]

int(self)

__invert__()[source]

~self

__le__(value, /)[source]

Return self<=value.

__lshift__(value, /)[source]

Return self<<value.

__lt__(value, /)[source]

Return self<value.

__mod__(value, /)[source]

Return self%value.

__mul__(value, /)[source]

Return self*value.

__ne__(value, /)[source]

Return self!=value.

__neg__()[source]

-self

__new__(value)[source]
__or__(value, /)[source]

Return self|value.

__pos__()[source]

+self

__pow__(value, mod=None, /)[source]

Return pow(self, value, mod).

__radd__(value, /)[source]

Return value+self.

__rand__(value, /)[source]

Return value&self.

__rdivmod__(value, /)[source]

Return divmod(value, self).

__repr__()[source]

Return repr(self).

__rfloordiv__(value, /)[source]

Return value//self.

__rlshift__(value, /)[source]

Return value<<self.

__rmod__(value, /)[source]

Return value%self.

__rmul__(value, /)[source]

Return value*self.

__ror__(value, /)[source]

Return value|self.

__round__()[source]

Rounding an Integral returns itself.

Rounding with an ndigits argument also returns an integer.

__rpow__(value, mod=None, /)[source]

Return pow(value, self, mod).

__rrshift__(value, /)[source]

Return value>>self.

__rshift__(value, /)[source]

Return self>>value.

__rsub__(value, /)[source]

Return value-self.

__rtruediv__(value, /)[source]

Return value/self.

__rxor__(value, /)[source]

Return value^self.

__sizeof__()[source]

Returns size in memory, in bytes.

__str__()[source]

Return repr(self).

__sub__(value, /)[source]

Return self-value.

__truediv__(value, /)[source]

Return self/value.

__trunc__()[source]

Truncating an Integral returns itself.

__xor__(value, /)[source]

Return self^value.

as_integer_ratio()[source]

Return a pair of integers, whose ratio is equal to the original int.

The ratio is in lowest terms and has a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
bit_count()[source]

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
bit_length()[source]

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
conjugate()[source]

Returns self, the complex conjugate of any int.

denominator[source]

the denominator of a rational number in lowest terms

from_bytes(byteorder='big', *, signed=False)[source]

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

imag[source]

the imaginary part of a complex number

is_integer()[source]

Returns True. Exists for duck type compatibility with float.is_integer.

numerator[source]

the numerator of a rational number in lowest terms

real[source]

the real part of a complex number

to_bytes(length=1, byteorder='big', *, signed=False)[source]

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

class telegram.constants.ChatAction(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: str, enum.Enum

This enum contains the available chat actions for telegram.Bot.send_chat_action(). The enum members of this enumeration are instances of str and can be treated as such.

New in version 20.0.

CHOOSE_STICKER = 'choose_sticker'[source]

Chat action indicating that the bot is selecting a sticker.

Type:

str

FIND_LOCATION = 'find_location'[source]

Chat action indicating that the bot is selecting a location.

Type:

str

RECORD_VIDEO = 'record_video'[source]

Chat action indicating that the bot is recording a video.

Type:

str

RECORD_VIDEO_NOTE = 'record_video_note'[source]

Chat action indicating that the bot is recording a video note.

Type:

str

RECORD_VOICE = 'record_voice'[source]

Chat action indicating that the bot is recording a voice message.

Type:

str

TYPING = 'typing'[source]

A chat indicating the bot is typing.

Type:

str

UPLOAD_DOCUMENT = 'upload_document'[source]

Chat action indicating that the bot is uploading a document.

Type:

str

UPLOAD_PHOTO = 'upload_photo'[source]

Chat action indicating that the bot is uploading a photo.

Type:

str

UPLOAD_VIDEO = 'upload_video'[source]

Chat action indicating that the bot is uploading a video.

Type:

str

UPLOAD_VIDEO_NOTE = 'upload_video_note'[source]

Chat action indicating that the bot is uploading a video note.

Type:

str

UPLOAD_VOICE = 'upload_voice'[source]

Chat action indicating that the bot is uploading a voice message.

Type:

str

__add__(value, /)[source]

Return self+value.

__contains__(key, /)[source]

Return bool(key in self).

__eq__(value, /)[source]

Return self==value.

__format__(format_spec)[source]

Return a formatted version of the string as described by format_spec.

__ge__(value, /)[source]

Return self>=value.

__getattribute__(name, /)[source]

Return getattr(self, name).

__getitem__(key, /)[source]

Return self[key].

__gt__(value, /)[source]

Return self>value.

__hash__()[source]

Return hash(self).

__iter__()[source]

Implement iter(self).

__le__(value, /)[source]

Return self<=value.

__len__()[source]

Return len(self).

__lt__(value, /)[source]

Return self<value.

__mod__(value, /)[source]

Return self%value.

__mul__(value, /)[source]

Return self*value.

__ne__(value, /)[source]

Return self!=value.

__new__(value)[source]
__repr__()[source]

Return repr(self).

__rmod__(value, /)[source]

Return value%self.

__rmul__(value, /)[source]

Return value*self.

__sizeof__()[source]

Return the size of the string in memory, in bytes.

__str__()[source]

Return str(self).

capitalize()[source]

Return a capitalized version of the string.

More specifically, make the first character have upper case and the rest lower case.

casefold()[source]

Return a version of the string suitable for caseless comparisons.

center(width, fillchar=' ', /)[source]

Return a centered string of length width.

Padding is done using the specified fill character (default is a space).

count(sub[, start[, end]]) int[source]

Return the number of non-overlapping occurrences of substring sub in string S[start:end]. Optional arguments start and end are interpreted as in slice notation.

encode(encoding='utf-8', errors='strict')[source]

Encode the string using the codec registered for encoding.

encoding

The encoding in which to encode the string.

errors

The error handling scheme to use for encoding errors. The default is ‘strict’ meaning that encoding errors raise a UnicodeEncodeError. Other possible values are ‘ignore’, ‘replace’ and ‘xmlcharrefreplace’ as well as any other name registered with codecs.register_error that can handle UnicodeEncodeErrors.

endswith(suffix[, start[, end]]) bool[source]

Return True if S ends with the specified suffix, False otherwise. With optional start, test S beginning at that position. With optional end, stop comparing S at that position. suffix can also be a tuple of strings to try.

expandtabs(tabsize=8)[source]

Return a copy where all tab characters are expanded using spaces.

If tabsize is not given, a tab size of 8 characters is assumed.

find(sub[, start[, end]]) int[source]

Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Return -1 on failure.

format(*args, **kwargs) str[source]

Return a formatted version of S, using substitutions from args and kwargs. The substitutions are identified by braces (‘{’ and ‘}’).

format_map(mapping) str[source]

Return a formatted version of S, using substitutions from mapping. The substitutions are identified by braces (‘{’ and ‘}’).

index(sub[, start[, end]]) int[source]

Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Raises ValueError when the substring is not found.

isalnum()[source]

Return True if the string is an alpha-numeric string, False otherwise.

A string is alpha-numeric if all characters in the string are alpha-numeric and there is at least one character in the string.

isalpha()[source]

Return True if the string is an alphabetic string, False otherwise.

A string is alphabetic if all characters in the string are alphabetic and there is at least one character in the string.

isascii()[source]

Return True if all characters in the string are ASCII, False otherwise.

ASCII characters have code points in the range U+0000-U+007F. Empty string is ASCII too.

isdecimal()[source]

Return True if the string is a decimal string, False otherwise.

A string is a decimal string if all characters in the string are decimal and there is at least one character in the string.

isdigit()[source]

Return True if the string is a digit string, False otherwise.

A string is a digit string if all characters in the string are digits and there is at least one character in the string.

isidentifier()[source]

Return True if the string is a valid Python identifier, False otherwise.

Call keyword.iskeyword(s) to test whether string s is a reserved identifier, such as “def” or “class”.

islower()[source]

Return True if the string is a lowercase string, False otherwise.

A string is lowercase if all cased characters in the string are lowercase and there is at least one cased character in the string.

isnumeric()[source]

Return True if the string is a numeric string, False otherwise.

A string is numeric if all characters in the string are numeric and there is at least one character in the string.

isprintable()[source]

Return True if the string is printable, False otherwise.

A string is printable if all of its characters are considered printable in repr() or if it is empty.

isspace()[source]

Return True if the string is a whitespace string, False otherwise.

A string is whitespace if all characters in the string are whitespace and there is at least one character in the string.

istitle()[source]

Return True if the string is a title-cased string, False otherwise.

In a title-cased string, upper- and title-case characters may only follow uncased characters and lowercase characters only cased ones.

isupper()[source]

Return True if the string is an uppercase string, False otherwise.

A string is uppercase if all cased characters in the string are uppercase and there is at least one cased character in the string.

join(iterable, /)[source]

Concatenate any number of strings.

The string whose method is called is inserted in between each given string. The result is returned as a new string.

Example: ‘.’.join([‘ab’, ‘pq’, ‘rs’]) -> ‘ab.pq.rs’

ljust(width, fillchar=' ', /)[source]

Return a left-justified string of length width.

Padding is done using the specified fill character (default is a space).

lower()[source]

Return a copy of the string converted to lowercase.

lstrip(chars=None, /)[source]

Return a copy of the string with leading whitespace removed.

If chars is given and not None, remove characters in chars instead.

static maketrans()[source]

Return a translation table usable for str.translate().

If there is only one argument, it must be a dictionary mapping Unicode ordinals (integers) or characters to Unicode ordinals, strings or None. Character keys will be then converted to ordinals. If there are two arguments, they must be strings of equal length, and in the resulting dictionary, each character in x will be mapped to the character at the same position in y. If there is a third argument, it must be a string, whose characters will be mapped to None in the result.

partition(sep, /)[source]

Partition the string into three parts using the given separator.

This will search for the separator in the string. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.

If the separator is not found, returns a 3-tuple containing the original string and two empty strings.

removeprefix(prefix, /)[source]

Return a str with the given prefix string removed if present.

If the string starts with the prefix string, return string[len(prefix):]. Otherwise, return a copy of the original string.

removesuffix(suffix, /)[source]

Return a str with the given suffix string removed if present.

If the string ends with the suffix string and that suffix is not empty, return string[:-len(suffix)]. Otherwise, return a copy of the original string.

replace(old, new, count=-1, /)[source]

Return a copy with all occurrences of substring old replaced by new.

count

Maximum number of occurrences to replace. -1 (the default value) means replace all occurrences.

If the optional argument count is given, only the first count occurrences are replaced.

rfind(sub[, start[, end]]) int[source]

Return the highest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Return -1 on failure.

rindex(sub[, start[, end]]) int[source]

Return the highest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Raises ValueError when the substring is not found.

rjust(width, fillchar=' ', /)[source]

Return a right-justified string of length width.

Padding is done using the specified fill character (default is a space).

rpartition(sep, /)[source]

Partition the string into three parts using the given separator.

This will search for the separator in the string, starting at the end. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.

If the separator is not found, returns a 3-tuple containing two empty strings and the original string.

rsplit(sep=None, maxsplit=-1)[source]

Return a list of the substrings in the string, using sep as the separator string.

sep

The separator used to split the string.

When set to None (the default value), will split on any whitespace character (including n r t f and spaces) and will discard empty strings from the result.

maxsplit

Maximum number of splits (starting from the left). -1 (the default value) means no limit.

Splitting starts at the end of the string and works to the front.

rstrip(chars=None, /)[source]

Return a copy of the string with trailing whitespace removed.

If chars is given and not None, remove characters in chars instead.

split(sep=None, maxsplit=-1)[source]

Return a list of the substrings in the string, using sep as the separator string.

sep

The separator used to split the string.

When set to None (the default value), will split on any whitespace character (including n r t f and spaces) and will discard empty strings from the result.

maxsplit

Maximum number of splits (starting from the left). -1 (the default value) means no limit.

Note, str.split() is mainly useful for data that has been intentionally delimited. With natural text that includes punctuation, consider using the regular expression module.

splitlines(keepends=False)[source]

Return a list of the lines in the string, breaking at line boundaries.

Line breaks are not included in the resulting list unless keepends is given and true.

startswith(prefix[, start[, end]]) bool[source]

Return True if S starts with the specified prefix, False otherwise. With optional start, test S beginning at that position. With optional end, stop comparing S at that position. prefix can also be a tuple of strings to try.

strip(chars=None, /)[source]

Return a copy of the string with leading and trailing whitespace removed.

If chars is given and not None, remove characters in chars instead.

swapcase()[source]

Convert uppercase characters to lowercase and lowercase characters to uppercase.

title()[source]

Return a version of the string where each word is titlecased.

More specifically, words start with uppercased characters and all remaining cased characters have lower case.

translate(table, /)[source]

Replace each character in the string using the given translation table.

table

Translation table, which must be a mapping of Unicode ordinals to Unicode ordinals, strings, or None.

The table must implement lookup/indexing via __getitem__, for instance a dictionary or list. If this operation raises LookupError, the character is left untouched. Characters mapped to None are deleted.

upper()[source]

Return a copy of the string converted to uppercase.

zfill(width, /)[source]

Pad a numeric string with zeros on the left, to fill a field of the given width.

The string is never truncated.

class telegram.constants.ChatBoostSources(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: str, enum.Enum

This enum contains the available sources for a Telegram chat boost. The enum members of this enumeration are instances of str and can be treated as such.

New in version 20.8.

GIFT_CODE = 'gift_code'[source]

The source of the chat boost was a Telegram Premium gift code.

Type:

str

GIVEAWAY = 'giveaway'[source]

The source of the chat boost was a Telegram Premium giveaway.

Type:

str

PREMIUM = 'premium'[source]

The source of the chat boost was a Telegram Premium subscription/gift.

Type:

str

__add__(value, /)[source]

Return self+value.

__contains__(key, /)[source]

Return bool(key in self).

__eq__(value, /)[source]

Return self==value.

__format__(format_spec)[source]

Return a formatted version of the string as described by format_spec.

__ge__(value, /)[source]

Return self>=value.

__getattribute__(name, /)[source]

Return getattr(self, name).

__getitem__(key, /)[source]

Return self[key].

__gt__(value, /)[source]

Return self>value.

__hash__()[source]

Return hash(self).

__iter__()[source]

Implement iter(self).

__le__(value, /)[source]

Return self<=value.

__len__()[source]

Return len(self).

__lt__(value, /)[source]

Return self<value.

__mod__(value, /)[source]

Return self%value.

__mul__(value, /)[source]

Return self*value.

__ne__(value, /)[source]

Return self!=value.

__new__(value)[source]
__repr__()[source]

Return repr(self).

__rmod__(value, /)[source]

Return value%self.

__rmul__(value, /)[source]

Return value*self.

__sizeof__()[source]

Return the size of the string in memory, in bytes.

__str__()[source]

Return str(self).

capitalize()[source]

Return a capitalized version of the string.

More specifically, make the first character have upper case and the rest lower case.

casefold()[source]

Return a version of the string suitable for caseless comparisons.

center(width, fillchar=' ', /)[source]

Return a centered string of length width.

Padding is done using the specified fill character (default is a space).

count(sub[, start[, end]]) int[source]

Return the number of non-overlapping occurrences of substring sub in string S[start:end]. Optional arguments start and end are interpreted as in slice notation.

encode(encoding='utf-8', errors='strict')[source]

Encode the string using the codec registered for encoding.

encoding

The encoding in which to encode the string.

errors

The error handling scheme to use for encoding errors. The default is ‘strict’ meaning that encoding errors raise a UnicodeEncodeError. Other possible values are ‘ignore’, ‘replace’ and ‘xmlcharrefreplace’ as well as any other name registered with codecs.register_error that can handle UnicodeEncodeErrors.

endswith(suffix[, start[, end]]) bool[source]

Return True if S ends with the specified suffix, False otherwise. With optional start, test S beginning at that position. With optional end, stop comparing S at that position. suffix can also be a tuple of strings to try.

expandtabs(tabsize=8)[source]

Return a copy where all tab characters are expanded using spaces.

If tabsize is not given, a tab size of 8 characters is assumed.

find(sub[, start[, end]]) int[source]

Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Return -1 on failure.

format(*args, **kwargs) str[source]

Return a formatted version of S, using substitutions from args and kwargs. The substitutions are identified by braces (‘{’ and ‘}’).

format_map(mapping) str[source]

Return a formatted version of S, using substitutions from mapping. The substitutions are identified by braces (‘{’ and ‘}’).

index(sub[, start[, end]]) int[source]

Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Raises ValueError when the substring is not found.

isalnum()[source]

Return True if the string is an alpha-numeric string, False otherwise.

A string is alpha-numeric if all characters in the string are alpha-numeric and there is at least one character in the string.

isalpha()[source]

Return True if the string is an alphabetic string, False otherwise.

A string is alphabetic if all characters in the string are alphabetic and there is at least one character in the string.

isascii()[source]

Return True if all characters in the string are ASCII, False otherwise.

ASCII characters have code points in the range U+0000-U+007F. Empty string is ASCII too.

isdecimal()[source]

Return True if the string is a decimal string, False otherwise.

A string is a decimal string if all characters in the string are decimal and there is at least one character in the string.

isdigit()[source]

Return True if the string is a digit string, False otherwise.

A string is a digit string if all characters in the string are digits and there is at least one character in the string.

isidentifier()[source]

Return True if the string is a valid Python identifier, False otherwise.

Call keyword.iskeyword(s) to test whether string s is a reserved identifier, such as “def” or “class”.

islower()[source]

Return True if the string is a lowercase string, False otherwise.

A string is lowercase if all cased characters in the string are lowercase and there is at least one cased character in the string.

isnumeric()[source]

Return True if the string is a numeric string, False otherwise.

A string is numeric if all characters in the string are numeric and there is at least one character in the string.

isprintable()[source]

Return True if the string is printable, False otherwise.

A string is printable if all of its characters are considered printable in repr() or if it is empty.

isspace()[source]

Return True if the string is a whitespace string, False otherwise.

A string is whitespace if all characters in the string are whitespace and there is at least one character in the string.

istitle()[source]

Return True if the string is a title-cased string, False otherwise.

In a title-cased string, upper- and title-case characters may only follow uncased characters and lowercase characters only cased ones.

isupper()[source]

Return True if the string is an uppercase string, False otherwise.

A string is uppercase if all cased characters in the string are uppercase and there is at least one cased character in the string.

join(iterable, /)[source]

Concatenate any number of strings.

The string whose method is called is inserted in between each given string. The result is returned as a new string.

Example: ‘.’.join([‘ab’, ‘pq’, ‘rs’]) -> ‘ab.pq.rs’

ljust(width, fillchar=' ', /)[source]

Return a left-justified string of length width.

Padding is done using the specified fill character (default is a space).

lower()[source]

Return a copy of the string converted to lowercase.

lstrip(chars=None, /)[source]

Return a copy of the string with leading whitespace removed.

If chars is given and not None, remove characters in chars instead.

static maketrans()[source]

Return a translation table usable for str.translate().

If there is only one argument, it must be a dictionary mapping Unicode ordinals (integers) or characters to Unicode ordinals, strings or None. Character keys will be then converted to ordinals. If there are two arguments, they must be strings of equal length, and in the resulting dictionary, each character in x will be mapped to the character at the same position in y. If there is a third argument, it must be a string, whose characters will be mapped to None in the result.

partition(sep, /)[source]

Partition the string into three parts using the given separator.

This will search for the separator in the string. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.

If the separator is not found, returns a 3-tuple containing the original string and two empty strings.

removeprefix(prefix, /)[source]

Return a str with the given prefix string removed if present.

If the string starts with the prefix string, return string[len(prefix):]. Otherwise, return a copy of the original string.

removesuffix(suffix, /)[source]

Return a str with the given suffix string removed if present.

If the string ends with the suffix string and that suffix is not empty, return string[:-len(suffix)]. Otherwise, return a copy of the original string.

replace(old, new, count=-1, /)[source]

Return a copy with all occurrences of substring old replaced by new.

count

Maximum number of occurrences to replace. -1 (the default value) means replace all occurrences.

If the optional argument count is given, only the first count occurrences are replaced.

rfind(sub[, start[, end]]) int[source]

Return the highest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Return -1 on failure.

rindex(sub[, start[, end]]) int[source]

Return the highest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Raises ValueError when the substring is not found.

rjust(width, fillchar=' ', /)[source]

Return a right-justified string of length width.

Padding is done using the specified fill character (default is a space).

rpartition(sep, /)[source]

Partition the string into three parts using the given separator.

This will search for the separator in the string, starting at the end. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.

If the separator is not found, returns a 3-tuple containing two empty strings and the original string.

rsplit(sep=None, maxsplit=-1)[source]

Return a list of the substrings in the string, using sep as the separator string.

sep

The separator used to split the string.

When set to None (the default value), will split on any whitespace character (including n r t f and spaces) and will discard empty strings from the result.

maxsplit

Maximum number of splits (starting from the left). -1 (the default value) means no limit.

Splitting starts at the end of the string and works to the front.

rstrip(chars=None, /)[source]

Return a copy of the string with trailing whitespace removed.

If chars is given and not None, remove characters in chars instead.

split(sep=None, maxsplit=-1)[source]

Return a list of the substrings in the string, using sep as the separator string.

sep

The separator used to split the string.

When set to None (the default value), will split on any whitespace character (including n r t f and spaces) and will discard empty strings from the result.

maxsplit

Maximum number of splits (starting from the left). -1 (the default value) means no limit.

Note, str.split() is mainly useful for data that has been intentionally delimited. With natural text that includes punctuation, consider using the regular expression module.

splitlines(keepends=False)[source]

Return a list of the lines in the string, breaking at line boundaries.

Line breaks are not included in the resulting list unless keepends is given and true.

startswith(prefix[, start[, end]]) bool[source]

Return True if S starts with the specified prefix, False otherwise. With optional start, test S beginning at that position. With optional end, stop comparing S at that position. prefix can also be a tuple of strings to try.

strip(chars=None, /)[source]

Return a copy of the string with leading and trailing whitespace removed.

If chars is given and not None, remove characters in chars instead.

swapcase()[source]

Convert uppercase characters to lowercase and lowercase characters to uppercase.

title()[source]

Return a version of the string where each word is titlecased.

More specifically, words start with uppercased characters and all remaining cased characters have lower case.

translate(table, /)[source]

Replace each character in the string using the given translation table.

table

Translation table, which must be a mapping of Unicode ordinals to Unicode ordinals, strings, or None.

The table must implement lookup/indexing via __getitem__, for instance a dictionary or list. If this operation raises LookupError, the character is left untouched. Characters mapped to None are deleted.

upper()[source]

Return a copy of the string converted to uppercase.

zfill(width, /)[source]

Pad a numeric string with zeros on the left, to fill a field of the given width.

The string is never truncated.

class telegram.constants.ChatID(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: enum.IntEnum

This enum contains some special chat IDs. The enum members of this enumeration are instances of int and can be treated as such.

New in version 20.0.

ANONYMOUS_ADMIN = 1087968824[source]

User ID in groups for messages sent by anonymous admins. Telegram chat: @GroupAnonymousBot.

Note

telegram.Message.from_user will contain this ID for backwards compatibility only. It’s recommended to use telegram.Message.sender_chat instead.

Type:

int

FAKE_CHANNEL = 136817688[source]

User ID in groups when message is sent on behalf of a channel, or when a channel votes on a poll. Telegram chat: @Channel_Bot.

Note

Type:

int

SERVICE_CHAT = 777000[source]

Telegram service chat, that also acts as sender of channel posts forwarded to discussion groups. Telegram chat: Telegram.

Note

telegram.Message.from_user will contain this ID for backwards compatibility only. It’s recommended to use telegram.Message.sender_chat instead.

Type:

int

__abs__()[source]

abs(self)

__add__(value, /)[source]

Return self+value.

__and__(value, /)[source]

Return self&value.

__bool__()[source]

True if self else False

__ceil__()[source]

Ceiling of an Integral returns itself.

__divmod__(value, /)[source]

Return divmod(self, value).

__eq__(value, /)[source]

Return self==value.

__float__()[source]

float(self)

__floor__()[source]

Flooring an Integral returns itself.

__floordiv__(value, /)[source]

Return self//value.

__format__(format_spec, /)[source]

Convert to a string according to format_spec.

__ge__(value, /)[source]

Return self>=value.

__getattribute__(name, /)[source]

Return getattr(self, name).

__gt__(value, /)[source]

Return self>value.

__hash__()[source]

Return hash(self).

__index__()[source]

Return self converted to an integer, if self is suitable for use as an index into a list.

__int__()[source]

int(self)

__invert__()[source]

~self

__le__(value, /)[source]

Return self<=value.

__lshift__(value, /)[source]

Return self<<value.

__lt__(value, /)[source]

Return self<value.

__mod__(value, /)[source]

Return self%value.

__mul__(value, /)[source]

Return self*value.

__ne__(value, /)[source]

Return self!=value.

__neg__()[source]

-self

__new__(value)[source]
__or__(value, /)[source]

Return self|value.

__pos__()[source]

+self

__pow__(value, mod=None, /)[source]

Return pow(self, value, mod).

__radd__(value, /)[source]

Return value+self.

__rand__(value, /)[source]

Return value&self.

__rdivmod__(value, /)[source]

Return divmod(value, self).

__repr__()[source]

Return repr(self).

__rfloordiv__(value, /)[source]

Return value//self.

__rlshift__(value, /)[source]

Return value<<self.

__rmod__(value, /)[source]

Return value%self.

__rmul__(value, /)[source]

Return value*self.

__ror__(value, /)[source]

Return value|self.

__round__()[source]

Rounding an Integral returns itself.

Rounding with an ndigits argument also returns an integer.

__rpow__(value, mod=None, /)[source]

Return pow(value, self, mod).

__rrshift__(value, /)[source]

Return value>>self.

__rshift__(value, /)[source]

Return self>>value.

__rsub__(value, /)[source]

Return value-self.

__rtruediv__(value, /)[source]

Return value/self.

__rxor__(value, /)[source]

Return value^self.

__sizeof__()[source]

Returns size in memory, in bytes.

__str__()[source]

Return repr(self).

__sub__(value, /)[source]

Return self-value.

__truediv__(value, /)[source]

Return self/value.

__trunc__()[source]

Truncating an Integral returns itself.

__xor__(value, /)[source]

Return self^value.

as_integer_ratio()[source]

Return a pair of integers, whose ratio is equal to the original int.

The ratio is in lowest terms and has a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
bit_count()[source]

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
bit_length()[source]

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
conjugate()[source]

Returns self, the complex conjugate of any int.

denominator[source]

the denominator of a rational number in lowest terms

from_bytes(byteorder='big', *, signed=False)[source]

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

imag[source]

the imaginary part of a complex number

is_integer()[source]

Returns True. Exists for duck type compatibility with float.is_integer.

numerator[source]

the numerator of a rational number in lowest terms

real[source]

the real part of a complex number

to_bytes(length=1, byteorder='big', *, signed=False)[source]

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

class telegram.constants.ChatInviteLinkLimit(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: enum.IntEnum

This enum contains limitations for telegram.ChatInviteLink/ telegram.Bot.create_chat_invite_link()/telegram.Bot.edit_chat_invite_link(). The enum members of this enumeration are instances of int and can be treated as such.

New in version 20.0.

MAX_MEMBER_LIMIT = 99999[source]

Maximum value allowed for the member_limit parameter of telegram.Bot.create_chat_invite_link() and member_limit of telegram.Bot.edit_chat_invite_link().

Type:

int

MIN_MEMBER_LIMIT = 1[source]

Minimum value allowed for the member_limit parameter of telegram.Bot.create_chat_invite_link() and member_limit of telegram.Bot.edit_chat_invite_link().

Type:

int

NAME_LENGTH = 32[source]

Maximum number of characters in a str passed as the name parameter of telegram.Bot.create_chat_invite_link() and name of telegram.Bot.edit_chat_invite_link().

Type:

int

__abs__()[source]

abs(self)

__add__(value, /)[source]

Return self+value.

__and__(value, /)[source]

Return self&value.

__bool__()[source]

True if self else False

__ceil__()[source]

Ceiling of an Integral returns itself.

__divmod__(value, /)[source]

Return divmod(self, value).

__eq__(value, /)[source]

Return self==value.

__float__()[source]

float(self)

__floor__()[source]

Flooring an Integral returns itself.

__floordiv__(value, /)[source]

Return self//value.

__format__(format_spec, /)[source]

Convert to a string according to format_spec.

__ge__(value, /)[source]

Return self>=value.

__getattribute__(name, /)[source]

Return getattr(self, name).

__gt__(value, /)[source]

Return self>value.

__hash__()[source]

Return hash(self).

__index__()[source]

Return self converted to an integer, if self is suitable for use as an index into a list.

__int__()[source]

int(self)

__invert__()[source]

~self

__le__(value, /)[source]

Return self<=value.

__lshift__(value, /)[source]

Return self<<value.

__lt__(value, /)[source]

Return self<value.

__mod__(value, /)[source]

Return self%value.

__mul__(value, /)[source]

Return self*value.

__ne__(value, /)[source]

Return self!=value.

__neg__()[source]

-self

__new__(value)[source]
__or__(value, /)[source]

Return self|value.

__pos__()[source]

+self

__pow__(value, mod=None, /)[source]

Return pow(self, value, mod).

__radd__(value, /)[source]

Return value+self.

__rand__(value, /)[source]

Return value&self.

__rdivmod__(value, /)[source]

Return divmod(value, self).

__repr__()[source]

Return repr(self).

__rfloordiv__(value, /)[source]

Return value//self.

__rlshift__(value, /)[source]

Return value<<self.

__rmod__(value, /)[source]

Return value%self.

__rmul__(value, /)[source]

Return value*self.

__ror__(value, /)[source]

Return value|self.

__round__()[source]

Rounding an Integral returns itself.

Rounding with an ndigits argument also returns an integer.

__rpow__(value, mod=None, /)[source]

Return pow(value, self, mod).

__rrshift__(value, /)[source]

Return value>>self.

__rshift__(value, /)[source]

Return self>>value.

__rsub__(value, /)[source]

Return value-self.

__rtruediv__(value, /)[source]

Return value/self.

__rxor__(value, /)[source]

Return value^self.

__sizeof__()[source]

Returns size in memory, in bytes.

__str__()[source]

Return repr(self).

__sub__(value, /)[source]

Return self-value.

__truediv__(value, /)[source]

Return self/value.

__trunc__()[source]

Truncating an Integral returns itself.

__xor__(value, /)[source]

Return self^value.

as_integer_ratio()[source]

Return a pair of integers, whose ratio is equal to the original int.

The ratio is in lowest terms and has a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
bit_count()[source]

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
bit_length()[source]

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
conjugate()[source]

Returns self, the complex conjugate of any int.

denominator[source]

the denominator of a rational number in lowest terms

from_bytes(byteorder='big', *, signed=False)[source]

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

imag[source]

the imaginary part of a complex number

is_integer()[source]

Returns True. Exists for duck type compatibility with float.is_integer.

numerator[source]

the numerator of a rational number in lowest terms

real[source]

the real part of a complex number

to_bytes(length=1, byteorder='big', *, signed=False)[source]

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

class telegram.constants.ChatLimit(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: enum.IntEnum

This enum contains limitations for telegram.Bot.set_chat_administrator_custom_title(), telegram.Bot.set_chat_description(), and telegram.Bot.set_chat_title(). The enum members of this enumeration are instances of int and can be treated as such.

New in version 20.0.

CHAT_ADMINISTRATOR_CUSTOM_TITLE_LENGTH = 16[source]

Maximum length of a str passed as the custom_title parameter of telegram.Bot.set_chat_administrator_custom_title().

Type:

int

CHAT_DESCRIPTION_LENGTH = 255[source]

Maximum number of characters in a str passed as the description parameter of telegram.Bot.set_chat_description().

Type:

int

MAX_CHAT_TITLE_LENGTH = 128[source]

Maximum length of a str passed as the title parameter of telegram.Bot.set_chat_title().

Type:

int

MIN_CHAT_TITLE_LENGTH = 1[source]

Minimum length of a str passed as the title parameter of telegram.Bot.set_chat_title().

Type:

int

__abs__()[source]

abs(self)

__add__(value, /)[source]

Return self+value.

__and__(value, /)[source]

Return self&value.

__bool__()[source]

True if self else False

__ceil__()[source]

Ceiling of an Integral returns itself.

__divmod__(value, /)[source]

Return divmod(self, value).

__eq__(value, /)[source]

Return self==value.

__float__()[source]

float(self)

__floor__()[source]

Flooring an Integral returns itself.

__floordiv__(value, /)[source]

Return self//value.

__format__(format_spec, /)[source]

Convert to a string according to format_spec.

__ge__(value, /)[source]

Return self>=value.

__getattribute__(name, /)[source]

Return getattr(self, name).

__gt__(value, /)[source]

Return self>value.

__hash__()[source]

Return hash(self).

__index__()[source]

Return self converted to an integer, if self is suitable for use as an index into a list.

__int__()[source]

int(self)

__invert__()[source]

~self

__le__(value, /)[source]

Return self<=value.

__lshift__(value, /)[source]

Return self<<value.

__lt__(value, /)[source]

Return self<value.

__mod__(value, /)[source]

Return self%value.

__mul__(value, /)[source]

Return self*value.

__ne__(value, /)[source]

Return self!=value.

__neg__()[source]

-self

__new__(value)[source]
__or__(value, /)[source]

Return self|value.

__pos__()[source]

+self

__pow__(value, mod=None, /)[source]

Return pow(self, value, mod).

__radd__(value, /)[source]

Return value+self.

__rand__(value, /)[source]

Return value&self.

__rdivmod__(value, /)[source]

Return divmod(value, self).

__repr__()[source]

Return repr(self).

__rfloordiv__(value, /)[source]

Return value//self.

__rlshift__(value, /)[source]

Return value<<self.

__rmod__(value, /)[source]

Return value%self.

__rmul__(value, /)[source]

Return value*self.

__ror__(value, /)[source]

Return value|self.

__round__()[source]

Rounding an Integral returns itself.

Rounding with an ndigits argument also returns an integer.

__rpow__(value, mod=None, /)[source]

Return pow(value, self, mod).

__rrshift__(value, /)[source]

Return value>>self.

__rshift__(value, /)[source]

Return self>>value.

__rsub__(value, /)[source]

Return value-self.

__rtruediv__(value, /)[source]

Return value/self.

__rxor__(value, /)[source]

Return value^self.

__sizeof__()[source]

Returns size in memory, in bytes.

__str__()[source]

Return repr(self).

__sub__(value, /)[source]

Return self-value.

__truediv__(value, /)[source]

Return self/value.

__trunc__()[source]

Truncating an Integral returns itself.

__xor__(value, /)[source]

Return self^value.

as_integer_ratio()[source]

Return a pair of integers, whose ratio is equal to the original int.

The ratio is in lowest terms and has a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
bit_count()[source]

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
bit_length()[source]

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
conjugate()[source]

Returns self, the complex conjugate of any int.

denominator[source]

the denominator of a rational number in lowest terms

from_bytes(byteorder='big', *, signed=False)[source]

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

imag[source]

the imaginary part of a complex number

is_integer()[source]

Returns True. Exists for duck type compatibility with float.is_integer.

numerator[source]

the numerator of a rational number in lowest terms

real[source]

the real part of a complex number

to_bytes(length=1, byteorder='big', *, signed=False)[source]

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

class telegram.constants.ChatMemberStatus(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: str, enum.Enum

This enum contains the available states for telegram.ChatMember. The enum members of this enumeration are instances of str and can be treated as such.

New in version 20.0.

ADMINISTRATOR = 'administrator'[source]

A telegram.ChatMember who is administrator of the chat.

Type:

str

BANNED = 'kicked'[source]

A telegram.ChatMember who was banned in the chat.

Type:

str

LEFT = 'left'[source]

A telegram.ChatMember who has left the chat.

Type:

str

MEMBER = 'member'[source]

A telegram.ChatMember who is a member of the chat.

Type:

str

OWNER = 'creator'[source]

A telegram.ChatMember who is the owner of the chat.

Type:

str

RESTRICTED = 'restricted'[source]

A telegram.ChatMember who was restricted in this chat.

Type:

str

__add__(value, /)[source]

Return self+value.

__contains__(key, /)[source]

Return bool(key in self).

__eq__(value, /)[source]

Return self==value.

__format__(format_spec)[source]

Return a formatted version of the string as described by format_spec.

__ge__(value, /)[source]

Return self>=value.

__getattribute__(name, /)[source]

Return getattr(self, name).

__getitem__(key, /)[source]

Return self[key].

__gt__(value, /)[source]

Return self>value.

__hash__()[source]

Return hash(self).

__iter__()[source]

Implement iter(self).

__le__(value, /)[source]

Return self<=value.

__len__()[source]

Return len(self).

__lt__(value, /)[source]

Return self<value.

__mod__(value, /)[source]

Return self%value.

__mul__(value, /)[source]

Return self*value.

__ne__(value, /)[source]

Return self!=value.

__new__(value)[source]
__repr__()[source]

Return repr(self).

__rmod__(value, /)[source]

Return value%self.

__rmul__(value, /)[source]

Return value*self.

__sizeof__()[source]

Return the size of the string in memory, in bytes.

__str__()[source]

Return str(self).

capitalize()[source]

Return a capitalized version of the string.

More specifically, make the first character have upper case and the rest lower case.

casefold()[source]

Return a version of the string suitable for caseless comparisons.

center(width, fillchar=' ', /)[source]

Return a centered string of length width.

Padding is done using the specified fill character (default is a space).

count(sub[, start[, end]]) int[source]

Return the number of non-overlapping occurrences of substring sub in string S[start:end]. Optional arguments start and end are interpreted as in slice notation.

encode(encoding='utf-8', errors='strict')[source]

Encode the string using the codec registered for encoding.

encoding

The encoding in which to encode the string.

errors

The error handling scheme to use for encoding errors. The default is ‘strict’ meaning that encoding errors raise a UnicodeEncodeError. Other possible values are ‘ignore’, ‘replace’ and ‘xmlcharrefreplace’ as well as any other name registered with codecs.register_error that can handle UnicodeEncodeErrors.

endswith(suffix[, start[, end]]) bool[source]

Return True if S ends with the specified suffix, False otherwise. With optional start, test S beginning at that position. With optional end, stop comparing S at that position. suffix can also be a tuple of strings to try.

expandtabs(tabsize=8)[source]

Return a copy where all tab characters are expanded using spaces.

If tabsize is not given, a tab size of 8 characters is assumed.

find(sub[, start[, end]]) int[source]

Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Return -1 on failure.

format(*args, **kwargs) str[source]

Return a formatted version of S, using substitutions from args and kwargs. The substitutions are identified by braces (‘{’ and ‘}’).

format_map(mapping) str[source]

Return a formatted version of S, using substitutions from mapping. The substitutions are identified by braces (‘{’ and ‘}’).

index(sub[, start[, end]]) int[source]

Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Raises ValueError when the substring is not found.

isalnum()[source]

Return True if the string is an alpha-numeric string, False otherwise.

A string is alpha-numeric if all characters in the string are alpha-numeric and there is at least one character in the string.

isalpha()[source]

Return True if the string is an alphabetic string, False otherwise.

A string is alphabetic if all characters in the string are alphabetic and there is at least one character in the string.

isascii()[source]

Return True if all characters in the string are ASCII, False otherwise.

ASCII characters have code points in the range U+0000-U+007F. Empty string is ASCII too.

isdecimal()[source]

Return True if the string is a decimal string, False otherwise.

A string is a decimal string if all characters in the string are decimal and there is at least one character in the string.

isdigit()[source]

Return True if the string is a digit string, False otherwise.

A string is a digit string if all characters in the string are digits and there is at least one character in the string.

isidentifier()[source]

Return True if the string is a valid Python identifier, False otherwise.

Call keyword.iskeyword(s) to test whether string s is a reserved identifier, such as “def” or “class”.

islower()[source]

Return True if the string is a lowercase string, False otherwise.

A string is lowercase if all cased characters in the string are lowercase and there is at least one cased character in the string.

isnumeric()[source]

Return True if the string is a numeric string, False otherwise.

A string is numeric if all characters in the string are numeric and there is at least one character in the string.

isprintable()[source]

Return True if the string is printable, False otherwise.

A string is printable if all of its characters are considered printable in repr() or if it is empty.

isspace()[source]

Return True if the string is a whitespace string, False otherwise.

A string is whitespace if all characters in the string are whitespace and there is at least one character in the string.

istitle()[source]

Return True if the string is a title-cased string, False otherwise.

In a title-cased string, upper- and title-case characters may only follow uncased characters and lowercase characters only cased ones.

isupper()[source]

Return True if the string is an uppercase string, False otherwise.

A string is uppercase if all cased characters in the string are uppercase and there is at least one cased character in the string.

join(iterable, /)[source]

Concatenate any number of strings.

The string whose method is called is inserted in between each given string. The result is returned as a new string.

Example: ‘.’.join([‘ab’, ‘pq’, ‘rs’]) -> ‘ab.pq.rs’

ljust(width, fillchar=' ', /)[source]

Return a left-justified string of length width.

Padding is done using the specified fill character (default is a space).

lower()[source]

Return a copy of the string converted to lowercase.

lstrip(chars=None, /)[source]

Return a copy of the string with leading whitespace removed.

If chars is given and not None, remove characters in chars instead.

static maketrans()[source]

Return a translation table usable for str.translate().

If there is only one argument, it must be a dictionary mapping Unicode ordinals (integers) or characters to Unicode ordinals, strings or None. Character keys will be then converted to ordinals. If there are two arguments, they must be strings of equal length, and in the resulting dictionary, each character in x will be mapped to the character at the same position in y. If there is a third argument, it must be a string, whose characters will be mapped to None in the result.

partition(sep, /)[source]

Partition the string into three parts using the given separator.

This will search for the separator in the string. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.

If the separator is not found, returns a 3-tuple containing the original string and two empty strings.

removeprefix(prefix, /)[source]

Return a str with the given prefix string removed if present.

If the string starts with the prefix string, return string[len(prefix):]. Otherwise, return a copy of the original string.

removesuffix(suffix, /)[source]

Return a str with the given suffix string removed if present.

If the string ends with the suffix string and that suffix is not empty, return string[:-len(suffix)]. Otherwise, return a copy of the original string.

replace(old, new, count=-1, /)[source]

Return a copy with all occurrences of substring old replaced by new.

count

Maximum number of occurrences to replace. -1 (the default value) means replace all occurrences.

If the optional argument count is given, only the first count occurrences are replaced.

rfind(sub[, start[, end]]) int[source]

Return the highest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Return -1 on failure.

rindex(sub[, start[, end]]) int[source]

Return the highest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Raises ValueError when the substring is not found.

rjust(width, fillchar=' ', /)[source]

Return a right-justified string of length width.

Padding is done using the specified fill character (default is a space).

rpartition(sep, /)[source]

Partition the string into three parts using the given separator.

This will search for the separator in the string, starting at the end. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.

If the separator is not found, returns a 3-tuple containing two empty strings and the original string.

rsplit(sep=None, maxsplit=-1)[source]

Return a list of the substrings in the string, using sep as the separator string.

sep

The separator used to split the string.

When set to None (the default value), will split on any whitespace character (including n r t f and spaces) and will discard empty strings from the result.

maxsplit

Maximum number of splits (starting from the left). -1 (the default value) means no limit.

Splitting starts at the end of the string and works to the front.

rstrip(chars=None, /)[source]

Return a copy of the string with trailing whitespace removed.

If chars is given and not None, remove characters in chars instead.

split(sep=None, maxsplit=-1)[source]

Return a list of the substrings in the string, using sep as the separator string.

sep

The separator used to split the string.

When set to None (the default value), will split on any whitespace character (including n r t f and spaces) and will discard empty strings from the result.

maxsplit

Maximum number of splits (starting from the left). -1 (the default value) means no limit.

Note, str.split() is mainly useful for data that has been intentionally delimited. With natural text that includes punctuation, consider using the regular expression module.

splitlines(keepends=False)[source]

Return a list of the lines in the string, breaking at line boundaries.

Line breaks are not included in the resulting list unless keepends is given and true.

startswith(prefix[, start[, end]]) bool[source]

Return True if S starts with the specified prefix, False otherwise. With optional start, test S beginning at that position. With optional end, stop comparing S at that position. prefix can also be a tuple of strings to try.

strip(chars=None, /)[source]

Return a copy of the string with leading and trailing whitespace removed.

If chars is given and not None, remove characters in chars instead.

swapcase()[source]

Convert uppercase characters to lowercase and lowercase characters to uppercase.

title()[source]

Return a version of the string where each word is titlecased.

More specifically, words start with uppercased characters and all remaining cased characters have lower case.

translate(table, /)[source]

Replace each character in the string using the given translation table.

table

Translation table, which must be a mapping of Unicode ordinals to Unicode ordinals, strings, or None.

The table must implement lookup/indexing via __getitem__, for instance a dictionary or list. If this operation raises LookupError, the character is left untouched. Characters mapped to None are deleted.

upper()[source]

Return a copy of the string converted to uppercase.

zfill(width, /)[source]

Pad a numeric string with zeros on the left, to fill a field of the given width.

The string is never truncated.

class telegram.constants.ChatPhotoSize(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: enum.IntEnum

This enum contains limitations for telegram.ChatPhoto. The enum members of this enumeration are instances of int and can be treated as such.

New in version 20.0.

BIG = 640[source]

Width and height of a big chat photo, ID of which is passed in big_file_id and big_file_unique_id parameters of telegram.ChatPhoto.

Type:

int

SMALL = 160[source]

Width and height of a small chat photo, ID of which is passed in small_file_id and small_file_unique_id parameters of telegram.ChatPhoto.

Type:

int

__abs__()[source]

abs(self)

__add__(value, /)[source]

Return self+value.

__and__(value, /)[source]

Return self&value.

__bool__()[source]

True if self else False

__ceil__()[source]

Ceiling of an Integral returns itself.

__divmod__(value, /)[source]

Return divmod(self, value).

__eq__(value, /)[source]

Return self==value.

__float__()[source]

float(self)

__floor__()[source]

Flooring an Integral returns itself.

__floordiv__(value, /)[source]

Return self//value.

__format__(format_spec, /)[source]

Convert to a string according to format_spec.

__ge__(value, /)[source]

Return self>=value.

__getattribute__(name, /)[source]

Return getattr(self, name).

__gt__(value, /)[source]

Return self>value.

__hash__()[source]

Return hash(self).

__index__()[source]

Return self converted to an integer, if self is suitable for use as an index into a list.

__int__()[source]

int(self)

__invert__()[source]

~self

__le__(value, /)[source]

Return self<=value.

__lshift__(value, /)[source]

Return self<<value.

__lt__(value, /)[source]

Return self<value.

__mod__(value, /)[source]

Return self%value.

__mul__(value, /)[source]

Return self*value.

__ne__(value, /)[source]

Return self!=value.

__neg__()[source]

-self

__new__(value)[source]
__or__(value, /)[source]

Return self|value.

__pos__()[source]

+self

__pow__(value, mod=None, /)[source]

Return pow(self, value, mod).

__radd__(value, /)[source]

Return value+self.

__rand__(value, /)[source]

Return value&self.

__rdivmod__(value, /)[source]

Return divmod(value, self).

__repr__()[source]

Return repr(self).

__rfloordiv__(value, /)[source]

Return value//self.

__rlshift__(value, /)[source]

Return value<<self.

__rmod__(value, /)[source]

Return value%self.

__rmul__(value, /)[source]

Return value*self.

__ror__(value, /)[source]

Return value|self.

__round__()[source]

Rounding an Integral returns itself.

Rounding with an ndigits argument also returns an integer.

__rpow__(value, mod=None, /)[source]

Return pow(value, self, mod).

__rrshift__(value, /)[source]

Return value>>self.

__rshift__(value, /)[source]

Return self>>value.

__rsub__(value, /)[source]

Return value-self.

__rtruediv__(value, /)[source]

Return value/self.

__rxor__(value, /)[source]

Return value^self.

__sizeof__()[source]

Returns size in memory, in bytes.

__str__()[source]

Return repr(self).

__sub__(value, /)[source]

Return self-value.

__truediv__(value, /)[source]

Return self/value.

__trunc__()[source]

Truncating an Integral returns itself.

__xor__(value, /)[source]

Return self^value.

as_integer_ratio()[source]

Return a pair of integers, whose ratio is equal to the original int.

The ratio is in lowest terms and has a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
bit_count()[source]

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
bit_length()[source]

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
conjugate()[source]

Returns self, the complex conjugate of any int.

denominator[source]

the denominator of a rational number in lowest terms

from_bytes(byteorder='big', *, signed=False)[source]

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

imag[source]

the imaginary part of a complex number

is_integer()[source]

Returns True. Exists for duck type compatibility with float.is_integer.

numerator[source]

the numerator of a rational number in lowest terms

real[source]

the real part of a complex number

to_bytes(length=1, byteorder='big', *, signed=False)[source]

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

class telegram.constants.ChatType(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: str, enum.Enum

This enum contains the available types of telegram.Chat. The enum members of this enumeration are instances of str and can be treated as such.

New in version 20.0.

CHANNEL = 'channel'[source]

A telegram.Chat that is a channel.

Type:

str

GROUP = 'group'[source]

A telegram.Chat that is a group.

Type:

str

PRIVATE = 'private'[source]

A telegram.Chat that is private.

Type:

str

SENDER = 'sender'[source]

A telegram.Chat that represents the chat of a telegram.User sending an telegram.InlineQuery.

Type:

str

SUPERGROUP = 'supergroup'[source]

A telegram.Chat that is a supergroup.

Type:

str

__add__(value, /)[source]

Return self+value.

__contains__(key, /)[source]

Return bool(key in self).

__eq__(value, /)[source]

Return self==value.

__format__(format_spec)[source]

Return a formatted version of the string as described by format_spec.

__ge__(value, /)[source]

Return self>=value.

__getattribute__(name, /)[source]

Return getattr(self, name).

__getitem__(key, /)[source]

Return self[key].

__gt__(value, /)[source]

Return self>value.

__hash__()[source]

Return hash(self).

__iter__()[source]

Implement iter(self).

__le__(value, /)[source]

Return self<=value.

__len__()[source]

Return len(self).

__lt__(value, /)[source]

Return self<value.

__mod__(value, /)[source]

Return self%value.

__mul__(value, /)[source]

Return self*value.

__ne__(value, /)[source]

Return self!=value.

__new__(value)[source]
__repr__()[source]

Return repr(self).

__rmod__(value, /)[source]

Return value%self.

__rmul__(value, /)[source]

Return value*self.

__sizeof__()[source]

Return the size of the string in memory, in bytes.

__str__()[source]

Return str(self).

capitalize()[source]

Return a capitalized version of the string.

More specifically, make the first character have upper case and the rest lower case.

casefold()[source]

Return a version of the string suitable for caseless comparisons.

center(width, fillchar=' ', /)[source]

Return a centered string of length width.

Padding is done using the specified fill character (default is a space).

count(sub[, start[, end]]) int[source]

Return the number of non-overlapping occurrences of substring sub in string S[start:end]. Optional arguments start and end are interpreted as in slice notation.

encode(encoding='utf-8', errors='strict')[source]

Encode the string using the codec registered for encoding.

encoding

The encoding in which to encode the string.

errors

The error handling scheme to use for encoding errors. The default is ‘strict’ meaning that encoding errors raise a UnicodeEncodeError. Other possible values are ‘ignore’, ‘replace’ and ‘xmlcharrefreplace’ as well as any other name registered with codecs.register_error that can handle UnicodeEncodeErrors.

endswith(suffix[, start[, end]]) bool[source]

Return True if S ends with the specified suffix, False otherwise. With optional start, test S beginning at that position. With optional end, stop comparing S at that position. suffix can also be a tuple of strings to try.

expandtabs(tabsize=8)[source]

Return a copy where all tab characters are expanded using spaces.

If tabsize is not given, a tab size of 8 characters is assumed.

find(sub[, start[, end]]) int[source]

Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Return -1 on failure.

format(*args, **kwargs) str[source]

Return a formatted version of S, using substitutions from args and kwargs. The substitutions are identified by braces (‘{’ and ‘}’).

format_map(mapping) str[source]

Return a formatted version of S, using substitutions from mapping. The substitutions are identified by braces (‘{’ and ‘}’).

index(sub[, start[, end]]) int[source]

Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Raises ValueError when the substring is not found.

isalnum()[source]

Return True if the string is an alpha-numeric string, False otherwise.

A string is alpha-numeric if all characters in the string are alpha-numeric and there is at least one character in the string.

isalpha()[source]

Return True if the string is an alphabetic string, False otherwise.

A string is alphabetic if all characters in the string are alphabetic and there is at least one character in the string.

isascii()[source]

Return True if all characters in the string are ASCII, False otherwise.

ASCII characters have code points in the range U+0000-U+007F. Empty string is ASCII too.

isdecimal()[source]

Return True if the string is a decimal string, False otherwise.

A string is a decimal string if all characters in the string are decimal and there is at least one character in the string.

isdigit()[source]

Return True if the string is a digit string, False otherwise.

A string is a digit string if all characters in the string are digits and there is at least one character in the string.

isidentifier()[source]

Return True if the string is a valid Python identifier, False otherwise.

Call keyword.iskeyword(s) to test whether string s is a reserved identifier, such as “def” or “class”.

islower()[source]

Return True if the string is a lowercase string, False otherwise.

A string is lowercase if all cased characters in the string are lowercase and there is at least one cased character in the string.

isnumeric()[source]

Return True if the string is a numeric string, False otherwise.

A string is numeric if all characters in the string are numeric and there is at least one character in the string.

isprintable()[source]

Return True if the string is printable, False otherwise.

A string is printable if all of its characters are considered printable in repr() or if it is empty.

isspace()[source]

Return True if the string is a whitespace string, False otherwise.

A string is whitespace if all characters in the string are whitespace and there is at least one character in the string.

istitle()[source]

Return True if the string is a title-cased string, False otherwise.

In a title-cased string, upper- and title-case characters may only follow uncased characters and lowercase characters only cased ones.

isupper()[source]

Return True if the string is an uppercase string, False otherwise.

A string is uppercase if all cased characters in the string are uppercase and there is at least one cased character in the string.

join(iterable, /)[source]

Concatenate any number of strings.

The string whose method is called is inserted in between each given string. The result is returned as a new string.

Example: ‘.’.join([‘ab’, ‘pq’, ‘rs’]) -> ‘ab.pq.rs’

ljust(width, fillchar=' ', /)[source]

Return a left-justified string of length width.

Padding is done using the specified fill character (default is a space).

lower()[source]

Return a copy of the string converted to lowercase.

lstrip(chars=None, /)[source]

Return a copy of the string with leading whitespace removed.

If chars is given and not None, remove characters in chars instead.

static maketrans()[source]

Return a translation table usable for str.translate().

If there is only one argument, it must be a dictionary mapping Unicode ordinals (integers) or characters to Unicode ordinals, strings or None. Character keys will be then converted to ordinals. If there are two arguments, they must be strings of equal length, and in the resulting dictionary, each character in x will be mapped to the character at the same position in y. If there is a third argument, it must be a string, whose characters will be mapped to None in the result.

partition(sep, /)[source]

Partition the string into three parts using the given separator.

This will search for the separator in the string. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.

If the separator is not found, returns a 3-tuple containing the original string and two empty strings.

removeprefix(prefix, /)[source]

Return a str with the given prefix string removed if present.

If the string starts with the prefix string, return string[len(prefix):]. Otherwise, return a copy of the original string.

removesuffix(suffix, /)[source]

Return a str with the given suffix string removed if present.

If the string ends with the suffix string and that suffix is not empty, return string[:-len(suffix)]. Otherwise, return a copy of the original string.

replace(old, new, count=-1, /)[source]

Return a copy with all occurrences of substring old replaced by new.

count

Maximum number of occurrences to replace. -1 (the default value) means replace all occurrences.

If the optional argument count is given, only the first count occurrences are replaced.

rfind(sub[, start[, end]]) int[source]

Return the highest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Return -1 on failure.

rindex(sub[, start[, end]]) int[source]

Return the highest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.

Raises ValueError when the substring is not found.

rjust(width, fillchar=' ', /)[source]

Return a right-justified string of length width.

Padding is done using the specified fill character (default is a space).

rpartition(sep, /)[source]

Partition the string into three parts using the given separator.

This will search for the separator in the string, starting at the end. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.

If the separator is not found, returns a 3-tuple containing two empty strings and the original string.

rsplit(sep=None, maxsplit=-1)[source]

Return a list of the substrings in the string, using sep as the separator string.

sep

The separator used to split the string.

When set to None (the default value), will split on any whitespace character (including n r t f and spaces) and will discard empty strings from the result.

maxsplit

Maximum number of splits (starting from the left). -1 (the default value) means no limit.

Splitting starts at the end of the string and works to the front.

rstrip(chars=None, /)[source]

Return a copy of the string with trailing whitespace removed.

If chars is given and not None, remove characters in chars instead.

split(sep=None, maxsplit=-1)[source]

Return a list of the substrings in the string, using sep as the separator string.

sep

The separator used to split the string.

When set to None (the default value), will split on any whitespace character (including n r t f and spaces) and will discard empty strings from the result.

maxsplit

Maximum number of splits (starting from the left). -1 (the default value) means no limit.

Note, str.split() is mainly useful for data that has been intentionally delimited. With natural text that includes punctuation, consider using the regular expression module.

splitlines(keepends=False)[source]

Return a list of the lines in the string, breaking at line boundaries.

Line breaks are not included in the resulting list unless keepends is given and true.

startswith(prefix[, start[, end]]) bool[source]

Return True if S starts with the specified prefix, False otherwise. With optional start, test S beginning at that position. With optional end, stop comparing S at that position. prefix can also be a tuple of strings to try.

strip(chars=None, /)[source]

Return a copy of the string with leading and trailing whitespace removed.

If chars is given and not None, remove characters in chars instead.

swapcase()[source]

Convert uppercase characters to lowercase and lowercase characters to uppercase.

title()[source]

Return a version of the string where each word is titlecased.

More specifically, words start with uppercased characters and all remaining cased characters have lower case.

translate(table, /)[source]

Replace each character in the string using the given translation table.

table

Translation table, which must be a mapping of Unicode ordinals to Unicode ordinals, strings, or None.

The table must implement lookup/indexing via __getitem__, for instance a dictionary or list. If this operation raises LookupError, the character is left untouched. Characters mapped to None are deleted.

upper()[source]

Return a copy of the string converted to uppercase.

zfill(width, /)[source]

Pad a numeric string with zeros on the left, to fill a field of the given width.

The string is never truncated.

class telegram.constants.ContactLimit(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: enum.IntEnum

This enum contains limitations for telegram.InlineQueryResultContact, telegram.InputContactMessageContent, and telegram.Bot.send_contact(). The enum members of this enumeration are instances of int and can be treated as such.

New in version 20.0.

VCARD = 2048[source]

Maximum value allowed for:

Type:

int

__abs__()[source]

abs(self)

__add__(value, /)[source]

Return self+value.

__and__(value, /)[source]

Return self&value.

__bool__()[source]

True if self else False

__ceil__()[source]

Ceiling of an Integral returns itself.

__divmod__(value, /)[source]

Return divmod(self, value).

__eq__(value, /)[source]

Return self==value.

__float__()[source]

float(self)

__floor__()[source]

Flooring an Integral returns itself.

__floordiv__(value, /)[source]

Return self//value.

__format__(format_spec, /)[source]

Convert to a string according to format_spec.

__ge__(value, /)[source]

Return self>=value.

__getattribute__(name, /)[source]

Return getattr(self, name).

__gt__(value, /)[source]

Return self>value.

__hash__()[source]

Return hash(self).

__index__()[source]

Return self converted to an integer, if self is suitable for use as an index into a list.

__int__()[source]

int(self)

__invert__()[source]

~self

__le__(value, /)[source]

Return self<=value.

__lshift__(value, /)[source]

Return self<<value.

__lt__(value, /)[source]

Return self<value.

__mod__(value, /)[source]

Return self%value.

__mul__(value, /)[source]

Return self*value.

__ne__(value, /)[source]

Return self!=value.

__neg__()[source]

-self

__new__(value)[source]
__or__(value, /)[source]

Return self|value.

__pos__()[source]

+self

__pow__(value, mod=None, /)[source]

Return pow(self, value, mod).

__radd__(value, /)[source]

Return value+self.

__rand__(value, /)[source]

Return value&self.

__rdivmod__(value, /)[source]

Return divmod(value, self).

__repr__()[source]

Return repr(self).

__rfloordiv__(value, /)[source]

Return value//self.

__rlshift__(value, /)[source]

Return value<<self.

__rmod__(value, /)[source]

Return value%self.

__rmul__(value, /)[source]

Return value*self.

__ror__(value, /)[source]

Return value|self.

__round__()[source]

Rounding an Integral returns itself.

Rounding with an ndigits argument also returns an integer.

__rpow__(value, mod=None, /)[source]

Return pow(value, self, mod).

__rrshift__(value, /)[source]

Return value>>self.

__rshift__(value, /)[source]

Return self>>value.

__rsub__(value, /)[source]

Return value-self.

__rtruediv__(value, /)[source]

Return value/self.

__rxor__(value, /)[source]

Return value^self.

__sizeof__()[source]

Returns size in memory, in bytes.

__str__()[source]

Return repr(self).

__sub__(value, /)[source]

Return self-value.

__truediv__(value, /)[source]

Return self/value.

__trunc__()[source]

Truncating an Integral returns itself.

__xor__(value, /)[source]

Return self^value.

as_integer_ratio()[source]

Return a pair of integers, whose ratio is equal to the original int.

The ratio is in lowest terms and has a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
bit_count()[source]

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
bit_length()[source]

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
conjugate()[source]

Returns self, the complex conjugate of any int.

denominator[source]

the denominator of a rational number in lowest terms

from_bytes(byteorder='big', *, signed=False)[source]

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

imag[source]

the imaginary part of a complex number

is_integer()[source]

Returns True. Exists for duck type compatibility with float.is_integer.

numerator[source]

the numerator of a rational number in lowest terms

real[source]

the real part of a complex number

to_bytes(length=1, byteorder='big', *, signed=False)[source]

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

class telegram.constants.CustomEmojiStickerLimit(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: enum.IntEnum

This enum contains limitations for telegram.Bot.get_custom_emoji_stickers(). The enum members of this enumeration are instances of int and can be treated as such.

New in version 20.0.

CUSTOM_EMOJI_IDENTIFIER_LIMIT = 200[source]

Maximum amount of custom emoji identifiers which can be specified for the custom_emoji_ids parameter of telegram.Bot.get_custom_emoji_stickers().

Type:

int

__abs__()[source]

abs(self)

__add__(value, /)[source]

Return self+value.

__and__(value, /)[source]

Return self&value.

__bool__()[source]

True if self else False

__ceil__()[source]

Ceiling of an Integral returns itself.

__divmod__(value, /)[source]

Return divmod(self, value).

__eq__(value, /)[source]

Return self==value.

__float__()[source]

float(self)

__floor__()[source]

Flooring an Integral returns itself.

__floordiv__(value, /)[source]

Return self//value.

__format__(format_spec, /)[source]

Convert to a string according to format_spec.

__ge__(value, /)[source]

Return self>=value.

__getattribute__(name, /)[source]

Return getattr(self, name).

__gt__(value, /)[source]

Return self>value.

__hash__()[source]