Telegram API

The Telegram adapter contains the largest platform surface in Peyk, including messages, media, forum topics, keyboards, inline mode, stickers, payments, Passport, games, business accounts, boosts/gifts, web apps, and newer Telegram features.

Client

Telegram platform adapter and compatibility exports.

class peyk.platforms.telegram.AcceptedGiftTypes(unlimited_gifts: bool, limited_gifts: bool, unique_gifts: bool, premium_subscription: bool, gifts_from_channels: bool)[source]

Bases: object

This object describes the types of gifts that can be gifted to a user or a chat.

Variables:
  • unlimited_gifts (bool) – True, if unlimited regular gifts are accepted

  • limited_gifts (bool) – True, if limited regular gifts are accepted

  • unique_gifts (bool) – True, if unique gifts or gifts that can be upgraded to unique for free are accepted

  • premium_subscription (bool) – True, if a Telegram Premium subscription is accepted

  • gifts_from_channels (bool) – True, if transfers of unique gifts from channels are accepted

classmethod from_dict(data: dict | None) AcceptedGiftTypes | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

unlimited_gifts: bool
limited_gifts: bool
unique_gifts: bool
premium_subscription: bool
gifts_from_channels: bool
class peyk.platforms.telegram.AffiliateInfo(commission_per_mille: int = 0, amount: int = 0, nanostar_amount: int | None = None, currency: str = '')[source]

Bases: object

Contains information about the affiliate that received a commission via this transaction.

Variables:
  • commission_per_mille (int) – The number of Telegram Stars received by the affiliate for each 1000 Telegram Stars received by the bot from referred users

  • amount (int) – Integer amount of Telegram Stars received by the affiliate from the transaction, rounded to 0; can be negative for refunds

  • affiliate_user – The bot or the user that received an affiliate commission if it was received by a bot or a user

  • affiliate_chat – The chat that received an affiliate commission if it was received by a chat

  • nanostar_amount (int | None) – The number of 1/1000000000 shares of Telegram Stars received by the affiliate; from -999999999 to 999999999; can be negative for refunds

amount: int = 0
commission_per_mille: int = 0
currency: str = ''
classmethod from_dict(data: dict | None) AffiliateInfo | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

nanostar_amount: int | None = None
class peyk.platforms.telegram.Animation(file_id: str, file_unique_id: str, width: int, height: int, duration: int, thumbnail: PhotoSize | None = None, file_name: str | None = None, mime_type: str | None = None, file_size: int | None = None)[source]

Bases: object

This object represents an animation file (GIF or H.264/MPEG-4 AVC video without sound).

Variables:
  • file_id (str) – Identifier for this file, which can be used to download or reuse the file

  • file_unique_id (str) – Unique identifier for this file, which is supposed to be the same over time and for different bots. Can’t be used to download or reuse the file.

  • width (int) – Video width as defined by the sender

  • height (int) – Video height as defined by the sender

  • duration (int) – Duration of the video in seconds as defined by the sender

  • thumbnail (peyk.platforms.telegram.types.photo_size.PhotoSize | None) – Animation thumbnail as defined by the sender

  • file_name (str | None) – Original animation filename as defined by the sender

  • mime_type (str | None) – MIME type of the file as defined by the sender

  • file_size (int | None) – File size in bytes. It can be bigger than 2^31 and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this value.

file_name: str | None = None
file_size: int | None = None
classmethod from_dict(data: dict | None) Animation | None[source]

Parse a Telegram API mapping into this type.

Parameters:

data – Raw Telegram API mapping, or None.

Returns:

Parsed type instance, or None when data is None.

mime_type: str | None = None
thumbnail: PhotoSize | None = None
file_id: str
file_unique_id: str
width: int
height: int
duration: int
class peyk.platforms.telegram.Audio(file_id: str, file_unique_id: str, duration: int, performer: str | None = None, title: str | None = None, file_name: str | None = None, mime_type: str | None = None, file_size: int | None = None, thumbnail: PhotoSize | None = None)[source]

Bases: object

This object represents an audio file to be treated as music by the Telegram clients.

Variables:
  • file_id (str) – Identifier for this file, which can be used to download or reuse the file

  • file_unique_id (str) – Unique identifier for this file, which is supposed to be the same over time and for different bots. Can’t be used to download or reuse the file.

  • duration (int) – Duration of the audio in seconds as defined by the sender

  • performer (str | None) – Performer of the audio as defined by the sender or by audio tags

  • title (str | None) – Title of the audio as defined by the sender or by audio tags

  • file_name (str | None) – Original filename as defined by the sender

  • mime_type (str | None) – MIME type of the file as defined by the sender

  • file_size (int | None) – File size in bytes. It can be bigger than 2^31 and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this value.

  • thumbnail (peyk.platforms.telegram.types.photo_size.PhotoSize | None) – Thumbnail of the album cover to which the music file belongs

file_name: str | None = None
file_size: int | None = None
classmethod from_dict(data: dict | None) Audio | None[source]

Parse a Telegram API mapping into this type.

Parameters:

data – Raw Telegram API mapping, or None.

Returns:

Parsed type instance, or None when data is None.

mime_type: str | None = None
performer: str | None = None
thumbnail: PhotoSize | None = None
title: str | None = None
file_id: str
file_unique_id: str
duration: int
class peyk.platforms.telegram.BackgroundFillFreeformGradient(type: str = 'freeform_gradient', colors: List[int] | None = None)[source]

Bases: object

The background is a freeform gradient that rotates after every message in the chat.

Variables:
  • type (str) – Type of the background fill, always ‘freeform_gradient’

  • colors (List[int] | None) – A list of the 3 or 4 base colors that are used to generate the freeform gradient in the RGB24 format

colors: List[int] | None = None
classmethod from_dict(data: dict | None) BackgroundFillFreeformGradient | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

type: str = 'freeform_gradient'
class peyk.platforms.telegram.BackgroundFillGradient(type: str = 'gradient', top_color: int = 0, bottom_color: int = 0, rotation_angle: int = 0)[source]

Bases: object

The background is a gradient fill.

Variables:
  • type (str) – Type of the background fill, always ‘gradient’

  • top_color (int) – Top color of the gradient in the RGB24 format

  • bottom_color (int) – Bottom color of the gradient in the RGB24 format

  • rotation_angle (int) – Clockwise rotation angle of the background fill in degrees; 0-359

bottom_color: int = 0
classmethod from_dict(data: dict | None) BackgroundFillGradient | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

rotation_angle: int = 0
top_color: int = 0
type: str = 'gradient'
class peyk.platforms.telegram.BackgroundFillSolid(type: str = 'solid', color: int = 0)[source]

Bases: object

The background is filled using the selected color.

Variables:
  • type (str) – Type of the background fill, always ‘solid’

  • color (int) – The color of the background fill in the RGB24 format

color: int = 0
classmethod from_dict(data: dict | None) BackgroundFillSolid | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

type: str = 'solid'
class peyk.platforms.telegram.BackgroundFillType(*values)[source]

Bases: StrEnum

Telegram background-fill discriminator values.

SOLID = 'solid'
GRADIENT = 'gradient'
FREEFORM_GRADIENT = 'freeform_gradient'
class peyk.platforms.telegram.BackgroundType(*values)[source]

Bases: StrEnum

Telegram background-type discriminator values.

FILL = 'fill'
WALLPAPER = 'wallpaper'
PATTERN = 'pattern'
CHAT_THEME = 'chat_theme'
class peyk.platforms.telegram.BackgroundTypeChatTheme(type: str = 'chat_theme', theme_name: str = '')[source]

Bases: object

The background is taken directly from a built-in chat theme.

Variables:
  • type (str) – Type of the background, always ‘chat_theme’

  • theme_name (str) – Name of the chat theme, which is usually an emoji

classmethod from_dict(data: dict | None) BackgroundTypeChatTheme | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

theme_name: str = ''
type: str = 'chat_theme'
class peyk.platforms.telegram.BackgroundTypeFill(type: str = 'fill', fill: BackgroundFillSolid | BackgroundFillGradient | BackgroundFillFreeformGradient | None = None, dark_theme_dimming: int = 0)[source]

Bases: object

The background is automatically filled based on the selected colors.

Variables:
dark_theme_dimming: int = 0
fill: BackgroundFillSolid | BackgroundFillGradient | BackgroundFillFreeformGradient | None = None
classmethod from_dict(data: dict | None) BackgroundTypeFill | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

type: str = 'fill'
class peyk.platforms.telegram.BackgroundTypePattern(type: str = 'pattern', document: Document | None = None, fill: BackgroundFillSolid | BackgroundFillGradient | BackgroundFillFreeformGradient | None = None, intensity: int = 0, is_inverted: bool | None = None, is_moving: bool | None = None)[source]

Bases: object

The background is a .PNG or .TGV (gzipped subset of SVG with MIME type ‘application/x-tgwallpattern’) pattern to be combined with the background fill chosen by the user.

Variables:
document: Document | None = None
fill: BackgroundFillSolid | BackgroundFillGradient | BackgroundFillFreeformGradient | None = None
classmethod from_dict(data: dict | None) BackgroundTypePattern | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

intensity: int = 0
is_inverted: bool | None = None
is_moving: bool | None = None
type: str = 'pattern'
class peyk.platforms.telegram.BackgroundTypeWallpaper(type: str = 'wallpaper', document: Document | None = None, dark_theme_dimming: int = 0, is_blurred: bool | None = None, is_moving: bool | None = None)[source]

Bases: object

The background is a wallpaper in the JPEG format.

Variables:
  • type (str) – Type of the background, always ‘wallpaper’

  • document (peyk.platforms.telegram.types.document.Document | None) – Document with the wallpaper

  • dark_theme_dimming (int) – Dimming of the background in dark themes, as a percentage; 0-100

  • is_blurred (bool | None) – True, if the wallpaper is downscaled to fit in a 450x450 square and then box-blurred with radius 12

  • is_moving (bool | None) – True, if the background moves slightly when the device is tilted

dark_theme_dimming: int = 0
document: Document | None = None
classmethod from_dict(data: dict | None) BackgroundTypeWallpaper | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

is_blurred: bool | None = None
is_moving: bool | None = None
type: str = 'wallpaper'
class peyk.platforms.telegram.Birthdate(day: int, month: int, year: int | None = None)[source]

Bases: object

Describes the birthdate of a user.

Variables:
  • day (int) – Day of the user’s birth; 1-31

  • month (int) – Month of the user’s birth; 1-12

  • year (int | None) – Year of the user’s birth

classmethod from_dict(data: dict | None) Birthdate | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

year: int | None = None
day: int
month: int
class peyk.platforms.telegram.BotAccessSettings(can_send_messages: bool | None = None, can_send_audios: bool | None = None, can_send_documents: bool | None = None, can_send_photos: bool | None = None, can_send_videos: bool | None = None, can_send_video_notes: bool | None = None, can_send_voice_notes: bool | None = None, can_send_polls: bool | None = None, can_send_other_messages: bool | None = None, can_add_web_page_previews: bool | None = None, can_change_info: bool | None = None, can_invite_users: bool | None = None, can_pin_messages: bool | None = None, can_manage_topics: bool | None = None)[source]

Bases: object

This object describes the access settings of a bot.

Variables:
  • is_access_restricted – True, if only selected users can access the bot. The bot’s owner can always access it.

  • added_users – The list of other users who have access to the bot if the access is restricted

can_add_web_page_previews: bool | None = None
can_change_info: bool | None = None
can_invite_users: bool | None = None
can_manage_topics: bool | None = None
can_pin_messages: bool | None = None
can_send_audios: bool | None = None
can_send_documents: bool | None = None
can_send_messages: bool | None = None
can_send_other_messages: bool | None = None
can_send_photos: bool | None = None
can_send_polls: bool | None = None
can_send_video_notes: bool | None = None
can_send_videos: bool | None = None
can_send_voice_notes: bool | None = None
classmethod from_dict(data: dict | None) BotAccessSettings | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

class peyk.platforms.telegram.BotCommand(command: str = '', description: str = '', is_ephemeral: bool | None = None)[source]

Bases: object

This object represents a bot command.

Variables:
  • command (str) – Text of the command; 1-32 characters. Can contain only lowercase English letters, digits and underscores.

  • description (str) – Description of the command; 1-256 characters

  • is_ephemeral (bool | None) – True, if the command sends an ephemeral message, which can be seen only by the sender of the message and the bot

command: str = ''
description: str = ''
classmethod from_dict(data: dict | None) BotCommand | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

is_ephemeral: bool | None = None
to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

class peyk.platforms.telegram.BotCommandScopeAllChatAdministrators(type: str = 'all_chat_administrators')[source]

Bases: object

Represents the scope of bot commands, covering all group and supergroup chat administrators.

Variables:

type (str) – Scope type, must be all_chat_administrators

classmethod from_dict(data: dict | None) BotCommandScopeAllChatAdministrators | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

type: str = 'all_chat_administrators'
class peyk.platforms.telegram.BotCommandScopeAllGroupChats(type: str = 'all_group_chats')[source]

Bases: object

Represents the scope of bot commands, covering all group and supergroup chats.

Variables:

type (str) – Scope type, must be all_group_chats

classmethod from_dict(data: dict | None) BotCommandScopeAllGroupChats | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

type: str = 'all_group_chats'
class peyk.platforms.telegram.BotCommandScopeAllPrivateChats(type: str = 'all_private_chats')[source]

Bases: object

Represents the scope of bot commands, covering all private chats.

Variables:

type (str) – Scope type, must be all_private_chats

classmethod from_dict(data: dict | None) BotCommandScopeAllPrivateChats | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

type: str = 'all_private_chats'
class peyk.platforms.telegram.BotCommandScopeChat(type: str = 'chat', chat_id: int | str = 0)[source]

Bases: object

Represents the scope of bot commands, covering a specific chat.

Variables:
  • type (str) – Scope type, must be chat

  • chat_id (int | str) – Unique identifier for the target chat or username of the target supergroup in the format @username. Channel direct messages chats and channel chats aren’t supported.

chat_id: int | str = 0
classmethod from_dict(data: dict | None) BotCommandScopeChat | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

type: str = 'chat'
class peyk.platforms.telegram.BotCommandScopeChatAdministrators(type: str = 'chat_administrators', chat_id: int | str = 0)[source]

Bases: object

Represents the scope of bot commands, covering all administrators of a specific group or supergroup chat.

Variables:
  • type (str) – Scope type, must be chat_administrators

  • chat_id (int | str) – Unique identifier for the target chat or username of the target supergroup in the format @username. Channel direct messages chats and channel chats aren’t supported.

chat_id: int | str = 0
classmethod from_dict(data: dict | None) BotCommandScopeChatAdministrators | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

type: str = 'chat_administrators'
class peyk.platforms.telegram.BotCommandScopeChatMember(type: str = 'chat_member', chat_id: int | str = 0, user_id: int = 0)[source]

Bases: object

Represents the scope of bot commands, covering a specific member of a group or supergroup chat.

Variables:
  • type (str) – Scope type, must be chat_member

  • chat_id (int | str) – Unique identifier for the target chat or username of the target supergroup in the format @username. Channel direct messages chats and channel chats aren’t supported.

  • user_id (int) – Unique identifier of the target user

chat_id: int | str = 0
classmethod from_dict(data: dict | None) BotCommandScopeChatMember | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

type: str = 'chat_member'
user_id: int = 0
class peyk.platforms.telegram.BotCommandScopeDefault(type: str = 'default')[source]

Bases: object

Represents the default scope of bot commands. Default commands are used if no commands with a narrower scope are specified for the user.

Variables:

type (str) – Scope type, must be default

classmethod from_dict(data: dict | None) BotCommandScopeDefault | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

type: str = 'default'
class peyk.platforms.telegram.BotCommandScopeType(*values)[source]

Bases: str, Enum

BotCommandScopeType defines a public API type for peyk.

DEFAULT = 'default'
ALL_PRIVATE_CHATS = 'all_private_chats'
ALL_GROUP_CHATS = 'all_group_chats'
ALL_CHAT_ADMINISTRATORS = 'all_chat_administrators'
CHAT = 'chat'
CHAT_ADMINISTRATORS = 'chat_administrators'
CHAT_MEMBER = 'chat_member'
class peyk.platforms.telegram.BotDescription(description: str = '')[source]

Bases: object

This object represents the bot’s description.

Variables:

description (str) – The bot’s description

description: str = ''
classmethod from_dict(data: dict | None) BotDescription | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

class peyk.platforms.telegram.BotName(name: str = '')[source]

Bases: object

This object represents the bot’s name.

Variables:

name (str) – The bot’s name

classmethod from_dict(data: dict | None) BotName | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

name: str = ''
class peyk.platforms.telegram.BotShortDescription(short_description: str = '')[source]

Bases: object

This object represents the bot’s short description.

Variables:

short_description (str) – The bot’s short description

classmethod from_dict(data: dict | None) BotShortDescription | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

short_description: str = ''
class peyk.platforms.telegram.BotSubscriptionUpdated(user: User, invoice_payload: str, state: str)[source]

Bases: object

This object contains information about changes to a user payment subscription toward the current bot.

Variables:
  • user (peyk.platforms.telegram.types.user.User) – User who subscribed for payments toward the bot

  • invoice_payload (str) – Bot-specified invoice payload

  • state (str) – The new state of the subscription. Currently, it can be one of ‘canceled’ if the user canceled the subscription, ‘active’ if the user re-enabled a previously canceled subscription, or ‘failed’ if payment for the subscription failed.

classmethod from_dict(data)
subscription = None
user: User
invoice_payload: str
state: str
class peyk.platforms.telegram.BotSubscriptionUpdatedState(*values)[source]

Bases: str, Enum

BotSubscriptionUpdatedState defines a public API type for peyk.

ACTIVE = 'active'
CANCELLED = 'cancelled'
PENDING = 'pending'
class peyk.platforms.telegram.BusinessBotRights(can_reply: bool | None = None, can_delete_outgoing_messages: bool | None = None, can_edit_messages: bool | None = None, can_delete_all_messages: bool | None = None, can_post_stories: bool | None = None, can_edit_stories: bool | None = None, can_delete_stories: bool | None = None, can_read_messages: bool | None = None, can_change_gift_settings: bool | None = None, can_transfer_and_upgrade_gifts: bool | None = None, can_convert_gift_to_stars: bool | None = None, can_transfer_stars: bool | None = None, can_manage_connected_bots: bool | None = None)[source]

Bases: object

Represents the rights of a business bot.

Variables:
  • can_reply (bool | None) – True, if the bot can send and edit messages in the private chats that had incoming messages in the last 24 hours

  • can_read_messages (bool | None) – True, if the bot can mark incoming private messages as read

  • can_delete_sent_messages – True, if the bot can delete messages sent by the bot

  • can_delete_all_messages (bool | None) – True, if the bot can delete all private messages in managed chats

  • can_edit_name – True, if the bot can edit the first and last name of the business account

  • can_edit_bio – True, if the bot can edit the bio of the business account

  • can_edit_profile_photo – True, if the bot can edit the profile photo of the business account

  • can_edit_username – True, if the bot can edit the username of the business account

  • can_change_gift_settings (bool | None) – True, if the bot can change the privacy settings pertaining to gifts for the business account

  • can_view_gifts_and_stars – True, if the bot can view gifts and the amount of Telegram Stars owned by the business account

  • can_convert_gifts_to_stars – True, if the bot can convert regular gifts owned by the business account to Telegram Stars

  • can_transfer_and_upgrade_gifts (bool | None) – True, if the bot can transfer and upgrade gifts owned by the business account

  • can_transfer_stars (bool | None) – True, if the bot can transfer Telegram Stars received by the business account to its own account, or use them to upgrade and transfer gifts

  • can_manage_stories – True, if the bot can post, edit and delete stories on behalf of the business account

  • can_delete_outgoing_messages (bool | None) – True, if the bot can delete messages sent by the bot

can_change_gift_settings: bool | None = None
can_convert_gift_to_stars: bool | None = None
can_delete_all_messages: bool | None = None
can_delete_outgoing_messages: bool | None = None
can_delete_stories: bool | None = None
can_edit_messages: bool | None = None
can_edit_stories: bool | None = None
can_manage_connected_bots: bool | None = None
can_post_stories: bool | None = None
can_read_messages: bool | None = None
can_reply: bool | None = None
can_transfer_and_upgrade_gifts: bool | None = None
can_transfer_stars: bool | None = None
classmethod from_dict(data: dict | None) BusinessBotRights | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

class peyk.platforms.telegram.BusinessConnection(id: str, user: User, user_chat_id: int, date: int, is_enabled: bool, rights: BusinessBotRights | None = None)[source]

Bases: object

Describes the connection of the bot with a business account.

Variables:
  • id (str) – Unique identifier of the business connection

  • user (peyk.platforms.telegram.types.user.User) – Business account user that created the business connection

  • user_chat_id (int) – Identifier of a private chat with the user who created the business connection. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a 64-bit integer or double-precision float type are safe for storing this identifier.

  • date (int) – Date the connection was established in Unix time

  • is_enabled (bool) – True, if the connection is active

  • rights (peyk.platforms.telegram.types.business_bot_rights.BusinessBotRights | None) – Rights of the business bot

  • can_reply – True, if the bot can act on behalf of the business account in chats that were active in the last 24 hours

can_reply = None
classmethod from_dict(data)
rights: BusinessBotRights | None = None
id: str
user: User
user_chat_id: int
date: int
is_enabled: bool
class peyk.platforms.telegram.BusinessIntro(title: str | None = None, message: str | None = None, sticker: Sticker | None = None)[source]

Bases: object

Contains information about the start page settings of a Telegram Business account.

Variables:
classmethod from_dict(data: dict | None) BusinessIntro | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

message: str | None = None
sticker: Sticker | None = None
title: str | None = None
class peyk.platforms.telegram.BusinessLocation(address: str, location: Location | None = None)[source]

Bases: object

Contains information about the location of a Telegram Business account.

Variables:
classmethod from_dict(data: dict | None) BusinessLocation | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

location: Location | None = None
address: str
class peyk.platforms.telegram.BusinessMessagesDeleted(business_connection_id: str, chat: Chat, message_ids: List[int])[source]

Bases: object

This object is received when messages are deleted from a connected business account.

Variables:
  • business_connection_id (str) – Unique identifier of the business connection

  • chat (peyk.platforms.telegram.types.chat.Chat) – Information about a chat in the business account. The bot may not have access to the chat or the corresponding user.

  • message_ids (List[int]) – The list of identifiers of deleted messages in the chat of the business account

classmethod from_dict(data: dict | None) BusinessMessagesDeleted | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

business_connection_id: str
chat: Chat
message_ids: List[int]
class peyk.platforms.telegram.BusinessOpeningHours(time_zone_name: str, opening_hours: List[BusinessOpeningHoursInterval])[source]

Bases: object

Describes the opening hours of a business.

Variables:
classmethod from_dict(data: dict | None) BusinessOpeningHours | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

time_zone_name: str
opening_hours: List[BusinessOpeningHoursInterval]
class peyk.platforms.telegram.BusinessOpeningHoursInterval(opening_minute: int, closing_minute: int)[source]

Bases: object

Describes an interval of time during which a business is open.

Variables:
  • opening_minute (int) – The minute’s sequence number in a week, starting on Monday, marking the start of the time interval during which the business is open; 0 - 7 24 60

  • closing_minute (int) – The minute’s sequence number in a week, starting on Monday, marking the end of the time interval during which the business is open; 0 - 8 24 60

classmethod from_dict(data: dict | None) BusinessOpeningHoursInterval | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

opening_minute: int
closing_minute: int
class peyk.platforms.telegram.ButtonStyle(*values)[source]

Bases: str, Enum

ButtonStyle defines a public API type for peyk.

PRIMARY = 'primary'
SUCCESS = 'success'
DANGER = 'danger'
class peyk.platforms.telegram.CallbackGame[source]

Bases: object

Placeholder – currently holds no information (game is set up via BotFather; full games surface is a later phase).

classmethod from_dict(data: dict | None) CallbackGame | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

class peyk.platforms.telegram.CallbackQuery(id: str = '', from_: User | None = None, message: Message | InaccessibleMessage | None = None, inline_message_id: str | None = None, chat_instance: str | None = None, data: str | None = None, game_short_name: str | None = None)[source]

Bases: object

This object represents an incoming callback query from a callback button in an inline keyboard. If the button that originated the query was attached to a message sent by the bot, the field message will be present. If the button was attached to a message sent via the bot (in inline mode), the field inline_message_id will be present. Exactly one of the fields data or game_short_name will be present. NOTE: After the user presses a callback button, Telegram clients will display a progress bar until you call answerCallbackQuery. It is, therefore, necessary to react by calling answerCallbackQuery even if no notification to the user is needed (e.g., without specifying any of the optional parameters).

Variables:
  • id (str) – Unique identifier for this query

  • from – Sender

  • chat_instance (str | None) – Global identifier, uniquely corresponding to the chat to which the message with the callback button was sent. Useful for high scores in games.

  • message (peyk.platforms.telegram.types.message.Message | peyk.platforms.telegram.types.inaccessible_message.InaccessibleMessage | None) – Message sent by the bot with the callback button that originated the query

  • inline_message_id (str | None) – Identifier of the message sent via the bot in inline mode, that originated the query

  • data (str | None) – Data associated with the callback button. Be aware that the message originated the query can contain no callback buttons with this data.

  • game_short_name (str | None) – Short name of a Game to be returned, serves as the unique identifier for the game

chat_instance: str | None = None
data: str | None = None
from_: User | None = None
classmethod from_dict(data: dict | None) CallbackQuery | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

game_short_name: str | None = None
id: str = ''
inline_message_id: str | None = None
message: Message | InaccessibleMessage | None = None
class peyk.platforms.telegram.Chat(id: int, type: str, title: str | None = None, username: str | None = None, first_name: str | None = None, last_name: str | None = None, is_forum: bool | None = None)[source]

Bases: object

This object represents a chat.

Variables:
  • id (int) – Unique identifier for this chat. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this identifier.

  • type (str) – Type of the chat, can be either ‘private’, ‘group’, ‘supergroup’ or ‘channel’

  • title (str | None) – Title, for supergroups, channels and group chats

  • username (str | None) – Username, for private chats, supergroups and channels if available

  • first_name (str | None) – First name of the other party in a private chat

  • last_name (str | None) – Last name of the other party in a private chat

  • is_forum (bool | None) – True, if the supergroup chat is a forum (has topics enabled)

  • is_direct_messages – True, if the chat is the direct messages chat of a channel

  • accent_color_id – Identifier of the accent color for the chat name and backgrounds of the chat photo, reply header, and link preview. See accent colors for more details. Returned only in getChat. Always returned in getChat.

  • active_usernames – If non-empty, the list of all active chat usernames; for private chats, supergroups and channels. Returned only in getChat.

  • available_reactions – List of available reactions allowed in the chat. If omitted, then all emoji reactions are allowed. Returned only in getChat.

  • background_custom_emoji_id – Custom emoji identifier of emoji chosen by the chat for the reply header and link preview background. Returned only in getChat.

  • bio – Bio of the other party in a private chat. Returned only in getChat.

  • birthdate – For private chats, the date of birth of the user. Returned only in getChat.

  • business_intro – For private chats with business accounts, the intro of the business. Returned only in getChat.

  • business_location – For private chats with business accounts, the location of the business. Returned only in getChat.

  • business_opening_hours – For private chats with business accounts, the opening hours of the business. Returned only in getChat.

  • can_set_sticker_set – True, if the bot can change the group sticker set. Returned only in getChat.

  • custom_emoji_sticker_set_name – For supergroups, the name of the group’s custom emoji sticker set. Custom emoji from this set can be used by all users and bots in the group. Returned only in getChat.

  • description – Description, for groups, supergroups and channel chats. Returned only in getChat.

  • emoji_status_custom_emoji_id – Custom emoji identifier of the emoji status of the chat or the other party in a private chat. Returned only in getChat.

  • emoji_status_expiration_date – Expiration date of the emoji status of the chat or the other party in a private chat, in Unix time, if any. Returned only in getChat.

  • has_aggressive_anti_spam_enabled – True, if aggressive anti-spam checks are enabled in the supergroup. The field is only available to chat administrators. Returned only in getChat.

  • has_hidden_members – True, if non-administrators can only get the list of bots and administrators in the chat. Returned only in getChat.

  • has_private_forwards – True, if privacy settings of the other party in the private chat allows to use tg://user?id= links only in chats with the user. Returned only in getChat.

  • has_protected_content – True, if messages from the chat can’t be forwarded to other chats. Returned only in getChat.

  • has_restricted_voice_and_video_messages – True, if the privacy settings of the other party restrict sending voice and video note messages in the private chat. Returned only in getChat.

  • has_visible_history – True, if new chat members will have access to old messages; available only to chat administrators. Returned only in getChat.

  • invite_link – Primary invite link, for groups, supergroups and channel chats. Returned only in getChat.

  • join_by_request – True, if all users directly joining the supergroup need to be approved by supergroup administrators. Returned only in getChat.

  • join_to_send_messages – True, if users need to join the supergroup before they can send messages. Returned only in getChat.

  • linked_chat_id – Unique identifier for the linked chat, i.e. the discussion group identifier for a channel and vice versa; for supergroups and channel chats. This identifier may be greater than 32 bits and some programming languages may have difficulty/silent defects in interpreting it. But it is smaller than 52 bits, so a signed 64 bit integer or double-precision float type are safe for storing this identifier. Returned only in getChat.

  • location – For supergroups, the location to which the supergroup is connected. Returned only in getChat.

  • message_auto_delete_time – The time after which all messages sent to the chat will be automatically deleted; in seconds. Returned only in getChat.

  • permissions – Default chat member permissions, for groups and supergroups. Returned only in getChat.

  • personal_chat – For private chats, the personal channel of the user. Returned only in getChat.

  • photo – Chat photo. Returned only in getChat.

  • pinned_message – The most recent pinned message (by sending date). Returned only in getChat.

  • profile_accent_color_id – Identifier of the accent color for the chat’s profile background. See profile accent colors for more details. Returned only in getChat.

  • profile_background_custom_emoji_id – Custom emoji identifier of the emoji chosen by the chat for its profile background. Returned only in getChat.

  • slow_mode_delay – For supergroups, the minimum allowed delay between consecutive messages sent by each unprivileged user; in seconds. Returned only in getChat.

  • sticker_set_name – For supergroups, name of group sticker set. Returned only in getChat.

  • unrestrict_boost_count – For supergroups, the minimum number of boosts that a non-administrator user needs to add in order to ignore slow mode and chat permissions. Returned only in getChat.

first_name: str | None = None
classmethod from_dict(data: dict | None) Chat | None[source]

Parse a Telegram API mapping into this type.

Parameters:

data – Raw Telegram API mapping, or None.

Returns:

Parsed type instance, or None when data is None.

is_forum: bool | None = None
last_name: str | None = None
title: str | None = None
username: str | None = None
id: int
type: str
class peyk.platforms.telegram.ChatAdministratorRights(is_anonymous: bool | None = None, can_manage_chat: bool | None = None, can_delete_messages: bool | None = None, can_manage_video_chats: bool | None = None, can_restrict_members: bool | None = None, can_promote_members: bool | None = None, can_change_info: bool | None = None, can_invite_users: bool | None = None, can_post_stories: bool | None = None, can_edit_stories: bool | None = None, can_delete_stories: bool | None = None, can_post_messages: bool | None = None, can_edit_messages: bool | None = None, can_pin_messages: bool | None = None, can_manage_topics: bool | None = None, can_manage_direct_messages: bool | None = None, can_manage_tags: bool | None = None, can_send_welcome_messages: bool | None = None)[source]

Bases: object

Represents the rights of an administrator in a chat.

Variables:
  • is_anonymous (bool | None) – True, if the user’s presence in the chat is hidden

  • can_manage_chat (bool | None) – True, if the administrator can access the chat event log, get boost list, see hidden supergroup and channel members, report spam messages, ignore slow mode, and send messages to the chat without paying Telegram Stars. Implied by any other administrator privilege.

  • can_delete_messages (bool | None) – True, if the administrator can delete messages of other users

  • can_manage_video_chats (bool | None) – True, if the administrator can manage video chats

  • can_restrict_members (bool | None) – True, if the administrator can restrict, ban or unban chat members, or access supergroup statistics

  • can_promote_members (bool | None) – True, if the administrator can add new administrators with a subset of their own privileges or demote administrators that they have promoted, directly or indirectly (promoted by administrators that were appointed by the user)

  • can_change_info (bool | None) – True, if the user is allowed to change the chat title, photo and other settings

  • can_invite_users (bool | None) – True, if the user is allowed to invite new users to the chat

  • can_post_stories (bool | None) – True, if the administrator can post stories to the chat

  • can_edit_stories (bool | None) – True, if the administrator can edit stories posted by other users, post stories to the chat page, pin chat stories, and access the chat’s story archive

  • can_delete_stories (bool | None) – True, if the administrator can delete stories posted by other users

  • can_post_messages (bool | None) – True, if the administrator can post messages in the channel, approve suggested posts, or access channel statistics; for channels only

  • can_edit_messages (bool | None) – True, if the administrator can edit messages of other users and can pin messages; for channels only

  • can_pin_messages (bool | None) – True, if the user is allowed to pin messages; for groups and supergroups only

  • can_manage_topics (bool | None) – True, if the user is allowed to create, rename, close, and reopen forum topics; for supergroups only

  • can_manage_direct_messages (bool | None) – True, if the administrator can manage direct messages of the channel and decline suggested posts; for channels only

  • can_manage_tags (bool | None) – True, if the administrator can edit the tags of regular members; for groups and supergroups only. If omitted, defaults to the value of can_pin_messages.

can_change_info: bool | None = None
can_delete_messages: bool | None = None
can_delete_stories: bool | None = None
can_edit_messages: bool | None = None
can_edit_stories: bool | None = None
can_invite_users: bool | None = None
can_manage_chat: bool | None = None
can_manage_direct_messages: bool | None = None
can_manage_tags: bool | None = None
can_manage_topics: bool | None = None
can_manage_video_chats: bool | None = None
can_pin_messages: bool | None = None
can_post_messages: bool | None = None
can_post_stories: bool | None = None
can_promote_members: bool | None = None
can_restrict_members: bool | None = None
can_send_welcome_messages: bool | None = None
classmethod from_dict(data: dict | None) ChatAdministratorRights | None[source]

Parse a Telegram API mapping into this type.

Parameters:

data – Raw Telegram API mapping, or None.

Returns:

Parsed type instance, or None when data is None.

is_anonymous: bool | None = None
to_dict() Dict[str, object][source]

Serialize this type to the Telegram API request shape.

Returns:

A JSON-compatible mapping representing this value.

class peyk.platforms.telegram.ChatBackground(type: BackgroundTypeFill | BackgroundTypeWallpaper | BackgroundTypePattern | BackgroundTypeChatTheme | None = None)[source]

Bases: object

This object represents a chat background.

Variables:

type (peyk.platforms.telegram.types.background_type_fill.BackgroundTypeFill | peyk.platforms.telegram.types.background_type_wallpaper.BackgroundTypeWallpaper | peyk.platforms.telegram.types.background_type_pattern.BackgroundTypePattern | peyk.platforms.telegram.types.background_type_chat_theme.BackgroundTypeChatTheme | None) – Type of the background

classmethod from_dict(data: dict | None) ChatBackground | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

type: BackgroundTypeFill | BackgroundTypeWallpaper | BackgroundTypePattern | BackgroundTypeChatTheme | None = None
class peyk.platforms.telegram.ChatBoost(boost_id: str, add_date: int, expiration_date: int, source: ChatBoostSource)[source]

Bases: object

This object contains information about a chat boost.

Variables:
  • boost_id (str) – Unique identifier of the boost

  • add_date (int) – Point in time (Unix timestamp) when the chat was boosted

  • expiration_date (int) – Point in time (Unix timestamp) when the boost will automatically expire, unless the booster’s Telegram Premium subscription is prolonged

  • source (peyk.platforms.telegram.types.chat_boost_source.ChatBoostSource) – Source of the added boost

classmethod from_dict(data: dict | None) ChatBoost | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

boost_id: str
add_date: int
expiration_date: int
source: ChatBoostSource
class peyk.platforms.telegram.ChatBoostAdded(boost_count: int)[source]

Bases: object

This object represents a service message about a user boosting a chat.

Variables:

boost_count (int) – Number of boosts added by the user

classmethod from_dict(data: dict | None) ChatBoostAdded | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

boost_count: int
class peyk.platforms.telegram.ChatBoostRemoved(chat: Chat, boost_id: str, remove_date: int, source: ChatBoostSource)[source]

Bases: object

This object represents a boost removed from a chat.

Variables:
classmethod from_dict(data: dict | None) ChatBoostRemoved | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

chat: Chat
boost_id: str
remove_date: int
source: ChatBoostSource
class peyk.platforms.telegram.ChatBoostSource(source: str = '', user: User | None = None)[source]

Bases: object

Chat boost source (union alias).

classmethod from_dict(data: dict | None) ChatBoostSource | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

source: str = ''
user: User | None = None
class peyk.platforms.telegram.ChatBoostSourceGiftCode(source: str, user: User)[source]

Bases: object

The boost was obtained by the creation of Telegram Premium gift codes to boost a chat. Each such code boosts the chat 4 times for the duration of the corresponding Telegram Premium subscription.

Variables:
classmethod from_dict(data: dict | None) ChatBoostSourceGiftCode | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

source: str
user: User
class peyk.platforms.telegram.ChatBoostSourceGiveaway(source: str, giveaway_message_id: int, user: User | None = None, prize_star_count: int | None = None, is_unclaimed: bool | None = None)[source]

Bases: object

The boost was obtained by the creation of a Telegram Premium or a Telegram Star giveaway. This boosts the chat 4 times for the duration of the corresponding Telegram Premium subscription for Telegram Premium giveaways and prize_star_count / 500 times for one year for Telegram Star giveaways.

Variables:
  • source (str) – Source of the boost, always ‘giveaway’

  • giveaway_message_id (int) – Identifier of a message in the chat with the giveaway; the message could have been deleted already. May be 0 if the message isn’t sent yet.

  • user (peyk.platforms.telegram.types.user.User | None) – User that won the prize in the giveaway if any; for Telegram Premium giveaways only

  • prize_star_count (int | None) – The number of Telegram Stars to be split between giveaway winners; for Telegram Star giveaways only

  • is_unclaimed (bool | None) – True, if the giveaway was completed, but there was no user to win the prize

classmethod from_dict(data: dict | None) ChatBoostSourceGiveaway | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

is_unclaimed: bool | None = None
prize_star_count: int | None = None
user: User | None = None
source: str
giveaway_message_id: int
class peyk.platforms.telegram.ChatBoostSourcePremium(source: str, user: User)[source]

Bases: object

The boost was obtained by subscribing to Telegram Premium or by gifting a Telegram Premium subscription to another user.

Variables:
classmethod from_dict(data: dict | None) ChatBoostSourcePremium | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

source: str
user: User
class peyk.platforms.telegram.ChatBoostSourceType(*values)[source]

Bases: StrEnum

Telegram chat-boost source discriminator values.

PREMIUM = 'premium'
GIFT_CODE = 'gift_code'
GIVEAWAY = 'giveaway'
class peyk.platforms.telegram.ChatBoostUpdated(chat: Chat, boost: ChatBoost)[source]

Bases: object

This object represents a boost added to a chat or changed.

Variables:
classmethod from_dict(data: dict | None) ChatBoostUpdated | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

chat: Chat
boost: ChatBoost
class peyk.platforms.telegram.ChatFullInfo(id: int, type: str, title: str | None = None, username: str | None = None, first_name: str | None = None, last_name: str | None = None, is_forum: bool | None = None, accent_color_id: int | None = None, max_reaction_count: int | None = None, photo: ChatPhoto | None = None, active_usernames: List[str] | None = None, description: str | None = None, invite_link: str | None = None, pinned_message: Message | None = None, permissions: object | None = None, slow_mode_delay: int | None = None, message_auto_delete_time: int | None = None, has_protected_content: bool | None = None, has_visible_history: bool | None = None, sticker_set_name: str | None = None, can_set_sticker_set: bool | None = None, linked_chat_id: int | None = None, location: object | None = None)[source]

Bases: object

This object contains full information about a chat.

Variables:
  • id (int) – Unique identifier for this chat. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this identifier.

  • type (str) – Type of the chat, can be either ‘private’, ‘group’, ‘supergroup’ or ‘channel’

  • accent_color_id (int | None) – Identifier of the accent color for the chat name and backgrounds of the chat photo, reply header, and link preview. See accent colors for more details.

  • max_reaction_count (int | None) – The maximum number of reactions that can be set on a message in the chat

  • accepted_gift_types – Information about types of gifts that are accepted by the chat or by the corresponding user for private chats

  • title (str | None) – Title, for supergroups, channels and group chats

  • username (str | None) – Username, for private chats, supergroups and channels if available

  • first_name (str | None) – First name of the other party in a private chat

  • last_name (str | None) – Last name of the other party in a private chat

  • is_forum (bool | None) – True, if the supergroup chat is a forum (has topics enabled)

  • is_direct_messages – True, if the chat is the direct messages chat of a channel

  • photo (peyk.platforms.telegram.types.chat_photo.ChatPhoto | None) – Chat photo

  • active_usernames (List[str] | None) – If non-empty, the list of all active chat usernames; for private chats, supergroups and channels

  • birthdate – For private chats, the date of birth of the user

  • business_intro – For private chats with business accounts, the intro of the business

  • business_location – For private chats with business accounts, the location of the business

  • business_opening_hours – For private chats with business accounts, the opening hours of the business

  • personal_chat – For private chats, the personal channel of the user

  • parent_chat – Information about the corresponding channel chat; for direct messages chats only

  • available_reactions – List of available reactions allowed in the chat. If omitted, then all emoji reactions are allowed.

  • background_custom_emoji_id – Custom emoji identifier of the emoji chosen by the chat for the reply header and link preview background

  • profile_accent_color_id – Identifier of the accent color for the chat’s profile background. See profile accent colors for more details.

  • profile_background_custom_emoji_id – Custom emoji identifier of the emoji chosen by the chat for its profile background

  • emoji_status_custom_emoji_id – Custom emoji identifier of the emoji status of the chat or the other party in a private chat

  • emoji_status_expiration_date – Expiration date of the emoji status of the chat or the other party in a private chat, in Unix time, if any

  • bio – Bio of the other party in a private chat

  • has_private_forwards – True, if privacy settings of the other party in the private chat allows to use tg://user?id= links only in chats with the user

  • has_restricted_voice_and_video_messages – True, if the privacy settings of the other party restrict sending voice and video note messages in the private chat

  • join_to_send_messages – True, if users need to join the supergroup before they can send messages

  • join_by_request – True, if all users directly joining the supergroup without using an invite link need to be approved by supergroup administrators

  • description (str | None) – Description, for groups, supergroups and channel chats

  • invite_link (str | None) – Primary invite link, for groups, supergroups and channel chats

  • pinned_message (peyk.platforms.telegram.types.message.Message | None) – The most recent pinned message (by sending date)

  • permissions (object | None) – Default chat member permissions, for groups and supergroups

  • can_send_paid_media – True, if paid media messages can be sent or forwarded to the channel chat. The field is available only for channel chats.

  • slow_mode_delay (int | None) – For supergroups, the minimum allowed delay between consecutive messages sent by each unprivileged user; in seconds

  • unrestrict_boost_count – For supergroups, the minimum number of boosts that a non-administrator user needs to add in order to ignore slow mode and chat permissions

  • message_auto_delete_time (int | None) – The time after which all messages sent to the chat will be automatically deleted; in seconds

  • has_aggressive_anti_spam_enabled – True, if aggressive anti-spam checks are enabled in the supergroup. The field is only available to chat administrators.

  • has_hidden_members – True, if non-administrators can only get the list of bots and administrators in the chat

  • has_protected_content (bool | None) – True, if messages from the chat can’t be forwarded to other chats

  • has_visible_history (bool | None) – True, if new chat members will have access to old messages; available only to chat administrators

  • sticker_set_name (str | None) – For supergroups, name of the group sticker set

  • can_set_sticker_set (bool | None) – True, if the bot can change the group sticker set

  • custom_emoji_sticker_set_name – For supergroups, the name of the group’s custom emoji sticker set. Custom emoji from this set can be used by all users and bots in the group.

  • linked_chat_id (int | None) – Unique identifier for the linked chat, i.e. the discussion group identifier for a channel and vice versa; for supergroups and channel chats. This identifier may be greater than 32 bits and some programming languages may have difficulty/silent defects in interpreting it. But it is smaller than 52 bits, so a signed 64 bit integer or double-precision float type are safe for storing this identifier.

  • location (object | None) – For supergroups, the location to which the supergroup is connected

  • rating – For private chats, the rating of the user if any

  • first_profile_audio – For private chats, the first audio added to the profile of the user

  • unique_gift_colors – The color scheme based on a unique gift that must be used for the chat’s name, message replies and link previews

  • paid_message_star_count – The number of Telegram Stars a general user has to pay to send a message to the chat

  • guard_bot – The bot that processes join request queries in the chat. The field is only available to chat administrators.

  • community – The Community to which the chat belongs

  • can_send_gift – True, if gifts can be sent to the chat

accent_color_id: int | None = None
active_usernames: List[str] | None = None
can_set_sticker_set: bool | None = None
community = None
description: str | None = None
first_name: str | None = None
classmethod from_dict(data)
guard_bot = None
has_protected_content: bool | None = None
has_visible_history: bool | None = None
is_forum: bool | None = None
last_name: str | None = None
linked_chat_id: int | None = None
location: object | None = None
max_reaction_count: int | None = None
message_auto_delete_time: int | None = None
permissions: object | None = None
photo: ChatPhoto | None = None
pinned_message: Message | None = None
slow_mode_delay: int | None = None
sticker_set_name: str | None = None
title: str | None = None
username: str | None = None
id: int
type: str

Bases: object

Represents an invite link for a chat.

Variables:
  • invite_link (str) – The invite link. If the link was created by another chat administrator, then the second part of the link will be replaced with ‘…’.

  • creator (peyk.platforms.telegram.types.user.User | None) – Creator of the link

  • creates_join_request (bool | None) – True, if users joining the chat via the link need to be approved by chat administrators

  • is_primary (bool | None) – True, if the link is primary

  • is_revoked (bool | None) – True, if the link is revoked

  • name (str | None) – Invite link name

  • expire_date (int | None) – Point in time (Unix timestamp) when the link will expire or has been expired

  • member_limit (int | None) – The maximum number of users that can be members of the chat simultaneously after joining the chat via this invite link; 1-99999

  • pending_join_request_count (int | None) – Number of pending join requests created using this link

  • subscription_period (int | None) – The number of seconds the subscription will be active for before the next payment

  • subscription_price (int | None) – The amount of Telegram Stars a user must pay initially and after each subsequent subscription period to be a member of the chat using the link

creates_join_request: bool | None = None
creator: User | None = None
expire_date: int | None = None
classmethod from_dict(data: dict | None) ChatInviteLink | None[source]

Parse a Telegram API mapping into this type.

Parameters:

data – Raw Telegram API mapping, or None.

Returns:

Parsed type instance, or None when data is None.

is_primary: bool | None = None
is_revoked: bool | None = None
member_limit: int | None = None
name: str | None = None
pending_join_request_count: int | None = None
subscription_period: int | None = None
subscription_price: int | None = None
class peyk.platforms.telegram.ChatJoinRequest(chat: Chat, from_: User | None = None, user_chat_id: int | None = None, date: int | None = None, bio: str | None = None, invite_link: ChatInviteLink | None = None, query_id: str | None = None, bot: 'Bot[object]' | None = None)[source]

Bases: object

Represents a join request sent to a chat.

Variables:
  • chat (Chat) – Chat to which the request was sent

  • from – User that sent the join request

  • user_chat_id (Optional[int]) – Identifier of a private chat with the user who sent the join request. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a 64-bit integer or double-precision float type are safe for storing this identifier. The bot can use this identifier for 5 minutes to send messages until the join request is processed, assuming no other administrator contacted the user.

  • date (Optional[int]) – Date the request was sent in Unix time

  • bio (Optional[str]) – Bio of the user

  • invite_link (Optional[ChatInviteLink]) – Chat invite link that was used by the user to send the join request

  • query_id (Optional[str]) – Identifier of the join request query; for bots assigned to process join requests only. If present, then the bot must call sendChatJoinRequestWebApp or directly call answerChatJoinRequestQuery within 10 seconds.

async approve() bool[source]

Approve this join request through the injected bot.

bio: str | None = None
bot: 'Bot[object]' | None = None
date: int | None = None
async decline() bool[source]

Decline this join request through the injected bot.

from_: User | None = None
classmethod from_dict(data: dict | None) ChatJoinRequest | None[source]

Parse a Telegram API mapping into this type.

Parameters:

data – Raw Telegram API mapping, or None.

Returns:

Parsed type instance, or None when data is None.

query_id: str | None = None
user_chat_id: int | None = None
chat: Chat
class peyk.platforms.telegram.ChatLocation(location: Location | None = None, address: str = '')[source]

Bases: object

Represents a location to which a chat is connected.

Variables:
address: str = ''
classmethod from_dict(data: dict | None) ChatLocation | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

location: Location | None = None
class peyk.platforms.telegram.ChatMemberAdministrator(status: str = 'administrator', user: User | None = None, can_be_edited: bool | None = None, is_anonymous: bool | None = None, can_manage_chat: bool | None = None, can_delete_messages: bool | None = None, can_manage_video_chats: bool | None = None, can_restrict_members: bool | None = None, can_promote_members: bool | None = None, can_change_info: bool | None = None, can_invite_users: bool | None = None, can_post_stories: bool | None = None, can_edit_stories: bool | None = None, can_delete_stories: bool | None = None, can_post_messages: bool | None = None, can_edit_messages: bool | None = None, can_pin_messages: bool | None = None, can_manage_topics: bool | None = None, can_manage_direct_messages: bool | None = None, can_manage_tags: bool | None = None, can_send_welcome_messages: bool | None = None, custom_title: str | None = None)[source]

Bases: object

Represents a chat member that has some additional privileges.

Variables:
  • status (str) – The member’s status in the chat, always ‘administrator’

  • user (peyk.platforms.telegram.types.user.User | None) – Information about the user

  • can_be_edited (bool | None) – True, if the bot is allowed to edit administrator privileges of that user

  • is_anonymous (bool | None) – True, if the user’s presence in the chat is hidden

  • can_manage_chat (bool | None) – True, if the administrator can access the chat event log, get boost list, see hidden supergroup and channel members, report spam messages, ignore slow mode, and send messages to the chat without paying Telegram Stars. Implied by any other administrator privilege.

  • can_delete_messages (bool | None) – True, if the administrator can delete messages of other users

  • can_manage_video_chats (bool | None) – True, if the administrator can manage video chats

  • can_restrict_members (bool | None) – True, if the administrator can restrict, ban or unban chat members, or access supergroup statistics

  • can_promote_members (bool | None) – True, if the administrator can add new administrators with a subset of their own privileges or demote administrators that they have promoted, directly or indirectly (promoted by administrators that were appointed by the user)

  • can_change_info (bool | None) – True, if the user is allowed to change the chat title, photo and other settings

  • can_invite_users (bool | None) – True, if the user is allowed to invite new users to the chat

  • can_post_stories (bool | None) – True, if the administrator can post stories to the chat

  • can_edit_stories (bool | None) – True, if the administrator can edit stories posted by other users, post stories to the chat page, pin chat stories, and access the chat’s story archive

  • can_delete_stories (bool | None) – True, if the administrator can delete stories posted by other users

  • can_post_messages (bool | None) – True, if the administrator can post messages in the channel, approve suggested posts, or access channel statistics; for channels only

  • can_edit_messages (bool | None) – True, if the administrator can edit messages of other users and can pin messages; for channels only

  • can_pin_messages (bool | None) – True, if the user is allowed to pin messages; for groups and supergroups only

  • can_manage_topics (bool | None) – True, if the user is allowed to create, rename, close, and reopen forum topics; for supergroups only

  • can_manage_direct_messages (bool | None) – True, if the administrator can manage direct messages of the channel and decline suggested posts; for channels only

  • can_manage_tags (bool | None) – True, if the administrator can edit the tags of regular members; for groups and supergroups only. If omitted, defaults to the value of can_pin_messages.

  • custom_title (str | None) – Custom title for this user

can_be_edited: bool | None = None
can_change_info: bool | None = None
can_delete_messages: bool | None = None
can_delete_stories: bool | None = None
can_edit_messages: bool | None = None
can_edit_stories: bool | None = None
can_invite_users: bool | None = None
can_manage_chat: bool | None = None
can_manage_direct_messages: bool | None = None
can_manage_tags: bool | None = None
can_manage_topics: bool | None = None
can_manage_video_chats: bool | None = None
can_pin_messages: bool | None = None
can_post_messages: bool | None = None
can_post_stories: bool | None = None
can_promote_members: bool | None = None
can_restrict_members: bool | None = None
can_send_welcome_messages: bool | None = None
custom_title: str | None = None
classmethod from_dict(data: dict | None) ChatMemberAdministrator | None[source]

Parse a Telegram API mapping into this type.

Parameters:

data – Raw Telegram API mapping, or None.

Returns:

Parsed type instance, or None when data is None.

is_anonymous: bool | None = None
status: str = 'administrator'
user: User | None = None
class peyk.platforms.telegram.ChatMemberBanned(status: str = 'kicked', user: User | None = None, until_date: int | None = None)[source]

Bases: object

Represents a chat member that was banned in the chat and can’t return to the chat or view chat messages.

Variables:
  • status (str) – The member’s status in the chat, always ‘kicked’

  • user (peyk.platforms.telegram.types.user.User | None) – Information about the user

  • until_date (int | None) – Date when restrictions will be lifted for this user; Unix time. If 0, then the user is banned forever.

classmethod from_dict(data: dict | None) ChatMemberBanned | None[source]

Parse a Telegram API mapping into this type.

Parameters:

data – Raw Telegram API mapping, or None.

Returns:

Parsed type instance, or None when data is None.

status: str = 'kicked'
until_date: int | None = None
user: User | None = None
class peyk.platforms.telegram.ChatMemberLeft(status: str = 'left', user: User | None = None)[source]

Bases: object

Represents a chat member that isn’t currently a member of the chat, but may join it themselves.

Variables:
classmethod from_dict(data: dict | None) ChatMemberLeft | None[source]

Parse a Telegram API mapping into this type.

Parameters:

data – Raw Telegram API mapping, or None.

Returns:

Parsed type instance, or None when data is None.

status: str = 'left'
user: User | None = None
class peyk.platforms.telegram.ChatMemberMember(status: str = 'member', user: User | None = None, tag: str | None = None, until_date: int | None = None)[source]

Bases: object

Represents a chat member that has no additional privileges or restrictions.

Variables:
  • status (str) – The member’s status in the chat, always ‘member’

  • user (peyk.platforms.telegram.types.user.User | None) – Information about the user

  • tag (str | None) – Tag of the member

  • until_date (int | None) – Date when the user’s subscription will expire; Unix time

classmethod from_dict(data: dict | None) ChatMemberMember | None[source]

Parse a Telegram API mapping into this type.

Parameters:

data – Raw Telegram API mapping, or None.

Returns:

Parsed type instance, or None when data is None.

status: str = 'member'
tag: str | None = None
until_date: int | None = None
user: User | None = None
class peyk.platforms.telegram.ChatMemberOwner(status: str = 'creator', user: User | None = None, is_anonymous: bool | None = None, custom_title: str | None = None)[source]

Bases: object

Represents a chat member that owns the chat and has all administrator privileges.

Variables:
  • status (str) – The member’s status in the chat, always ‘creator’

  • user (peyk.platforms.telegram.types.user.User | None) – Information about the user

  • is_anonymous (bool | None) – True, if the user’s presence in the chat is hidden

  • custom_title (str | None) – Custom title for this user

custom_title: str | None = None
classmethod from_dict(data: dict | None) ChatMemberOwner | None[source]

Parse a Telegram API mapping into this type.

Parameters:

data – Raw Telegram API mapping, or None.

Returns:

Parsed type instance, or None when data is None.

is_anonymous: bool | None = None
status: str = 'creator'
user: User | None = None
class peyk.platforms.telegram.ChatMemberRestricted(status: str = 'restricted', user: User | None = None, tag: str | None = None, is_member: bool | None = None, can_send_messages: bool | None = None, can_send_audios: bool | None = None, can_send_documents: bool | None = None, can_send_photos: bool | None = None, can_send_videos: bool | None = None, can_send_video_notes: bool | None = None, can_send_voice_notes: bool | None = None, can_send_polls: bool | None = None, can_send_other_messages: bool | None = None, can_add_web_page_previews: bool | None = None, can_react_to_messages: bool | None = None, can_edit_tag: bool | None = None, can_change_info: bool | None = None, can_invite_users: bool | None = None, can_pin_messages: bool | None = None, can_manage_topics: bool | None = None, until_date: int | None = None)[source]

Bases: object

Represents a chat member that is under certain restrictions in the chat. Supergroups only.

Variables:
  • status (str) – The member’s status in the chat, always ‘restricted’

  • user (peyk.platforms.telegram.types.user.User | None) – Information about the user

  • is_member (bool | None) – True, if the user is a member of the chat at the moment of the request

  • can_send_messages (bool | None) – True, if the user is allowed to send text messages, rich messages, contacts, giveaways, giveaway winners, invoices, locations and venues

  • can_send_audios (bool | None) – True, if the user is allowed to send audios

  • can_send_documents (bool | None) – True, if the user is allowed to send documents

  • can_send_photos (bool | None) – True, if the user is allowed to send photos

  • can_send_videos (bool | None) – True, if the user is allowed to send videos

  • can_send_video_notes (bool | None) – True, if the user is allowed to send video notes

  • can_send_voice_notes (bool | None) – True, if the user is allowed to send voice notes

  • can_send_polls (bool | None) – True, if the user is allowed to send polls and checklists

  • can_send_other_messages (bool | None) – True, if the user is allowed to send animations, games, stickers and use inline bots

  • can_add_web_page_previews (bool | None) – True, if the user is allowed to add web page previews to their messages

  • can_react_to_messages (bool | None) – True, if the user is allowed to react to messages

  • can_edit_tag (bool | None) – True, if the user is allowed to edit their own tag

  • can_change_info (bool | None) – True, if the user is allowed to change the chat title, photo and other settings

  • can_invite_users (bool | None) – True, if the user is allowed to invite new users to the chat

  • can_pin_messages (bool | None) – True, if the user is allowed to pin messages

  • can_manage_topics (bool | None) – True, if the user is allowed to create forum topics

  • until_date (int | None) – Date when restrictions will be lifted for this user; Unix time. If 0, then the user is restricted forever.

  • tag (str | None) – Tag of the member

can_add_web_page_previews: bool | None = None
can_change_info: bool | None = None
can_edit_tag: bool | None = None
can_invite_users: bool | None = None
can_manage_topics: bool | None = None
can_pin_messages: bool | None = None
can_react_to_messages: bool | None = None
can_send_audios: bool | None = None
can_send_documents: bool | None = None
can_send_messages: bool | None = None
can_send_other_messages: bool | None = None
can_send_photos: bool | None = None
can_send_polls: bool | None = None
can_send_video_notes: bool | None = None
can_send_videos: bool | None = None
can_send_voice_notes: bool | None = None
classmethod from_dict(data: dict | None) ChatMemberRestricted | None[source]

Parse a Telegram API mapping into this type.

Parameters:

data – Raw Telegram API mapping, or None.

Returns:

Parsed type instance, or None when data is None.

is_member: bool | None = None
status: str = 'restricted'
tag: str | None = None
until_date: int | None = None
user: User | None = None
class peyk.platforms.telegram.ChatMemberStatus(*values)[source]

Bases: StrEnum

Finite status values used by Telegram’s ChatMember union.

CREATOR = 'creator'
ADMINISTRATOR = 'administrator'
MEMBER = 'member'
RESTRICTED = 'restricted'
LEFT = 'left'
KICKED = 'kicked'
class peyk.platforms.telegram.ChatMemberUpdated(chat: Chat, from_: User | None = None, date: int | None = None, old_chat_member: ChatMemberOwner | ChatMemberAdministrator | ChatMemberMember | ChatMemberRestricted | ChatMemberLeft | ChatMemberBanned | None = None, new_chat_member: ChatMemberOwner | ChatMemberAdministrator | ChatMemberMember | ChatMemberRestricted | ChatMemberLeft | ChatMemberBanned | None = None, invite_link: ChatInviteLink | None = None, via_join_request: bool | None = None, via_chat_folder_invite_link: bool | None = None)[source]

Bases: object

This object represents changes in the status of a chat member.

Variables:
date: int | None = None
from_: User | None = None
classmethod from_dict(data: dict | None) ChatMemberUpdated | None[source]

Parse a Telegram API mapping into this type.

Parameters:

data – Raw Telegram API mapping, or None.

Returns:

Parsed type instance, or None when data is None.

new_chat_member: ChatMemberOwner | ChatMemberAdministrator | ChatMemberMember | ChatMemberRestricted | ChatMemberLeft | ChatMemberBanned | None = None
old_chat_member: ChatMemberOwner | ChatMemberAdministrator | ChatMemberMember | ChatMemberRestricted | ChatMemberLeft | ChatMemberBanned | None = None
via_join_request: bool | None = None
chat: Chat
class peyk.platforms.telegram.ChatOwnerChanged(from_user: User | None = None, to_user: User | None = None)[source]

Bases: object

Describes a service message about an ownership change in the chat.

Variables:

new_owner – The new owner of the chat

classmethod from_dict(data: dict | None) ChatOwnerChanged | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

from_user: User | None = None
to_user: User | None = None
class peyk.platforms.telegram.ChatOwnerLeft(user: User | None = None)[source]

Bases: object

Describes a service message about the chat owner leaving the chat.

Variables:

new_owner – The user who will become the new owner of the chat if the previous owner does not return to the chat

classmethod from_dict(data: dict | None) ChatOwnerLeft | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

user: User | None = None
class peyk.platforms.telegram.ChatPermissions(can_send_messages: bool | None = None, can_send_audios: bool | None = None, can_send_documents: bool | None = None, can_send_photos: bool | None = None, can_send_videos: bool | None = None, can_send_video_notes: bool | None = None, can_send_voice_notes: bool | None = None, can_send_polls: bool | None = None, can_send_other_messages: bool | None = None, can_add_web_page_previews: bool | None = None, can_react_to_messages: bool | None = None, can_edit_tag: bool | None = None, can_change_info: bool | None = None, can_invite_users: bool | None = None, can_pin_messages: bool | None = None, can_manage_topics: bool | None = None)[source]

Bases: object

Describes actions that a non-administrator user is allowed to take in a chat.

Variables:
  • can_send_messages (bool | None) – True, if the user is allowed to send text messages, rich messages, contacts, giveaways, giveaway winners, invoices, locations and venues

  • can_send_audios (bool | None) – True, if the user is allowed to send audios

  • can_send_documents (bool | None) – True, if the user is allowed to send documents

  • can_send_photos (bool | None) – True, if the user is allowed to send photos

  • can_send_videos (bool | None) – True, if the user is allowed to send videos

  • can_send_video_notes (bool | None) – True, if the user is allowed to send video notes

  • can_send_voice_notes (bool | None) – True, if the user is allowed to send voice notes

  • can_send_polls (bool | None) – True, if the user is allowed to send polls and checklists

  • can_send_other_messages (bool | None) – True, if the user is allowed to send animations, games, stickers and use inline bots

  • can_add_web_page_previews (bool | None) – True, if the user is allowed to add web page previews to their messages

  • can_react_to_messages (bool | None) – True, if the user is allowed to react to messages. If omitted, defaults to the value of can_send_messages.

  • can_edit_tag (bool | None) – True, if the user is allowed to edit their own tag. If omitted, defaults to the value of can_pin_messages.

  • can_change_info (bool | None) – True, if the user is allowed to change the chat title, photo and other settings. Ignored in public supergroups.

  • can_invite_users (bool | None) – True, if the user is allowed to invite new users to the chat

  • can_pin_messages (bool | None) – True, if the user is allowed to pin messages. Ignored in public supergroups.

  • can_manage_topics (bool | None) – True, if the user is allowed to create forum topics. If omitted, defaults to the value of can_pin_messages.

can_add_web_page_previews: bool | None = None
can_change_info: bool | None = None
can_edit_tag: bool | None = None
can_invite_users: bool | None = None
can_manage_topics: bool | None = None
can_pin_messages: bool | None = None
can_react_to_messages: bool | None = None
can_send_audios: bool | None = None
can_send_documents: bool | None = None
can_send_messages: bool | None = None
can_send_other_messages: bool | None = None
can_send_photos: bool | None = None
can_send_polls: bool | None = None
can_send_video_notes: bool | None = None
can_send_videos: bool | None = None
can_send_voice_notes: bool | None = None
classmethod from_dict(data: dict | None) ChatPermissions | None[source]

Parse a Telegram API mapping into this type.

Parameters:

data – Raw Telegram API mapping, or None.

Returns:

Parsed type instance, or None when data is None.

to_dict() Dict[str, object][source]

Serialize this type to the Telegram API request shape.

Returns:

A JSON-compatible mapping representing this value.

class peyk.platforms.telegram.ChatPhoto(small_file_id: str, small_file_unique_id: str, big_file_id: str, big_file_unique_id: str)[source]

Bases: object

This object represents a chat photo.

Variables:
  • small_file_id (str) – File identifier of small (160x160) chat photo. This file_id can be used only for photo download and only for as long as the photo is not changed.

  • small_file_unique_id (str) – Unique file identifier of small (160x160) chat photo, which is supposed to be the same over time and for different bots. Can’t be used to download or reuse the file.

  • big_file_id (str) – File identifier of big (640x640) chat photo. This file_id can be used only for photo download and only for as long as the photo is not changed.

  • big_file_unique_id (str) – Unique file identifier of big (640x640) chat photo, which is supposed to be the same over time and for different bots. Can’t be used to download or reuse the file.

classmethod from_dict(data: dict | None) ChatPhoto | None[source]

Parse a Telegram API mapping into this type.

Parameters:

data – Raw Telegram API mapping, or None.

Returns:

Parsed type instance, or None when data is None.

small_file_id: str
small_file_unique_id: str
big_file_id: str
big_file_unique_id: str
class peyk.platforms.telegram.ChatShared(request_id: int = 0, chat_id: int = 0, title: str | None = None, username: str | None = None, photo: List[PhotoSize] | None = None)[source]

Bases: object

This object contains information about a chat that was shared with the bot using a KeyboardButtonRequestChat button.

Variables:
  • request_id (int) – Identifier of the request

  • chat_id (int) – Identifier of the shared chat. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a 64-bit integer or double-precision float type are safe for storing this identifier. The bot may not have access to the chat and could be unable to use this identifier, unless the chat is already known to the bot by some other means.

  • title (str | None) – Title of the chat, if the title was requested by the bot

  • username (str | None) – Username of the chat, if the username was requested by the bot and available

  • photo (List[peyk.platforms.telegram.types.photo_size.PhotoSize] | None) – Available sizes of the chat photo, if the photo was requested by the bot

chat_id: int = 0
classmethod from_dict(data: dict | None) ChatShared | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

photo: List[PhotoSize] | None = None
request_id: int = 0
title: str | None = None
username: str | None = None
class peyk.platforms.telegram.ChatType(*values)[source]

Bases: StrEnum

Finite Telegram chat-type values.

PRIVATE = 'private'
GROUP = 'group'
SUPERGROUP = 'supergroup'
CHANNEL = 'channel'
class peyk.platforms.telegram.Checklist(title: str = '', tasks: List[ChecklistTask] | None = None, others_can_add_tasks: bool | None = None, others_can_mark_tasks_as_done: bool | None = None)[source]

Bases: object

Describes a checklist.

Variables:
  • title (str) – Title of the checklist

  • tasks (List[peyk.platforms.telegram.types.checklist_task.ChecklistTask] | None) – List of tasks in the checklist

  • title_entities – Special entities that appear in the checklist title

  • others_can_add_tasks (bool | None) – True, if users other than the creator of the list can add tasks to the list

  • others_can_mark_tasks_as_done (bool | None) – True, if users other than the creator of the list can mark tasks as done or not done

classmethod from_dict(data: dict | None) Checklist | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

others_can_add_tasks: bool | None = None
others_can_mark_tasks_as_done: bool | None = None
tasks: List[ChecklistTask] | None = None
title: str = ''
class peyk.platforms.telegram.ChecklistTask(id: int = 0, text: str = '', text_entities: List[MessageEntity] | None = None, completed_by_user: User | None = None, completion_date: int | None = None)[source]

Bases: object

Describes a task in a checklist.

Variables:
  • id (int) – Unique identifier of the task

  • text (str) – Text of the task

  • text_entities (List[peyk.platforms.telegram.types.message_entity.MessageEntity] | None) – Special entities that appear in the task text

  • completed_by_user (peyk.platforms.telegram.types.user.User | None) – User that completed the task; omitted if the task wasn’t completed by a user

  • completed_by_chat – Chat that completed the task; omitted if the task wasn’t completed by a chat

  • completion_date (int | None) – Point in time (Unix timestamp) when the task was completed; 0 if the task wasn’t completed

completed_by_user: User | None = None
completion_date: int | None = None
classmethod from_dict(data: dict | None) ChecklistTask | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

id: int = 0
text: str = ''
text_entities: List[MessageEntity] | None = None
class peyk.platforms.telegram.ChecklistTasksAdded(checklist_message: Message | None = None, tasks: List[ChecklistTask] | None = None)[source]

Bases: object

Describes a service message about tasks added to a checklist.

Variables:
checklist_message: Message | None = None
classmethod from_dict(data: dict | None) ChecklistTasksAdded | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

tasks: List[ChecklistTask] | None = None
class peyk.platforms.telegram.ChecklistTasksDone(checklist_message: Message | None = None, tasks: List[ChecklistTask] | None = None, completed_tasks: List[ChecklistTask] | None = None)[source]

Bases: object

Describes a service message about checklist tasks marked as done or not done.

Variables:
  • checklist_message (peyk.platforms.telegram.types.message.Message | None) – Message containing the checklist whose tasks were marked as done or not done. Note that the Message object in this field will not contain the reply_to_message field even if it itself is a reply.

  • marked_as_done_task_ids – Identifiers of the tasks that were marked as done

  • marked_as_not_done_task_ids – Identifiers of the tasks that were marked as not done

checklist_message: Message | None = None
completed_tasks: List[ChecklistTask] | None = None
classmethod from_dict(data: dict | None) ChecklistTasksDone | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

tasks: List[ChecklistTask] | None = None
class peyk.platforms.telegram.ChosenInlineResult(result_id: str, from_: User | None = None, location: Location | None = None, inline_message_id: str | None = None, query: str = '')[source]

Bases: object

Represents a result of an inline query that was chosen by the user and sent to their chat partner. Note: It is necessary to enable inline feedback via @BotFather in order to receive these objects in updates.

Variables:
  • result_id (str) – The unique identifier for the result that was chosen

  • from – The user that chose the result

  • query (str) – The query that was used to obtain the result

  • location (peyk.platforms.telegram.types.location.Location | None) – Sender location, only for bots that require user location

  • inline_message_id (str | None) – Identifier of the sent inline message. Available only if there is an inline keyboard attached to the message. Will be also received in callback queries and can be used to edit the message.

from_: User | None = None
classmethod from_dict(data: dict | None) ChosenInlineResult | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

inline_message_id: str | None = None
location: Location | None = None
query: str = ''
result_id: str
class peyk.platforms.telegram.Community(id: int = 0, title: str = '', bot: User | None = None, name: str | None = None)[source]

Bases: object

Represents a community (a group of chats).

Variables:
  • id (int) – Unique identifier for this community. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this identifier.

  • name (str | None) – Name of the community

bot: User | None = None
classmethod from_dict(data: dict | None) Community | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

id: int = 0
name: str | None = None
title: str = ''
class peyk.platforms.telegram.CommunityChatAdded(chat_id: int = 0, community: Community | None = None)[source]

Bases: object

Describes a service message about a chat being added to a community.

Variables:

community (peyk.platforms.telegram.types.community.Community | None) – The new community to which the chat belongs

chat_id: int = 0
community: Community | None = None
classmethod from_dict(data: dict | None) CommunityChatAdded | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

class peyk.platforms.telegram.CommunityChatJoined(chat_id: int = 0, community: Community | None = None)[source]

Bases: object

CommunityChatJoined Telegram Bot API type.

chat_id: int = 0
community: Community | None = None
classmethod from_dict(data: dict | None) CommunityChatJoined | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

class peyk.platforms.telegram.CommunityChatRemoved(chat_id: int = 0)[source]

Bases: object

CommunityChatRemoved Telegram Bot API type.

chat_id: int = 0
classmethod from_dict(data: dict | None) CommunityChatRemoved | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

class peyk.platforms.telegram.Contact(phone_number: str, first_name: str, last_name: str | None = None, user_id: int | None = None, vcard: str | None = None)[source]

Bases: object

This object represents a phone contact.

Variables:
  • phone_number (str) – Contact’s phone number

  • first_name (str) – Contact’s first name

  • last_name (str | None) – Contact’s last name

  • user_id (int | None) – Contact’s user identifier in Telegram. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a 64-bit integer or double-precision float type are safe for storing this identifier.

  • vcard (str | None) – Additional data about the contact in the form of a vCard

classmethod from_dict(data: dict | None) Contact | None[source]

Parse a Telegram API mapping into this type.

Parameters:

data – Raw Telegram API mapping, or None.

Returns:

Parsed type instance, or None when data is None.

last_name: str | None = None
user_id: int | None = None
vcard: str | None = None
phone_number: str
first_name: str
class peyk.platforms.telegram.CopyTextButton(text: str = '')[source]

Bases: object

This object represents an inline keyboard button that copies specified text to the clipboard.

Variables:

text (str) – The text to be copied to the clipboard; 1-256 characters

classmethod from_dict(data: dict | None) CopyTextButton | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

text: str = ''
to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

class peyk.platforms.telegram.Currency(*values)[source]

Bases: str, Enum

Currency defines a public API type for peyk.

XTR = 'XTR'
class peyk.platforms.telegram.Dice(emoji: str, value: int)[source]

Bases: object

This object represents an animated emoji that displays a random value.

Variables:
  • emoji (str) – Emoji on which the dice throw animation is based

  • value (int) – Value of the dice, 1-6 for ‘’, ‘’ and ‘’ base emoji, 1-5 for ‘’ and ‘’ base emoji, 1-64 for ‘’ base emoji

classmethod from_dict(data: dict | None) Dice | None[source]

Parse a Telegram API mapping into this type.

Parameters:

data – Raw Telegram API mapping, or None.

Returns:

Parsed type instance, or None when data is None.

emoji: str
value: int
class peyk.platforms.telegram.DiceEmoji(*values)[source]

Bases: str, Enum

DiceEmoji defines a public API type for peyk.

DICE = '🎲'
DARTS = '🎯'
BASKETBALL = '🏀'
FOOTBALL = '⚽'
SLOT_MACHINE = '🎰'
BOWLING = '🎳'
class peyk.platforms.telegram.DirectMessagePriceChanged(is_paid_direct_messages: bool | None = None)[source]

Bases: object

Describes a service message about a change in the price of direct messages sent to a channel chat.

Variables:
  • are_direct_messages_enabled – True, if direct messages are enabled for the channel chat; False otherwise

  • direct_message_star_count – The new number of Telegram Stars that must be paid by users for each direct message sent to the channel. Does not apply to users who have been exempted by administrators. Defaults to 0.

classmethod from_dict(data: dict | None) DirectMessagePriceChanged | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

is_paid_direct_messages: bool | None = None
class peyk.platforms.telegram.DirectMessagesTopic(topic_id: int | None = None, user: User | None = None)[source]

Bases: object

Describes a topic of a direct messages chat.

Variables:
  • topic_id (int | None) – Unique identifier of the topic. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a 64-bit integer or double-precision float type are safe for storing this identifier.

  • user (peyk.platforms.telegram.types.user.User | None) – Information about the user that created the topic. Currently, it is always present.

classmethod from_dict(data: dict | None) DirectMessagesTopic | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

topic_id: int | None = None
user: User | None = None
class peyk.platforms.telegram.DisabledButton[source]

Bases: object

Newer addition – marks an inline button disabled (does nothing). Currently holds no information.

classmethod from_dict(data: dict | None) DisabledButton | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

class peyk.platforms.telegram.Document(file_id: str, file_unique_id: str, thumbnail: PhotoSize | None = None, file_name: str | None = None, mime_type: str | None = None, file_size: int | None = None)[source]

Bases: object

This object represents a general file (as opposed to photos, voice messages and audio files).

Variables:
  • file_id (str) – Identifier for this file, which can be used to download or reuse the file

  • file_unique_id (str) – Unique identifier for this file, which is supposed to be the same over time and for different bots. Can’t be used to download or reuse the file.

  • thumbnail (peyk.platforms.telegram.types.photo_size.PhotoSize | None) – Document thumbnail as defined by the sender

  • file_name (str | None) – Original filename as defined by the sender

  • mime_type (str | None) – MIME type of the file as defined by the sender

  • file_size (int | None) – File size in bytes. It can be bigger than 2^31 and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this value.

file_name: str | None = None
file_size: int | None = None
classmethod from_dict(data: dict | None) Document | None[source]

Parse a Telegram API mapping into this type.

Parameters:

data – Raw Telegram API mapping, or None.

Returns:

Parsed type instance, or None when data is None.

mime_type: str | None = None
thumbnail: PhotoSize | None = None
file_id: str
file_unique_id: str
class peyk.platforms.telegram.EncryptedCredentials(data: str, hash: str, secret: str)[source]

Bases: object

Describes data required for decrypting and authenticating EncryptedPassportElement. See the Telegram Passport Documentation for a complete description of the data decryption and authentication processes.

Variables:
  • data (str) – Base64-encoded encrypted JSON-serialized data with unique user’s payload, data hashes and secrets required for EncryptedPassportElement decryption and authentication

  • hash (str) – Base64-encoded data hash for data authentication

  • secret (str) – Base64-encoded secret, encrypted with the bot’s public RSA key, required for data decryption

classmethod from_dict(data: dict | None) EncryptedCredentials | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

data: str
hash: str
secret: str
class peyk.platforms.telegram.EncryptedPassportElement(*values)[source]

Bases: str, Enum

EncryptedPassportElement defines a public API type for peyk.

DATA = 'data'
FRONT_SIDE = 'front_side'
REVERSE_SIDE = 'reverse_side'
SELFIE = 'selfie'
FILES = 'files'
TRANSLATION = 'translation'
UTILITY_BILL = 'utility_bill'
class peyk.platforms.telegram.EphemeralMessageParameters(receiver_user_id: int | None = None, callback_query_id: str | None = None, replace_callback_query_message: bool | None = None)[source]

Bases: object

Ephemeral message parameters.

callback_query_id: str | None = None
classmethod from_dict(data: dict | None) EphemeralMessageParameters | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

receiver_user_id: int | None = None
replace_callback_query_message: bool | None = None
class peyk.platforms.telegram.ExternalReplyInfo(origin: object | None = None, chat: Chat | None = None, message_id: int | None = None, link_preview_options: object | None = None, animation: object | None = None, audio: object | None = None, document: object | None = None, photo: object | None = None, sticker: object | None = None, story: object | None = None, video: object | None = None, video_note: object | None = None, voice: object | None = None, live_photo: object | None = None, has_media_spoiler: bool | None = None, contact: object | None = None, dice: object | None = None, game: object | None = None, giveaway: object | None = None, giveaway_winners: object | None = None, invoice: object | None = None, location: object | None = None, poll: object | None = None, venue: object | None = None, quote: TextQuote | None = None)[source]

Bases: object

This object contains information about a message that is being replied to, which may come from another chat or forum topic.

Variables:
  • origin (object | None) – Origin of the message replied to by the given message

  • chat (peyk.platforms.telegram.types.chat.Chat | None) – Chat the original message belongs to. Available only if the chat is a supergroup or a channel.

  • message_id (int | None) – Unique message identifier inside the original chat. Available only if the original chat is a supergroup or a channel.

  • link_preview_options (object | None) – Options used for link preview generation for the original message, if it is a text message

  • animation (object | None) – Message is an animation, information about the animation

  • audio (object | None) – Message is an audio file, information about the file

  • document (object | None) – Message is a general file, information about the file

  • live_photo (object | None) – Message is a live photo, information about the live photo

  • paid_media – Message contains paid media; information about the paid media

  • photo (object | None) – Message is a photo, available sizes of the photo

  • sticker (object | None) – Message is a sticker, information about the sticker

  • story (object | None) – Message is a forwarded story

  • video (object | None) – Message is a video, information about the video

  • video_note (object | None) – Message is a video note, information about the video message

  • voice (object | None) – Message is a voice message, information about the file

  • has_media_spoiler (bool | None) – True, if the message media is covered by a spoiler animation

  • checklist – Message is a checklist

  • contact (object | None) – Message is a shared contact, information about the contact

  • dice (object | None) – Message is a dice with random value

  • game (object | None) – Message is a game, information about the game.

  • giveaway (object | None) – Message is a scheduled giveaway, information about the giveaway

  • giveaway_winners (object | None) – A giveaway with public winners was completed

  • invoice (object | None) – Message is an invoice for a payment, information about the invoice.

  • location (object | None) – Message is a shared location, information about the location

  • poll (object | None) – Message is a native poll, information about the poll

  • venue (object | None) – Message is a venue, information about the venue

animation: object | None = None
audio: object | None = None
chat: Chat | None = None
contact: object | None = None
dice: object | None = None
document: object | None = None
classmethod from_dict(data: dict | None) ExternalReplyInfo | None[source]

Parse a Telegram API mapping into this type.

Parameters:

data – Raw Telegram API mapping, or None.

Returns:

Parsed type instance, or None when data is None.

game: object | None = None
giveaway: object | None = None
giveaway_winners: object | None = None
has_media_spoiler: bool | None = None
invoice: object | None = None
live_photo: object | None = None
location: object | None = None
message_id: int | None = None
origin: object | None = None
photo: object | None = None
poll: object | None = None
quote: TextQuote | None = None
sticker: object | None = None
story: object | None = None
venue: object | None = None
video: object | None = None
video_note: object | None = None
voice: object | None = None
class peyk.platforms.telegram.File(file_id: str, file_unique_id: str, file_size: int | None = None, file_path: str | None = None)[source]

Bases: object

This object represents a file ready to be downloaded. The file can be downloaded via the link https://api.telegram.org/file/bot/. It is guaranteed that the link will be valid for at least 1 hour. When the link expires, a new one can be requested by calling getFile. The maximum file size to download is 20 MB

Variables:
  • file_id (str) – Identifier for this file, which can be used to download or reuse the file

  • file_unique_id (str) – Unique identifier for this file, which is supposed to be the same over time and for different bots. Can’t be used to download or reuse the file.

  • file_size (int | None) – File size in bytes. It can be bigger than 2^31 and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this value.

  • file_path (str | None) – File path. Use https://api.telegram.org/file/bot/ to get the file.

file_path: str | None = None
file_size: int | None = None
classmethod from_dict(data: dict | None) File | None[source]

Parse a Telegram API mapping into this type.

Parameters:

data – Raw Telegram API mapping, or None.

Returns:

Parsed type instance, or None when data is None.

file_id: str
file_unique_id: str
class peyk.platforms.telegram.ForceReply(force_reply: bool = True, input_field_placeholder: str | None = None, selective: bool | None = None)[source]

Bases: object

Upon receiving a message with this object, Telegram clients will display a reply interface to the user (act as if the user has selected the bot’s message and tapped ‘Reply’). This can be extremely useful if you want to create user-friendly step-by-step interfaces without having to sacrifice privacy mode. Not supported in channels and for messages sent on behalf of a user account. Example: A poll bot for groups runs in privacy mode (only receives commands, replies to its messages and mentions). There could be two ways to create a new poll:

Explain the user how to send a command with parameters (e.g. /newpoll question answer1 answer2). May be appealing for hardcore users but lacks modern day polish. Guide the user through a step-by-step process. ‘Please send me your question’, ‘Cool, now let’s add the first answer option’, ‘Great. Keep adding answer options, then send /done when you’re ready’. The last option is definitely more attractive. And if you use ForceReply in your bot’s questions, it will receive the user’s answers even if it only receives replies, commands and mentions - without any extra work for the user.

Variables:
  • force_reply (bool) – Shows reply interface to the user, as if they manually selected the bot’s message and tapped ‘Reply’

  • input_field_placeholder (str | None) – The placeholder to be shown in the input field when the reply is active; 1-64 characters

  • selective (bool | None) – Use this parameter if you want to force reply from specific users only. Targets: 1) users that are @mentioned in the text of the Message object; 2) if the bot’s message is a reply to a message in the same chat and forum topic, sender of the original message.

force_reply: bool = True
classmethod from_dict(data: dict | None) ForceReply | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

input_field_placeholder: str | None = None
selective: bool | None = None
to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

class peyk.platforms.telegram.ForumTopic(message_thread_id: int, name: str, icon_color: int | None = None, icon_custom_emoji_id: str | None = None, is_name_implicit: bool | None = None)[source]

Bases: object

This object represents a forum topic.

Variables:
  • message_thread_id (int) – Unique identifier of the forum topic

  • name (str) – Name of the topic

  • icon_color (int | None) – Color of the topic icon in RGB format

  • icon_custom_emoji_id (str | None) – Unique identifier of the custom emoji shown as the topic icon

  • is_name_implicit (bool | None) – True, if the name of the topic wasn’t specified explicitly by its creator and likely needs to be changed by the bot

classmethod from_dict(data: dict | None) ForumTopic | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

icon_color: int | None = None
icon_custom_emoji_id: str | None = None
is_name_implicit: bool | None = None
message_thread_id: int
name: str
class peyk.platforms.telegram.ForumTopicClosed[source]

Bases: object

ForumTopicClosed Telegram Bot API type.

classmethod from_dict(data: dict | None) ForumTopicClosed | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

class peyk.platforms.telegram.ForumTopicCreated(name: str = '', icon_color: int | None = None, icon_custom_emoji_id: str | None = None, is_name_implicit: bool | None = None)[source]

Bases: object

This object represents a service message about a new forum topic created in the chat.

Variables:
  • name (str) – Name of the topic

  • icon_color (int | None) – Color of the topic icon in RGB format

  • icon_custom_emoji_id (str | None) – Unique identifier of the custom emoji shown as the topic icon

  • is_name_implicit (bool | None) – True, if the name of the topic wasn’t specified explicitly by its creator and likely needs to be changed by the bot

classmethod from_dict(data: dict | None) ForumTopicCreated | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

icon_color: int | None = None
icon_custom_emoji_id: str | None = None
is_name_implicit: bool | None = None
name: str = ''
class peyk.platforms.telegram.ForumTopicEdited(name: str | None = None, icon_custom_emoji_id: str | None = None)[source]

Bases: object

This object represents a service message about an edited forum topic.

Variables:
  • name (str | None) – New name of the topic, if it was edited

  • icon_custom_emoji_id (str | None) – New identifier of the custom emoji shown as the topic icon, if it was edited; an empty string if the icon was removed

classmethod from_dict(data: dict | None) ForumTopicEdited | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

icon_custom_emoji_id: str | None = None
name: str | None = None
class peyk.platforms.telegram.ForumTopicReopened[source]

Bases: object

ForumTopicReopened Telegram Bot API type.

classmethod from_dict(data: dict | None) ForumTopicReopened | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

class peyk.platforms.telegram.Game(title: str, description: str, photo: List[PhotoSize], text: str | None = None, text_entities: List[MessageEntity] | None = None, animation: Animation | None = None)[source]

Bases: object

This object represents a game. Use BotFather to create and edit games, their short names will act as unique identifiers.

Variables:
  • title (str) – Title of the game

  • description (str) – Description of the game

  • photo (List[peyk.platforms.telegram.types.photo_size.PhotoSize]) – Photo that will be displayed in the game message in chats

  • text (str | None) – Brief description of the game or high scores included in the game message. Can be automatically edited to include current high scores for the game when the bot calls setGameScore, or manually edited using editMessageText. 0-4096 characters.

  • text_entities (List[peyk.platforms.telegram.types.message_entity.MessageEntity] | None) – Special entities that appear in text, such as usernames, URLs, bot commands, etc.

  • animation (peyk.platforms.telegram.types.animation.Animation | None) – Animation that will be displayed in the game message in chats. Upload via BotFather.

animation: Animation | None = None
classmethod from_dict(data: dict | None) Game | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

text: str | None = None
text_entities: List[MessageEntity] | None = None
title: str
description: str
photo: List[PhotoSize]
class peyk.platforms.telegram.GameHighScore(position: int, user: User, score: int)[source]

Bases: object

This object represents one row of the high scores table for a game. And that’s about all we’ve got for now. If you’ve got any questions, please check out our Bot FAQ

Variables:
classmethod from_dict(data: dict | None) GameHighScore | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

position: int
user: User
score: int
class peyk.platforms.telegram.GeneralForumTopicHidden[source]

Bases: object

GeneralForumTopicHidden Telegram Bot API type.

classmethod from_dict(data: dict | None) GeneralForumTopicHidden | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

class peyk.platforms.telegram.GeneralForumTopicUnhidden[source]

Bases: object

GeneralForumTopicUnhidden Telegram Bot API type.

classmethod from_dict(data: dict | None) GeneralForumTopicUnhidden | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

class peyk.platforms.telegram.Gift(id: str, sticker: Sticker, star_count: int, upgrade_star_count: int | None = None, is_premium: bool | None = None, has_colors: bool | None = None, total_count: int | None = None, remaining_count: int | None = None, personal_total_count: int | None = None, personal_remaining_count: int | None = None, background: GiftBackground | None = None, unique_gift_variant_count: int | None = None, publisher_chat: Chat | None = None)[source]

Bases: object

This object represents a gift that can be sent by the bot.

Variables:
  • id (str) – Unique identifier of the gift

  • sticker (peyk.platforms.telegram.types.sticker.Sticker) – The sticker that represents the gift

  • star_count (int) – The number of Telegram Stars that must be paid to send the sticker

  • upgrade_star_count (int | None) – The number of Telegram Stars that must be paid to upgrade the gift to a unique one

  • is_premium (bool | None) – True, if the gift can only be purchased by Telegram Premium subscribers

  • has_colors (bool | None) – True, if the gift can be used (after being upgraded) to customize a user’s appearance

  • total_count (int | None) – The total number of gifts of this type that can be sent by all users; for limited gifts only

  • remaining_count (int | None) – The number of remaining gifts of this type that can be sent by all users; for limited gifts only

  • personal_total_count (int | None) – The total number of gifts of this type that can be sent by the bot; for limited gifts only

  • personal_remaining_count (int | None) – The number of remaining gifts of this type that can be sent by the bot; for limited gifts only

  • background (peyk.platforms.telegram.types.gift_background.GiftBackground | None) – Background of the gift

  • unique_gift_variant_count (int | None) – The total number of different unique gifts that can be obtained by upgrading the gift

  • publisher_chat (peyk.platforms.telegram.types.chat.Chat | None) – Information about the chat that published the gift

background: GiftBackground | None = None
classmethod from_dict(data: dict | None) Gift | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

has_colors: bool | None = None
is_premium: bool | None = None
personal_remaining_count: int | None = None
personal_total_count: int | None = None
publisher_chat: Chat | None = None
remaining_count: int | None = None
total_count: int | None = None
unique_gift_variant_count: int | None = None
upgrade_star_count: int | None = None
id: str
sticker: Sticker
star_count: int
class peyk.platforms.telegram.GiftBackground(name: str = '', center_color: int = 0, edge_color: int = 0, symbol_color: int = 0, text_color: int = 0)[source]

Bases: object

This object describes the background of a gift.

Variables:
  • center_color (int) – Center color of the background in RGB format

  • edge_color (int) – Edge color of the background in RGB format

  • text_color (int) – Text color of the background in RGB format

center_color: int = 0
edge_color: int = 0
classmethod from_dict(data: dict | None) GiftBackground | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

name: str = ''
symbol_color: int = 0
text_color: int = 0
class peyk.platforms.telegram.GiftInfo(gift: Gift | None = None, owned_gift_id: str | None = None, convert_star_count: int | None = None, upgrade_star_count: int | None = None, can_be_upgraded: bool | None = None, is_saved: bool | None = None, is_pinned: bool | None = None, is_private: bool | None = None, is_saved_in_chat: bool | None = None, can_be_refunded: bool | None = None, upgraded_gift: object | None = None, date: int | None = None, send_date: int | None = None, last_reservation_date: int | None = None)[source]

Bases: object

Describes a service message about a regular gift that was sent or received.

Variables:
  • gift (peyk.platforms.telegram.types.gift.Gift | None) – Information about the gift

  • owned_gift_id (str | None) – Unique identifier of the received gift for the bot; only present for gifts received on behalf of business accounts

  • convert_star_count (int | None) – Number of Telegram Stars that can be claimed by the receiver by converting the gift; omitted if conversion to Telegram Stars is impossible

  • prepaid_upgrade_star_count – Number of Telegram Stars that were prepaid for the ability to upgrade the gift

  • is_upgrade_separate – True, if the gift’s upgrade was purchased after the gift was sent

  • can_be_upgraded (bool | None) – True, if the gift can be upgraded to a unique gift

  • text – Text of the message that was added to the gift

  • entities – Special entities that appear in the text

  • is_private (bool | None) – True, if the sender and gift text are shown only to the gift receiver; otherwise, everyone will be able to see them

  • unique_gift_number – Unique number reserved for this gift when upgraded. See the number field in UniqueGift.

can_be_refunded: bool | None = None
can_be_upgraded: bool | None = None
convert_star_count: int | None = None
date: int | None = None
classmethod from_dict(data: dict | None) GiftInfo | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

gift: Gift | None = None
is_pinned: bool | None = None
is_private: bool | None = None
is_saved: bool | None = None
is_saved_in_chat: bool | None = None
last_reservation_date: int | None = None
owned_gift_id: str | None = None
send_date: int | None = None
upgrade_star_count: int | None = None
upgraded_gift: object | None = None
class peyk.platforms.telegram.Gifts(gifts: List[Gift])[source]

Bases: object

This object represent a list of gifts.

Variables:

gifts (List[peyk.platforms.telegram.types.gift.Gift]) – The list of gifts

classmethod from_dict(data: dict | None) Gifts | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

gifts: List[Gift]
class peyk.platforms.telegram.Giveaway(chats: List[Chat], winners_selection_date: int, winner_count: int, only_new_members: bool | None = None, has_public_winners: bool | None = None, prize_description: str | None = None, country_codes: List[str] | None = None, prize_star_count: int | None = None, premium_subscription_month_count: int | None = None)[source]

Bases: object

This object represents a message about a scheduled giveaway.

Variables:
  • chats (List[peyk.platforms.telegram.types.chat.Chat]) – The list of chats which the user must join to participate in the giveaway

  • winners_selection_date (int) – Point in time (Unix timestamp) when winners of the giveaway will be selected

  • winner_count (int) – The number of users which are supposed to be selected as winners of the giveaway

  • only_new_members (bool | None) – True, if only users who join the chats after the giveaway started should be eligible to win

  • has_public_winners (bool | None) – True, if the list of giveaway winners will be visible to everyone

  • prize_description (str | None) – Description of additional giveaway prize

  • country_codes (List[str] | None) – A list of two-letter ISO 3166-1 alpha-2 country codes indicating the countries from which eligible users for the giveaway must come. If empty, then all users can participate in the giveaway. Users with a phone number that was bought on Fragment can always participate in giveaways.

  • prize_star_count (int | None) – The number of Telegram Stars to be split between giveaway winners; for Telegram Star giveaways only

  • premium_subscription_month_count (int | None) – The number of months the Telegram Premium subscription won from the giveaway will be active for; for Telegram Premium giveaways only

country_codes: List[str] | None = None
classmethod from_dict(data: dict | None) Giveaway | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

has_public_winners: bool | None = None
only_new_members: bool | None = None
premium_subscription_month_count: int | None = None
prize_description: str | None = None
prize_star_count: int | None = None
chats: List[Chat]
winners_selection_date: int
winner_count: int
class peyk.platforms.telegram.GiveawayCompleted(winner_count: int, unclaimed_prize_count: int | None = None, giveaway_message: Message | None = None, is_star_giveaway: bool | None = None)[source]

Bases: object

This object represents a service message about the completion of a giveaway without public winners.

Variables:
  • winner_count (int) – Number of winners in the giveaway

  • unclaimed_prize_count (int | None) – Number of undistributed prizes

  • giveaway_message (peyk.platforms.telegram.types.message.Message | None) – Message with the giveaway that was completed, if it wasn’t deleted

  • is_star_giveaway (bool | None) – True, if the giveaway is a Telegram Star giveaway. Otherwise, currently, the giveaway is a Telegram Premium giveaway.

classmethod from_dict(data)
giveaway_message: Message | None = None
giveaway_message_id = None
is_star_giveaway: bool | None = None
unclaimed_prize_count: int | None = None
winner_count: int
class peyk.platforms.telegram.GiveawayCreated(prize_star_count: int | None = None)[source]

Bases: object

This object represents a service message about the creation of a scheduled giveaway.

Variables:

prize_star_count (int | None) – The number of Telegram Stars to be split between giveaway winners; for Telegram Star giveaways only

classmethod from_dict(data: dict | None) GiveawayCreated | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

prize_star_count: int | None = None
class peyk.platforms.telegram.GiveawayWinners(chat: Chat, giveaway_message_id: int, winners_selection_date: int, winner_count: int, winners: List[User], additional_chat_count: int | None = None, prize_star_count: int | None = None, premium_subscription_month_count: int | None = None, unclaimed_prize_count: int | None = None, only_new_members: bool | None = None, was_refunded: bool | None = None, prize_description: str | None = None)[source]

Bases: object

This object represents a message about the completion of a giveaway with public winners.

Variables:
  • chat (peyk.platforms.telegram.types.chat.Chat) – The chat that created the giveaway

  • giveaway_message_id (int) – Identifier of the message with the giveaway in the chat

  • winners_selection_date (int) – Point in time (Unix timestamp) when winners of the giveaway were selected

  • winner_count (int) – Total number of winners in the giveaway

  • winners (List[peyk.platforms.telegram.types.user.User]) – List of up to 100 winners of the giveaway

  • additional_chat_count (int | None) – The number of other chats the user had to join in order to be eligible for the giveaway

  • prize_star_count (int | None) – The number of Telegram Stars that were split between giveaway winners; for Telegram Star giveaways only

  • premium_subscription_month_count (int | None) – The number of months the Telegram Premium subscription won from the giveaway will be active for; for Telegram Premium giveaways only

  • unclaimed_prize_count (int | None) – Number of undistributed prizes

  • only_new_members (bool | None) – True, if only users who had joined the chats after the giveaway started were eligible to win

  • was_refunded (bool | None) – True, if the giveaway was canceled because the payment for it was refunded

  • prize_description (str | None) – Description of additional giveaway prize

additional_chat_count: int | None = None
classmethod from_dict(data: dict | None) GiveawayWinners | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

only_new_members: bool | None = None
premium_subscription_month_count: int | None = None
prize_description: str | None = None
prize_star_count: int | None = None
unclaimed_prize_count: int | None = None
was_refunded: bool | None = None
chat: Chat
giveaway_message_id: int
winners_selection_date: int
winner_count: int
winners: List[User]
class peyk.platforms.telegram.InaccessibleMessage(chat: Chat, message_id: int, date: int = 0)[source]

Bases: object

This object describes a message that was deleted or is otherwise inaccessible to the bot.

Variables:
  • chat (peyk.platforms.telegram.types.chat.Chat) – Chat the message belonged to

  • message_id (int) – Unique message identifier inside the chat

  • date (int) – Always 0. The field can be used to differentiate regular and inaccessible messages.

date: int = 0
classmethod from_dict(data: dict | None) InaccessibleMessage | None[source]

Parse a Telegram API mapping into this type.

Parameters:

data – Raw Telegram API mapping, or None.

Returns:

Parsed type instance, or None when data is None.

chat: Chat
message_id: int
class peyk.platforms.telegram.InlineKeyboardButton(text: str = '', icon_custom_emoji_id: str | None = None, style: str | None = None, url: str | None = None, callback_data: str | None = None, web_app: WebAppInfo | None = None, login_url: LoginUrl | None = None, switch_inline_query: str | None = None, switch_inline_query_current_chat: str | None = None, switch_inline_query_chosen_chat: SwitchInlineQueryChosenChat | None = None, copy_text: CopyTextButton | None = None, callback_game: CallbackGame | None = None, pay: bool | None = None, disabled: DisabledButton | None = None)[source]

Bases: object

This object represents one button of an inline keyboard. Exactly one of the fields other than text, icon_custom_emoji_id, and style must be used to specify the type of the button.

Variables:
  • text (str) – Label text on the button

  • icon_custom_emoji_id (str | None) – Unique identifier of the custom emoji shown before the text of the button. Can only be used by bots that purchased additional usernames on Fragment or in the messages directly sent by the bot to private, group and supergroup chats if the owner of the bot has a Telegram Premium subscription.

  • style (str | None) – Style of the button. Must be one of ‘danger’ (red), ‘success’ (green) or ‘primary’ (blue). If omitted, then an app-specific style is used.

  • url (str | None) – HTTP or tg:// URL to be opened when the button is pressed. Links tg://user?id= can be used to mention a user by their identifier without using a username, if this is allowed by their privacy settings.

  • callback_data (str | None) – Data to be sent in a callback query to the bot when the button is pressed, 1-64 bytes

  • web_app (peyk.platforms.telegram.types.web_app_info.WebAppInfo | None) – Description of the Web App that will be launched when the user presses the button. The Web App will be able to send an arbitrary message on behalf of the user using the method answerWebAppQuery. Available only in private chats between a user and the bot. Not supported for messages sent on behalf of a business account.

  • login_url (peyk.platforms.telegram.types.login_url.LoginUrl | None) – An HTTPS URL used to automatically authorize the user. Can be used as a replacement for the Telegram Login Widget.

  • switch_inline_query (str | None) – If set, pressing the button will prompt the user to select one of their chats, open that chat and insert the bot’s username and the specified inline query in the input field. May be empty, in which case just the bot’s username will be inserted. Not supported for messages sent in channel direct messages chats and on behalf of a business account.

  • switch_inline_query_current_chat (str | None) – If set, pressing the button will insert the bot’s username and the specified inline query in the current chat’s input field. May be empty, in which case only the bot’s username will be inserted.

This offers a quick way for the user to open your bot in inline mode in the same chat - good for selecting something from multiple options. Not supported in channels and for messages sent in channel direct messages chats and on behalf of a business account.

switch_inline_query_chosen_chat: If set, pressing the button will prompt the user to select one of their chats of the specified type, open that chat and insert the bot’s username and the specified inline query in the input field. Not supported for messages sent in channel direct messages chats and on behalf of a business account. copy_text: Description of the button that copies the specified text to the clipboard callback_game: Description of the game that will be launched when the user presses the button.

NOTE: This type of button must always be the first button in the first row.

pay: Specify True, to send a Pay button. Substrings ‘’ and ‘XTR’ in the buttons’s text will be replaced with a Telegram Star icon.

NOTE: This type of button must always be the first button in the first row and can only be used in invoice messages.

callback_data: str | None = None
callback_game: CallbackGame | None = None
copy_text: CopyTextButton | None = None
disabled: DisabledButton | None = None
classmethod from_dict(data: dict | None) InlineKeyboardButton | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

icon_custom_emoji_id: str | None = None
login_url: LoginUrl | None = None
pay: bool | None = None
style: str | None = None
switch_inline_query: str | None = None
switch_inline_query_chosen_chat: SwitchInlineQueryChosenChat | None = None
switch_inline_query_current_chat: str | None = None
text: str = ''
to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

url: str | None = None
web_app: WebAppInfo | None = None
class peyk.platforms.telegram.InlineKeyboardMarkup(inline_keyboard: ~typing.List[~typing.List[~peyk.platforms.telegram.types.inline_keyboard_button.InlineKeyboardButton]] = <factory>)[source]

Bases: object

This object represents an inline keyboard that appears right next to the message it belongs to.

Variables:

inline_keyboard (List[List[peyk.platforms.telegram.types.inline_keyboard_button.InlineKeyboardButton]]) – Array of button rows, each represented by an Array of InlineKeyboardButton objects

classmethod from_dict(data: dict | None) InlineKeyboardMarkup | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

inline_keyboard: List[List[InlineKeyboardButton]]
class peyk.platforms.telegram.InlineQuery(id: str, from_: User | None = None, query: str = '', offset: str = '', chat_type: str | None = None, location: Location | None = None, bot: 'Bot[object]' | None = None)[source]

Bases: object

This object represents an incoming inline query. When the user sends an empty query, your bot could return some default or trending results.

Variables:
  • id (str) – Unique identifier for this query

  • from – Sender

  • query (str) – Text of the query (up to 256 characters)

  • offset (str) – Offset of the results to be returned, can be controlled by the bot

  • chat_type (Optional[str]) – Type of the chat from which the inline query was sent. Can be either ‘sender’ for a private chat with the inline query sender, ‘private’, ‘group’, ‘supergroup’, or ‘channel’. The chat type should be always known for requests sent from official clients and most third-party clients, unless the request was sent from a secret chat.

  • location (Optional[Location]) – Sender location, only for bots that request user location

async answer(results: Sequence[InlineQueryResultArticle | InlineQueryResultPhoto | InlineQueryResultGif | InlineQueryResultMpeg4Gif | InlineQueryResultVideo | InlineQueryResultAudio | InlineQueryResultVoice | InlineQueryResultDocument | InlineQueryResultLocation | InlineQueryResultVenue | InlineQueryResultContact | InlineQueryResultGame | InlineQueryResultCachedPhoto | InlineQueryResultCachedGif | InlineQueryResultCachedMpeg4Gif | InlineQueryResultCachedSticker | InlineQueryResultCachedDocument | InlineQueryResultCachedVideo | InlineQueryResultCachedVoice | InlineQueryResultCachedAudio | Mapping[str, object]], *, cache_time: int | None = None, is_personal: bool | None = None, next_offset: str | None = None, button: object | None = None) bool[source]

Answer this inline query through the bot injected by the dispatcher.

bot: 'Bot[object]' | None = None
chat_type: str | None = None
from_: User | None = None
classmethod from_dict(data: dict | None) InlineQuery | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

location: Location | None = None
offset: str = ''
query: str = ''
id: str
class peyk.platforms.telegram.InlineQueryResultArticle(id: str, title: str, input_message_content: InputTextMessageContent | InputLocationMessageContent | InputVenueMessageContent | InputContactMessageContent | InputInvoiceMessageContent | Mapping[str, object], type: str = 'article', reply_markup: InlineKeyboardMarkup | Mapping[str, object] | None = None, url: str | None = None, description: str | None = None, thumbnail_url: str | None = None, thumbnail_width: int | None = None, thumbnail_height: int | None = None)[source]

Bases: object

Represents a link to an article or web page.

Variables:
description: str | None = None
reply_markup: InlineKeyboardMarkup | Mapping[str, object] | None = None
thumbnail_height: int | None = None
thumbnail_url: str | None = None
thumbnail_width: int | None = None
to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

type: str = 'article'
url: str | None = None
id: str
title: str
input_message_content: InputTextMessageContent | InputLocationMessageContent | InputVenueMessageContent | InputContactMessageContent | InputInvoiceMessageContent | Mapping[str, object]
class peyk.platforms.telegram.InlineQueryResultAudio(id: str, audio_url: str, title: str, type: str = 'audio', caption: str | None = None, parse_mode: str | None = None, caption_entities: Sequence[MessageEntity | Mapping[str, object]] | None = None, performer: str | None = None, audio_duration: int | None = None, reply_markup: InlineKeyboardMarkup | Mapping[str, object] | None = None, input_message_content: InputTextMessageContent | InputLocationMessageContent | InputVenueMessageContent | InputContactMessageContent | InputInvoiceMessageContent | Mapping[str, object] | None = None)[source]

Bases: object

Represents a link to an MP3 audio file. By default, this audio file will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the audio.

Variables:
audio_duration: int | None = None
caption: str | None = None
caption_entities: Sequence[MessageEntity | Mapping[str, object]] | None = None
input_message_content: InputTextMessageContent | InputLocationMessageContent | InputVenueMessageContent | InputContactMessageContent | InputInvoiceMessageContent | Mapping[str, object] | None = None
parse_mode: str | None = None
performer: str | None = None
reply_markup: InlineKeyboardMarkup | Mapping[str, object] | None = None
to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

type: str = 'audio'
id: str
audio_url: str
title: str
class peyk.platforms.telegram.InlineQueryResultCachedAudio(id: str, audio_file_id: str, type: str = 'audio', caption: str | None = None, parse_mode: str | None = None, caption_entities: Sequence[MessageEntity | Mapping[str, object]] | None = None, reply_markup: InlineKeyboardMarkup | Mapping[str, object] | None = None, input_message_content: InputTextMessageContent | InputLocationMessageContent | InputVenueMessageContent | InputContactMessageContent | InputInvoiceMessageContent | Mapping[str, object] | None = None)[source]

Bases: object

Represents a link to an MP3 audio file stored on the Telegram servers. By default, this audio file will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the audio.

Variables:
caption: str | None = None
caption_entities: Sequence[MessageEntity | Mapping[str, object]] | None = None
input_message_content: InputTextMessageContent | InputLocationMessageContent | InputVenueMessageContent | InputContactMessageContent | InputInvoiceMessageContent | Mapping[str, object] | None = None
parse_mode: str | None = None
reply_markup: InlineKeyboardMarkup | Mapping[str, object] | None = None
to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

type: str = 'audio'
id: str
audio_file_id: str
class peyk.platforms.telegram.InlineQueryResultCachedDocument(id: str, title: str, document_file_id: str, type: str = 'document', description: str | None = None, caption: str | None = None, parse_mode: str | None = None, caption_entities: Sequence[MessageEntity | Mapping[str, object]] | None = None, reply_markup: InlineKeyboardMarkup | Mapping[str, object] | None = None, input_message_content: InputTextMessageContent | InputLocationMessageContent | InputVenueMessageContent | InputContactMessageContent | InputInvoiceMessageContent | Mapping[str, object] | None = None)[source]

Bases: object

Represents a link to a file stored on the Telegram servers. By default, this file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the file.

Variables:
caption: str | None = None
caption_entities: Sequence[MessageEntity | Mapping[str, object]] | None = None
description: str | None = None
input_message_content: InputTextMessageContent | InputLocationMessageContent | InputVenueMessageContent | InputContactMessageContent | InputInvoiceMessageContent | Mapping[str, object] | None = None
parse_mode: str | None = None
reply_markup: InlineKeyboardMarkup | Mapping[str, object] | None = None
to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

type: str = 'document'
id: str
title: str
document_file_id: str
class peyk.platforms.telegram.InlineQueryResultCachedGif(id: str, gif_file_id: str, type: str = 'gif', title: str | None = None, caption: str | None = None, parse_mode: str | None = None, caption_entities: Sequence[MessageEntity | Mapping[str, object]] | None = None, show_caption_above_media: bool | None = None, reply_markup: InlineKeyboardMarkup | Mapping[str, object] | None = None, input_message_content: InputTextMessageContent | InputLocationMessageContent | InputVenueMessageContent | InputContactMessageContent | InputInvoiceMessageContent | Mapping[str, object] | None = None)[source]

Bases: object

Represents a link to an animated GIF file stored on the Telegram servers. By default, this animated GIF file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with specified content instead of the animation.

Variables:
caption: str | None = None
caption_entities: Sequence[MessageEntity | Mapping[str, object]] | None = None
input_message_content: InputTextMessageContent | InputLocationMessageContent | InputVenueMessageContent | InputContactMessageContent | InputInvoiceMessageContent | Mapping[str, object] | None = None
parse_mode: str | None = None
reply_markup: InlineKeyboardMarkup | Mapping[str, object] | None = None
show_caption_above_media: bool | None = None
title: str | None = None
to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

type: str = 'gif'
id: str
gif_file_id: str
class peyk.platforms.telegram.InlineQueryResultCachedMpeg4Gif(id: str, mpeg4_file_id: str, type: str = 'mpeg4_gif', title: str | None = None, caption: str | None = None, parse_mode: str | None = None, caption_entities: Sequence[MessageEntity | Mapping[str, object]] | None = None, show_caption_above_media: bool | None = None, reply_markup: InlineKeyboardMarkup | Mapping[str, object] | None = None, input_message_content: InputTextMessageContent | InputLocationMessageContent | InputVenueMessageContent | InputContactMessageContent | InputInvoiceMessageContent | Mapping[str, object] | None = None)[source]

Bases: object

Represents a link to a video animation (H.264/MPEG-4 AVC video without sound) stored on the Telegram servers. By default, this animated MPEG-4 file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the animation.

Variables:
caption: str | None = None
caption_entities: Sequence[MessageEntity | Mapping[str, object]] | None = None
input_message_content: InputTextMessageContent | InputLocationMessageContent | InputVenueMessageContent | InputContactMessageContent | InputInvoiceMessageContent | Mapping[str, object] | None = None
parse_mode: str | None = None
reply_markup: InlineKeyboardMarkup | Mapping[str, object] | None = None
show_caption_above_media: bool | None = None
title: str | None = None
to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

type: str = 'mpeg4_gif'
id: str
mpeg4_file_id: str
class peyk.platforms.telegram.InlineQueryResultCachedPhoto(id: str, photo_file_id: str, type: str = 'photo', title: str | None = None, description: str | None = None, caption: str | None = None, parse_mode: str | None = None, caption_entities: Sequence[MessageEntity | Mapping[str, object]] | None = None, show_caption_above_media: bool | None = None, reply_markup: InlineKeyboardMarkup | Mapping[str, object] | None = None, input_message_content: InputTextMessageContent | InputLocationMessageContent | InputVenueMessageContent | InputContactMessageContent | InputInvoiceMessageContent | Mapping[str, object] | None = None)[source]

Bases: object

Represents a link to a photo stored on the Telegram servers. By default, this photo will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the photo.

Variables:
caption: str | None = None
caption_entities: Sequence[MessageEntity | Mapping[str, object]] | None = None
description: str | None = None
input_message_content: InputTextMessageContent | InputLocationMessageContent | InputVenueMessageContent | InputContactMessageContent | InputInvoiceMessageContent | Mapping[str, object] | None = None
parse_mode: str | None = None
reply_markup: InlineKeyboardMarkup | Mapping[str, object] | None = None
show_caption_above_media: bool | None = None
title: str | None = None
to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

type: str = 'photo'
id: str
photo_file_id: str
class peyk.platforms.telegram.InlineQueryResultCachedSticker(id: str, sticker_file_id: str, type: str = 'sticker', reply_markup: InlineKeyboardMarkup | Mapping[str, object] | None = None, input_message_content: InputTextMessageContent | InputLocationMessageContent | InputVenueMessageContent | InputContactMessageContent | InputInvoiceMessageContent | Mapping[str, object] | None = None)[source]

Bases: object

Represents a link to a sticker stored on the Telegram servers. By default, this sticker will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the sticker.

Variables:
input_message_content: InputTextMessageContent | InputLocationMessageContent | InputVenueMessageContent | InputContactMessageContent | InputInvoiceMessageContent | Mapping[str, object] | None = None
reply_markup: InlineKeyboardMarkup | Mapping[str, object] | None = None
to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

type: str = 'sticker'
id: str
sticker_file_id: str
class peyk.platforms.telegram.InlineQueryResultCachedVideo(id: str, video_file_id: str, title: str, type: str = 'video', description: str | None = None, caption: str | None = None, parse_mode: str | None = None, caption_entities: Sequence[MessageEntity | Mapping[str, object]] | None = None, show_caption_above_media: bool | None = None, reply_markup: InlineKeyboardMarkup | Mapping[str, object] | None = None, input_message_content: InputTextMessageContent | InputLocationMessageContent | InputVenueMessageContent | InputContactMessageContent | InputInvoiceMessageContent | Mapping[str, object] | None = None)[source]

Bases: object

Represents a link to a video file stored on the Telegram servers. By default, this video file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the video.

Variables:
caption: str | None = None
caption_entities: Sequence[MessageEntity | Mapping[str, object]] | None = None
description: str | None = None
input_message_content: InputTextMessageContent | InputLocationMessageContent | InputVenueMessageContent | InputContactMessageContent | InputInvoiceMessageContent | Mapping[str, object] | None = None
parse_mode: str | None = None
reply_markup: InlineKeyboardMarkup | Mapping[str, object] | None = None
show_caption_above_media: bool | None = None
to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

type: str = 'video'
id: str
video_file_id: str
title: str
class peyk.platforms.telegram.InlineQueryResultCachedVoice(id: str, voice_file_id: str, title: str, type: str = 'voice', caption: str | None = None, parse_mode: str | None = None, caption_entities: Sequence[MessageEntity | Mapping[str, object]] | None = None, reply_markup: InlineKeyboardMarkup | Mapping[str, object] | None = None, input_message_content: InputTextMessageContent | InputLocationMessageContent | InputVenueMessageContent | InputContactMessageContent | InputInvoiceMessageContent | Mapping[str, object] | None = None)[source]

Bases: object

Represents a link to a voice message stored on the Telegram servers. By default, this voice message will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the voice message.

Variables:
caption: str | None = None
caption_entities: Sequence[MessageEntity | Mapping[str, object]] | None = None
input_message_content: InputTextMessageContent | InputLocationMessageContent | InputVenueMessageContent | InputContactMessageContent | InputInvoiceMessageContent | Mapping[str, object] | None = None
parse_mode: str | None = None
reply_markup: InlineKeyboardMarkup | Mapping[str, object] | None = None
to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

type: str = 'voice'
id: str
voice_file_id: str
title: str
class peyk.platforms.telegram.InlineQueryResultContact(id: str, phone_number: str, first_name: str, type: str = 'contact', last_name: str | None = None, vcard: str | None = None, reply_markup: InlineKeyboardMarkup | Mapping[str, object] | None = None, input_message_content: InputTextMessageContent | InputLocationMessageContent | InputVenueMessageContent | InputContactMessageContent | InputInvoiceMessageContent | Mapping[str, object] | None = None, thumbnail_url: str | None = None, thumbnail_width: int | None = None, thumbnail_height: int | None = None)[source]

Bases: object

Represents a contact with a phone number. By default, this contact will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the contact.

Variables:
input_message_content: InputTextMessageContent | InputLocationMessageContent | InputVenueMessageContent | InputContactMessageContent | InputInvoiceMessageContent | Mapping[str, object] | None = None
last_name: str | None = None
reply_markup: InlineKeyboardMarkup | Mapping[str, object] | None = None
thumbnail_height: int | None = None
thumbnail_url: str | None = None
thumbnail_width: int | None = None
to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

type: str = 'contact'
vcard: str | None = None
id: str
phone_number: str
first_name: str
class peyk.platforms.telegram.InlineQueryResultDocument(id: str, title: str, document_url: str, mime_type: str, type: str = 'document', caption: str | None = None, parse_mode: str | None = None, caption_entities: Sequence[MessageEntity | Mapping[str, object]] | None = None, description: str | None = None, reply_markup: InlineKeyboardMarkup | Mapping[str, object] | None = None, input_message_content: InputTextMessageContent | InputLocationMessageContent | InputVenueMessageContent | InputContactMessageContent | InputInvoiceMessageContent | Mapping[str, object] | None = None, thumbnail_url: str | None = None, thumbnail_width: int | None = None, thumbnail_height: int | None = None)[source]

Bases: object

Represents a link to a file. By default, this file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the file. Currently, only .PDF and .ZIP files can be sent using this method.

Variables:
caption: str | None = None
caption_entities: Sequence[MessageEntity | Mapping[str, object]] | None = None
description: str | None = None
input_message_content: InputTextMessageContent | InputLocationMessageContent | InputVenueMessageContent | InputContactMessageContent | InputInvoiceMessageContent | Mapping[str, object] | None = None
parse_mode: str | None = None
reply_markup: InlineKeyboardMarkup | Mapping[str, object] | None = None
thumbnail_height: int | None = None
thumbnail_url: str | None = None
thumbnail_width: int | None = None
to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

type: str = 'document'
id: str
title: str
document_url: str
mime_type: str
class peyk.platforms.telegram.InlineQueryResultGame(id: str, game_short_name: str, type: str = 'game', reply_markup: InlineKeyboardMarkup | Mapping[str, object] | None = None)[source]

Bases: object

Represents a Game.

Variables:
reply_markup: InlineKeyboardMarkup | Mapping[str, object] | None = None
to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

type: str = 'game'
id: str
game_short_name: str
class peyk.platforms.telegram.InlineQueryResultGif(id: str, gif_url: str, thumbnail_url: str, type: str = 'gif', gif_width: int | None = None, gif_height: int | None = None, gif_duration: int | None = None, thumbnail_mime_type: str | None = None, title: str | None = None, caption: str | None = None, parse_mode: str | None = None, caption_entities: Sequence[MessageEntity | Mapping[str, object]] | None = None, show_caption_above_media: bool | None = None, reply_markup: InlineKeyboardMarkup | Mapping[str, object] | None = None, input_message_content: InputTextMessageContent | InputLocationMessageContent | InputVenueMessageContent | InputContactMessageContent | InputInvoiceMessageContent | Mapping[str, object] | None = None)[source]

Bases: object

Represents a link to an animated GIF file. By default, this animated GIF file will be sent by the user with optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the animation.

Variables:
caption: str | None = None
caption_entities: Sequence[MessageEntity | Mapping[str, object]] | None = None
gif_duration: int | None = None
gif_height: int | None = None
gif_width: int | None = None
input_message_content: InputTextMessageContent | InputLocationMessageContent | InputVenueMessageContent | InputContactMessageContent | InputInvoiceMessageContent | Mapping[str, object] | None = None
parse_mode: str | None = None
reply_markup: InlineKeyboardMarkup | Mapping[str, object] | None = None
show_caption_above_media: bool | None = None
thumbnail_mime_type: str | None = None
title: str | None = None
to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

type: str = 'gif'
id: str
gif_url: str
thumbnail_url: str
class peyk.platforms.telegram.InlineQueryResultLocation(id: str, latitude: float, longitude: float, title: str, type: str = 'location', horizontal_accuracy: float | None = None, live_period: int | None = None, heading: int | None = None, proximity_alert_radius: int | None = None, reply_markup: InlineKeyboardMarkup | Mapping[str, object] | None = None, input_message_content: InputTextMessageContent | InputLocationMessageContent | InputVenueMessageContent | InputContactMessageContent | InputInvoiceMessageContent | Mapping[str, object] | None = None, thumbnail_url: str | None = None, thumbnail_width: int | None = None, thumbnail_height: int | None = None)[source]

Bases: object

Represents a location on a map. By default, the location will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the location.

Variables:
heading: int | None = None
horizontal_accuracy: float | None = None
input_message_content: InputTextMessageContent | InputLocationMessageContent | InputVenueMessageContent | InputContactMessageContent | InputInvoiceMessageContent | Mapping[str, object] | None = None
live_period: int | None = None
proximity_alert_radius: int | None = None
reply_markup: InlineKeyboardMarkup | Mapping[str, object] | None = None
thumbnail_height: int | None = None
thumbnail_url: str | None = None
thumbnail_width: int | None = None
to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

type: str = 'location'
id: str
latitude: float
longitude: float
title: str
class peyk.platforms.telegram.InlineQueryResultMpeg4Gif(id: str, mpeg4_url: str, thumbnail_url: str, type: str = 'mpeg4_gif', mpeg4_width: int | None = None, mpeg4_height: int | None = None, mpeg4_duration: int | None = None, thumbnail_mime_type: str | None = None, title: str | None = None, caption: str | None = None, parse_mode: str | None = None, caption_entities: Sequence[MessageEntity | Mapping[str, object]] | None = None, show_caption_above_media: bool | None = None, reply_markup: InlineKeyboardMarkup | Mapping[str, object] | None = None, input_message_content: InputTextMessageContent | InputLocationMessageContent | InputVenueMessageContent | InputContactMessageContent | InputInvoiceMessageContent | Mapping[str, object] | None = None)[source]

Bases: object

Represents a link to a video animation (H.264/MPEG-4 AVC video without sound). By default, this animated MPEG-4 file will be sent by the user with optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the animation.

Variables:
caption: str | None = None
caption_entities: Sequence[MessageEntity | Mapping[str, object]] | None = None
input_message_content: InputTextMessageContent | InputLocationMessageContent | InputVenueMessageContent | InputContactMessageContent | InputInvoiceMessageContent | Mapping[str, object] | None = None
mpeg4_duration: int | None = None
mpeg4_height: int | None = None
mpeg4_width: int | None = None
parse_mode: str | None = None
reply_markup: InlineKeyboardMarkup | Mapping[str, object] | None = None
show_caption_above_media: bool | None = None
thumbnail_mime_type: str | None = None
title: str | None = None
to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

type: str = 'mpeg4_gif'
id: str
mpeg4_url: str
thumbnail_url: str
class peyk.platforms.telegram.InlineQueryResultPhoto(id: str, photo_url: str, thumbnail_url: str, type: str = 'photo', photo_width: int | None = None, photo_height: int | None = None, title: str | None = None, description: str | None = None, caption: str | None = None, parse_mode: str | None = None, caption_entities: Sequence[MessageEntity | Mapping[str, object]] | None = None, show_caption_above_media: bool | None = None, reply_markup: InlineKeyboardMarkup | Mapping[str, object] | None = None, input_message_content: InputTextMessageContent | InputLocationMessageContent | InputVenueMessageContent | InputContactMessageContent | InputInvoiceMessageContent | Mapping[str, object] | None = None)[source]

Bases: object

Represents a link to a photo. By default, this photo will be sent by the user with optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the photo.

Variables:
caption: str | None = None
caption_entities: Sequence[MessageEntity | Mapping[str, object]] | None = None
description: str | None = None
input_message_content: InputTextMessageContent | InputLocationMessageContent | InputVenueMessageContent | InputContactMessageContent | InputInvoiceMessageContent | Mapping[str, object] | None = None
parse_mode: str | None = None
photo_height: int | None = None
photo_width: int | None = None
reply_markup: InlineKeyboardMarkup | Mapping[str, object] | None = None
show_caption_above_media: bool | None = None
title: str | None = None
to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

type: str = 'photo'
id: str
photo_url: str
thumbnail_url: str
class peyk.platforms.telegram.InlineQueryResultType(*values)[source]

Bases: str, Enum

InlineQueryResultType defines a public API type for peyk.

ARTICLE = 'article'
PHOTO = 'photo'
GIF = 'gif'
MPEG4_GIF = 'mpeg4_gif'
VIDEO = 'video'
AUDIO = 'audio'
VOICE = 'voice'
DOCUMENT = 'document'
LOCATION = 'location'
VENUE = 'venue'
CONTACT = 'contact'
GAME = 'game'
STICKER = 'sticker'
class peyk.platforms.telegram.InlineQueryResultVenue(id: str, latitude: float, longitude: float, title: str, address: str, type: str = 'venue', foursquare_id: str | None = None, foursquare_type: str | None = None, google_place_id: str | None = None, google_place_type: str | None = None, reply_markup: InlineKeyboardMarkup | Mapping[str, object] | None = None, input_message_content: InputTextMessageContent | InputLocationMessageContent | InputVenueMessageContent | InputContactMessageContent | InputInvoiceMessageContent | Mapping[str, object] | None = None, thumbnail_url: str | None = None, thumbnail_width: int | None = None, thumbnail_height: int | None = None)[source]

Bases: object

Represents a venue. By default, the venue will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the venue.

Variables:
foursquare_id: str | None = None
foursquare_type: str | None = None
google_place_id: str | None = None
google_place_type: str | None = None
input_message_content: InputTextMessageContent | InputLocationMessageContent | InputVenueMessageContent | InputContactMessageContent | InputInvoiceMessageContent | Mapping[str, object] | None = None
reply_markup: InlineKeyboardMarkup | Mapping[str, object] | None = None
thumbnail_height: int | None = None
thumbnail_url: str | None = None
thumbnail_width: int | None = None
to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

type: str = 'venue'
id: str
latitude: float
longitude: float
title: str
address: str
class peyk.platforms.telegram.InlineQueryResultVideo(id: str, video_url: str, mime_type: str, thumbnail_url: str, title: str, type: str = 'video', caption: str | None = None, parse_mode: str | None = None, caption_entities: Sequence[MessageEntity | Mapping[str, object]] | None = None, show_caption_above_media: bool | None = None, video_width: int | None = None, video_height: int | None = None, video_duration: int | None = None, description: str | None = None, reply_markup: InlineKeyboardMarkup | Mapping[str, object] | None = None, input_message_content: InputTextMessageContent | InputLocationMessageContent | InputVenueMessageContent | InputContactMessageContent | InputInvoiceMessageContent | Mapping[str, object] | None = None)[source]

Bases: object

Represents a link to a page containing an embedded video player or a video file. By default, this video file will be sent by the user with an optional caption. Alternatively, you can use input_message_content to send a message with the specified content instead of the video. If an InlineQueryResultVideo message contains an embedded video (e.g., YouTube), you must replace its content using input_message_content.

Variables:
caption: str | None = None
caption_entities: Sequence[MessageEntity | Mapping[str, object]] | None = None
description: str | None = None
input_message_content: InputTextMessageContent | InputLocationMessageContent | InputVenueMessageContent | InputContactMessageContent | InputInvoiceMessageContent | Mapping[str, object] | None = None
parse_mode: str | None = None
reply_markup: InlineKeyboardMarkup | Mapping[str, object] | None = None
show_caption_above_media: bool | None = None
to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

type: str = 'video'
video_duration: int | None = None
video_height: int | None = None
video_width: int | None = None
id: str
video_url: str
mime_type: str
thumbnail_url: str
title: str
class peyk.platforms.telegram.InlineQueryResultVoice(id: str, voice_url: str, title: str, type: str = 'voice', caption: str | None = None, parse_mode: str | None = None, caption_entities: Sequence[MessageEntity | Mapping[str, object]] | None = None, voice_duration: int | None = None, reply_markup: InlineKeyboardMarkup | Mapping[str, object] | None = None, input_message_content: InputTextMessageContent | InputLocationMessageContent | InputVenueMessageContent | InputContactMessageContent | InputInvoiceMessageContent | Mapping[str, object] | None = None)[source]

Bases: object

Represents a link to a voice recording in an .OGG container encoded with OPUS. By default, this voice recording will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the the voice message.

Variables:
caption: str | None = None
caption_entities: Sequence[MessageEntity | Mapping[str, object]] | None = None
input_message_content: InputTextMessageContent | InputLocationMessageContent | InputVenueMessageContent | InputContactMessageContent | InputInvoiceMessageContent | Mapping[str, object] | None = None
parse_mode: str | None = None
reply_markup: InlineKeyboardMarkup | Mapping[str, object] | None = None
to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

type: str = 'voice'
voice_duration: int | None = None
id: str
voice_url: str
title: str
class peyk.platforms.telegram.InlineQueryResultsButton(text: str, web_app: WebAppInfo | Mapping[str, object] | None = None, start_parameter: str | None = None)[source]

Bases: object

This object represents a button to be shown above inline query results. You must use exactly one of the optional fields.

Variables:
  • text (str) – Label text on the button

  • web_app (peyk.platforms.telegram.types.web_app_info.WebAppInfo | Mapping[str, object] | None) – Description of the Web App that will be launched when the user presses the button. The Web App will be able to switch back to the inline mode using the method switchInlineQuery inside the Web App.

  • start_parameter (str | None) – Deep-linking parameter for the /start message sent to the bot when a user presses the button. 1-64 characters, only A-Z, a-z, 0-9, _ and - are allowed.

Example: An inline bot that sends YouTube videos can ask the user to connect the bot to their YouTube account to adapt search results accordingly. To do this, it displays a ‘Connect your YouTube account’ button above the results, or even before showing any. The user presses the button, switches to a private chat with the bot and, in doing so, passes a start parameter that instructs the bot to return an OAuth link. Once done, the bot can offer a switch_inline button so that the user can easily return to the chat where they wanted to use the bot’s inline capabilities.

classmethod from_dict(data: dict | None) InlineQueryResultsButton | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

start_parameter: str | None = None
to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

web_app: WebAppInfo | Mapping[str, object] | None = None
text: str
class peyk.platforms.telegram.InputChecklist(title: str, tasks: List[InputChecklistTask], others_can_add_tasks: bool | None = None, others_can_mark_tasks_as_done: bool | None = None)[source]

Bases: object

Describes a checklist to create.

Variables:
  • title (str) – Title of the checklist; 1-255 characters after entities parsing

  • tasks (List[peyk.platforms.telegram.types.input_checklist_task.InputChecklistTask]) – List of 1-30 tasks in the checklist

  • parse_mode – Mode for parsing entities in the title. See formatting options for more details.

  • title_entities – List of special entities that appear in the title, which can be specified instead of parse_mode. Currently, only bold, italic, underline, strikethrough, spoiler, custom_emoji, and date_time entities are allowed.

  • others_can_add_tasks (bool | None) – Pass True if other users can add tasks to the checklist

  • others_can_mark_tasks_as_done (bool | None) – Pass True if other users can mark tasks as done or not done in the checklist

others_can_add_tasks: bool | None = None
others_can_mark_tasks_as_done: bool | None = None
to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

title: str
tasks: List[InputChecklistTask]
class peyk.platforms.telegram.InputChecklistTask(text: str, parse_mode: str | None = None, text_entities: List[MessageEntity] | None = None)[source]

Bases: object

Describes a task to add to a checklist.

Variables:
  • id – Unique identifier of the task; must be positive and unique among all task identifiers currently present in the checklist

  • text (str) – Text of the task; 1-100 characters after entities parsing

  • parse_mode (str | None) – Mode for parsing entities in the text. See formatting options for more details.

  • text_entities (List[peyk.platforms.telegram.types.message_entity.MessageEntity] | None) – List of special entities that appear in the text, which can be specified instead of parse_mode. Currently, only bold, italic, underline, strikethrough, spoiler, custom_emoji, and date_time entities are allowed.

parse_mode: str | None = None
text_entities: List[MessageEntity] | None = None
to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

text: str
class peyk.platforms.telegram.InputContactMessageContent(phone_number: str, first_name: str, last_name: str | None = None, vcard: str | None = None)[source]

Bases: object

Represents the content of a contact message to be sent as the result of an inline query.

Variables:
  • phone_number (str) – Contact’s phone number

  • first_name (str) – Contact’s first name

  • last_name (str | None) – Contact’s last name

  • vcard (str | None) – Additional data about the contact in the form of a vCard, 0-2048 bytes

last_name: str | None = None
to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

vcard: str | None = None
phone_number: str
first_name: str
class peyk.platforms.telegram.InputFile(file_id: str = '')[source]

Bases: object

Input file (placeholder).

file_id: str = ''
classmethod from_dict(data: dict | None) InputFile | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

class peyk.platforms.telegram.InputInvoiceMessageContent(title: str, description: str, payload: str, currency: str, prices: ~typing.Sequence[~peyk.platforms.telegram.types.labeled_price.LabeledPrice | ~typing.Mapping[str, object]] = <factory>, provider_token: str | None = None, max_tip_amount: int | None = None, suggested_tip_amounts: ~typing.List[int] | None = None, provider_data: str | None = None, photo_url: str | None = None, photo_size: int | None = None, photo_width: int | None = None, photo_height: int | None = None, need_name: bool | None = None, need_phone_number: bool | None = None, need_email: bool | None = None, need_shipping_address: bool | None = None, send_phone_number_to_provider: bool | None = None, send_email_to_provider: bool | None = None, is_flexible: bool | None = None)[source]

Bases: object

Represents the content of an invoice message to be sent as the result of an inline query.

Variables:
  • title (str) – Product name, 1-32 characters

  • description (str) – Product description, 1-255 characters

  • payload (str) – Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use it for your internal processes.

  • currency (str) – Three-letter ISO 4217 currency code, see more on currencies. Pass ‘XTR’ for payments in Telegram Stars.

  • prices (Sequence[peyk.platforms.telegram.types.labeled_price.LabeledPrice | Mapping[str, object]]) – Price breakdown, a JSON-serialized list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.). Must contain exactly one item for payments in Telegram Stars.

  • provider_token (str | None) – Payment provider token, obtained via @BotFather. Pass an empty string for payments in Telegram Stars.

  • max_tip_amount (int | None) – The maximum accepted amount for tips in the smallest units of the currency (integer, not float/double). For example, for a maximum tip of US$ 1.45 pass max_tip_amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). Defaults to 0. Not supported for payments in Telegram Stars.

  • suggested_tip_amounts (List[int] | None) – A JSON-serialized Array of suggested amounts of tip in the smallest units of the currency (integer, not float/double). At most 4 suggested tip amounts can be specified. The suggested tip amounts must be positive, passed in a strictly increased order and must not exceed max_tip_amount.

  • provider_data (str | None) – A JSON-serialized object for data about the invoice, which will be shared with the payment provider. A detailed description of the required fields should be provided by the payment provider.

  • photo_url (str | None) – URL of the product photo for the invoice. Can be a photo of the goods or a marketing image for a service.

  • photo_size (int | None) – Photo size in bytes

  • photo_width (int | None) – Photo width

  • photo_height (int | None) – Photo height

  • need_name (bool | None) – Pass True if you require the user’s full name to complete the order. Ignored for payments in Telegram Stars.

  • need_phone_number (bool | None) – Pass True if you require the user’s phone number to complete the order. Ignored for payments in Telegram Stars.

  • need_email (bool | None) – Pass True if you require the user’s email address to complete the order. Ignored for payments in Telegram Stars.

  • need_shipping_address (bool | None) – Pass True if you require the user’s shipping address to complete the order. Ignored for payments in Telegram Stars.

  • send_phone_number_to_provider (bool | None) – Pass True if the user’s phone number should be sent to the provider. Ignored for payments in Telegram Stars.

  • send_email_to_provider (bool | None) – Pass True if the user’s email address should be sent to the provider. Ignored for payments in Telegram Stars.

  • is_flexible (bool | None) – Pass True if the final price depends on the shipping method. Ignored for payments in Telegram Stars.

is_flexible: bool | None = None
max_tip_amount: int | None = None
need_email: bool | None = None
need_name: bool | None = None
need_phone_number: bool | None = None
need_shipping_address: bool | None = None
photo_height: int | None = None
photo_size: int | None = None
photo_url: str | None = None
photo_width: int | None = None
provider_data: str | None = None
provider_token: str | None = None
send_email_to_provider: bool | None = None
send_phone_number_to_provider: bool | None = None
suggested_tip_amounts: List[int] | None = None
to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

title: str
description: str
payload: str
currency: str
prices: Sequence[LabeledPrice | Mapping[str, object]]
class peyk.platforms.telegram.InputLocationMessageContent(latitude: float, longitude: float, horizontal_accuracy: float | None = None, live_period: int | None = None, heading: int | None = None, proximity_alert_radius: int | None = None)[source]

Bases: object

Represents the content of a location message to be sent as the result of an inline query.

Variables:
  • latitude (float) – Latitude of the location in degrees

  • longitude (float) – Longitude of the location in degrees

  • horizontal_accuracy (float | None) – The radius of uncertainty for the location, measured in meters; 0-1500

  • live_period (int | None) – Period in seconds during which the location can be updated, must be between 60 and 86400, or 0x7FFFFFFF for live locations that can be edited indefinitely

  • heading (int | None) – For live locations, a direction in which the user is moving, in degrees. Must be between 1 and 360 if specified.

  • proximity_alert_radius (int | None) – For live locations, a maximum distance for proximity alerts about approaching another chat member, in meters. Must be between 1 and 100000 if specified.

heading: int | None = None
horizontal_accuracy: float | None = None
live_period: int | None = None
proximity_alert_radius: int | None = None
to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

latitude: float
longitude: float
class peyk.platforms.telegram.InputMediaAnimation(media: object, thumbnail: object | None = None, caption: str | None = None, parse_mode: str | None = None, caption_entities: List[MessageEntity] | None = None, show_caption_above_media: bool | None = None, width: int | None = None, height: int | None = None, duration: int | None = None, has_spoiler: bool | None = None)[source]

Bases: object

Represents an animation file (GIF or H.264/MPEG-4 AVC video without sound) to be sent.

Variables:
  • type – Type of the media, must be animation

  • media (object) – File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass ‘attach://’ to upload a new one using multipart/form-data under name. More information on Sending Files

  • thumbnail (object | None) – Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail’s width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass ‘attach://’ if the thumbnail was uploaded using multipart/form-data under . More information on Sending Files

  • caption (str | None) – Caption of the animation to be sent, 0-1024 characters after entities parsing

  • parse_mode (str | None) – Mode for parsing entities in the animation caption. See formatting options for more details.

  • caption_entities (List[peyk.platforms.telegram.types.message_entity.MessageEntity] | None) – List of special entities that appear in the caption, which can be specified instead of parse_mode

  • show_caption_above_media (bool | None) – Pass True if the caption must be shown above the message media

  • width (int | None) – Animation width

  • height (int | None) – Animation height

  • duration (int | None) – Animation duration in seconds

  • has_spoiler (bool | None) – Pass True if the animation needs to be covered with a spoiler animation

caption: str | None = None
caption_entities: List[MessageEntity] | None = None
duration: int | None = None
has_spoiler: bool | None = None
height: int | None = None
parse_mode: str | None = None
show_caption_above_media: bool | None = None
thumbnail: object | None = None
to_dict(media: str, thumbnail: str | None = None) Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Parameters:
  • media – Value used by this operation.

  • thumbnail – Value used by this operation.

Returns:

Result produced by the operation.

width: int | None = None
media: object
class peyk.platforms.telegram.InputMediaAudio(media: object, thumbnail: object | None = None, caption: str | None = None, parse_mode: str | None = None, caption_entities: List[MessageEntity] | None = None, duration: int | None = None, performer: str | None = None, title: str | None = None)[source]

Bases: object

Represents an audio file to be treated as music to be sent.

Variables:
  • type – Type of the media, must be audio

  • media (object) – File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass ‘attach://’ to upload a new one using multipart/form-data under name. More information on Sending Files

  • thumbnail (object | None) – Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail’s width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass ‘attach://’ if the thumbnail was uploaded using multipart/form-data under . More information on Sending Files

  • caption (str | None) – Caption of the audio to be sent, 0-1024 characters after entities parsing

  • parse_mode (str | None) – Mode for parsing entities in the audio caption. See formatting options for more details.

  • caption_entities (List[peyk.platforms.telegram.types.message_entity.MessageEntity] | None) – List of special entities that appear in the caption, which can be specified instead of parse_mode

  • duration (int | None) – Duration of the audio in seconds

  • performer (str | None) – Performer of the audio

  • title (str | None) – Title of the audio

caption: str | None = None
caption_entities: List[MessageEntity] | None = None
duration: int | None = None
parse_mode: str | None = None
performer: str | None = None
thumbnail: object | None = None
title: str | None = None
to_dict(media: str, thumbnail: str | None = None) Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Parameters:
  • media – Value used by this operation.

  • thumbnail – Value used by this operation.

Returns:

Result produced by the operation.

media: object
class peyk.platforms.telegram.InputMediaDocument(media: object, thumbnail: object | None = None, caption: str | None = None, parse_mode: str | None = None, caption_entities: List[MessageEntity] | None = None, disable_content_type_detection: bool | None = None)[source]

Bases: object

Represents a general file to be sent.

Variables:
  • type – Type of the media, must be document

  • media (object) – File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass ‘attach://’ to upload a new one using multipart/form-data under name. More information on Sending Files

  • thumbnail (object | None) – Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail’s width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass ‘attach://’ if the thumbnail was uploaded using multipart/form-data under . More information on Sending Files

  • caption (str | None) – Caption of the document to be sent, 0-1024 characters after entities parsing

  • parse_mode (str | None) – Mode for parsing entities in the document caption. See formatting options for more details.

  • caption_entities (List[peyk.platforms.telegram.types.message_entity.MessageEntity] | None) – List of special entities that appear in the caption, which can be specified instead of parse_mode

  • disable_content_type_detection (bool | None) – Disables automatic server-side content type detection for files uploaded using multipart/form-data. Always True, if the document is sent as part of an album.

caption: str | None = None
caption_entities: List[MessageEntity] | None = None
disable_content_type_detection: bool | None = None
parse_mode: str | None = None
thumbnail: object | None = None
to_dict(media: str, thumbnail: str | None = None) Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Parameters:
  • media – Value used by this operation.

  • thumbnail – Value used by this operation.

Returns:

Result produced by the operation.

media: object

Bases: object

Represents an HTTP link to be sent.

Variables:
  • type – Type of the media, must be link

  • url (str) – HTTP URL of the link

to_dict() Dict[str, object][source]

Serialize this type to the Telegram API request shape.

Returns:

A JSON-compatible mapping representing this value.

url: str
class peyk.platforms.telegram.InputMediaLivePhoto(media: object, photo: object, caption: str | None = None, parse_mode: str | None = None, caption_entities: List[MessageEntity] | None = None, show_caption_above_media: bool | None = None, has_spoiler: bool | None = None)[source]

Bases: object

Represents a live photo to be sent.

Variables:
  • type – Type of the media, must be live_photo

  • media (object) – Video of the live photo to send. Pass a file_id to send a file that exists on the Telegram servers (recommended) or pass ‘attach://’ to upload a new one using multipart/form-data under name. More information on Sending Files. Sending live photos by a URL is currently unsupported.

  • photo (object) – The static photo to send. Pass a file_id to send a file that exists on the Telegram servers (recommended) or pass ‘attach://’ to upload a new one using multipart/form-data under name. More information on Sending Files. Sending live photos by a URL is currently unsupported.

  • caption (str | None) – Caption of the live photo to be sent, 0-1024 characters after entities parsing

  • parse_mode (str | None) – Mode for parsing entities in the live photo caption. See formatting options for more details.

  • caption_entities (List[peyk.platforms.telegram.types.message_entity.MessageEntity] | None) – List of special entities that appear in the caption, which can be specified instead of parse_mode

  • show_caption_above_media (bool | None) – Pass True if the caption must be shown above the message media

  • has_spoiler (bool | None) – Pass True if the live photo needs to be covered with a spoiler animation

caption: str | None = None
caption_entities: List[MessageEntity] | None = None
has_spoiler: bool | None = None
parse_mode: str | None = None
show_caption_above_media: bool | None = None
to_dict(media: str, photo: str) Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Parameters:
  • media – Value used by this operation.

  • photo – Value used by this operation.

Returns:

Result produced by the operation.

media: object
photo: object
class peyk.platforms.telegram.InputMediaLocation(latitude: float, longitude: float, horizontal_accuracy: float | None = None)[source]

Bases: object

Represents a location to be sent.

Variables:
  • type – Type of the media, must be location

  • latitude (float) – Latitude of the location

  • longitude (float) – Longitude of the location

  • horizontal_accuracy (float | None) – The radius of uncertainty for the location, measured in meters; 0-1500

horizontal_accuracy: float | None = None
to_dict() Dict[str, object][source]

Serialize this type to the Telegram API request shape.

Returns:

A JSON-compatible mapping representing this value.

latitude: float
longitude: float
class peyk.platforms.telegram.InputMediaPhoto(media: object, caption: str | None = None, parse_mode: str | None = None, caption_entities: List[MessageEntity] | None = None, show_caption_above_media: bool | None = None, has_spoiler: bool | None = None)[source]

Bases: object

Represents a photo to be sent.

Variables:
  • type – Type of the media, must be photo

  • media (object) – File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass ‘attach://’ to upload a new one using multipart/form-data under name. More information on Sending Files

  • caption (str | None) – Caption of the photo to be sent, 0-1024 characters after entities parsing

  • parse_mode (str | None) – Mode for parsing entities in the photo caption. See formatting options for more details.

  • caption_entities (List[peyk.platforms.telegram.types.message_entity.MessageEntity] | None) – List of special entities that appear in the caption, which can be specified instead of parse_mode

  • show_caption_above_media (bool | None) – Pass True if the caption must be shown above the message media

  • has_spoiler (bool | None) – Pass True if the photo needs to be covered with a spoiler animation

caption: str | None = None
caption_entities: List[MessageEntity] | None = None
has_spoiler: bool | None = None
parse_mode: str | None = None
show_caption_above_media: bool | None = None
to_dict(media: str) Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Parameters:

media – Value used by this operation.

Returns:

Result produced by the operation.

media: object
class peyk.platforms.telegram.InputMediaSticker(media: object, type: str = 'sticker', emoji: str | None = None, mask_position: object | None = None)[source]

Bases: object

Represents a sticker file to be sent.

Variables:
  • type (str) – Type of the media, must be sticker

  • media (object) – File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a .WEBP sticker from the Internet, or pass ‘attach://’ to upload a new .WEBP, .TGS, or .WEBM sticker using multipart/form-data under name. More information on Sending Files

  • emoji (str | None) – Emoji associated with the sticker; only for just uploaded stickers

emoji: str | None = None
mask_position: object | None = None
to_dict(media_ref: str) Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Parameters:

media_ref – Value used by this operation.

Returns:

Result produced by the operation.

type: str = 'sticker'
media: object
class peyk.platforms.telegram.InputMediaType(*values)[source]

Bases: str, Enum

InputMediaType defines a public API type for peyk.

ANIMATION = 'animation'
DOCUMENT = 'document'
AUDIO = 'audio'
PHOTO = 'photo'
VIDEO = 'video'
class peyk.platforms.telegram.InputMediaVenue(latitude: float, longitude: float, title: str, address: str, foursquare_id: str | None = None, foursquare_type: str | None = None, google_place_id: str | None = None, google_place_type: str | None = None)[source]

Bases: object

Represents a venue to be sent.

Variables:
  • type – Type of the media, must be venue

  • latitude (float) – Latitude of the location

  • longitude (float) – Longitude of the location

  • title (str) – Name of the venue

  • address (str) – Address of the venue

  • foursquare_id (str | None) – Foursquare identifier of the venue

  • foursquare_type (str | None) – Foursquare type of the venue, if known. (For example, ‘arts_entertainment/default’, ‘arts_entertainment/aquarium’ or ‘food/icecream’.)

  • google_place_id (str | None) – Google Places identifier of the venue

  • google_place_type (str | None) – Google Places type of the venue. (See supported types.)

foursquare_id: str | None = None
foursquare_type: str | None = None
google_place_id: str | None = None
google_place_type: str | None = None
to_dict() Dict[str, object][source]

Serialize this type to the Telegram API request shape.

Returns:

A JSON-compatible mapping representing this value.

latitude: float
longitude: float
title: str
address: str
class peyk.platforms.telegram.InputMediaVideo(media: object, thumbnail: object | None = None, cover: object | None = None, caption: str | None = None, parse_mode: str | None = None, caption_entities: List[MessageEntity] | None = None, show_caption_above_media: bool | None = None, width: int | None = None, height: int | None = None, duration: int | None = None, supports_streaming: bool | None = None, has_spoiler: bool | None = None, start_timestamp: int | None = None)[source]

Bases: object

Represents a video to be sent.

Variables:
  • type – Type of the media, must be video

  • media (object) – File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass ‘attach://’ to upload a new one using multipart/form-data under name. More information on Sending Files

  • thumbnail (object | None) – Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail’s width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass ‘attach://’ if the thumbnail was uploaded using multipart/form-data under . More information on Sending Files

  • cover (object | None) – Cover for the video in the message. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass ‘attach://’ to upload a new one using multipart/form-data under name. More information on Sending Files

  • start_timestamp (int | None) – Start timestamp for the video in the message

  • caption (str | None) – Caption of the video to be sent, 0-1024 characters after entities parsing

  • parse_mode (str | None) – Mode for parsing entities in the video caption. See formatting options for more details.

  • caption_entities (List[peyk.platforms.telegram.types.message_entity.MessageEntity] | None) – List of special entities that appear in the caption, which can be specified instead of parse_mode

  • show_caption_above_media (bool | None) – Pass True if the caption must be shown above the message media

  • width (int | None) – Video width

  • height (int | None) – Video height

  • duration (int | None) – Video duration in seconds

  • supports_streaming (bool | None) – Pass True if the uploaded video is suitable for streaming

  • has_spoiler (bool | None) – Pass True if the video needs to be covered with a spoiler animation

caption: str | None = None
caption_entities: List[MessageEntity] | None = None
cover: object | None = None
duration: int | None = None
has_spoiler: bool | None = None
height: int | None = None
parse_mode: str | None = None
show_caption_above_media: bool | None = None
start_timestamp: int | None = None
supports_streaming: bool | None = None
thumbnail: object | None = None
to_dict(media: str, thumbnail: str | None = None, cover: str | None = None) Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Parameters:
  • media – Value used by this operation.

  • thumbnail – Value used by this operation.

  • cover – Value used by this operation.

Returns:

Result produced by the operation.

width: int | None = None
media: object
class peyk.platforms.telegram.InputMediaVoiceNote(media: object, type: str = 'voice_note', duration: int | None = None, waveform: str | None = None)[source]

Bases: object

Represents a voice message file to be sent.

Variables:
  • type (str) – Type of the media, must be voice_note

  • media (object) – File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass “attach://” to upload a new one using multipart/form-data under name. More information on Sending Files

  • caption – Caption of the voice message to be sent, 0-1024 characters after entities parsing

  • parse_mode – Mode for parsing entities in the voice message caption. See formatting options for more details.

  • caption_entities – List of special entities that appear in the caption, which can be specified instead of parse_mode

  • duration (int | None) – Duration of the voice message in seconds

duration: int | None = None
to_dict(media_ref: str) Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Parameters:

media_ref – Value used by this operation.

Returns:

Result produced by the operation.

type: str = 'voice_note'
waveform: str | None = None
media: object
class peyk.platforms.telegram.InputPaidMediaLivePhoto(media: object, photo: object, type: str = 'live_photo', caption: str | None = None, parse_mode: str | None = None, caption_entities: List[MessageEntity] | None = None, show_caption_above_media: bool | None = None, has_spoiler: bool | None = None)[source]

Bases: object

The paid media to send is a live photo.

Variables:
  • type (str) – Type of the media, must be live_photo

  • media (object) – Video of the live photo to send. Pass a file_id to send a file that exists on the Telegram servers (recommended) or pass ‘attach://’ to upload a new one using multipart/form-data under name. More information on Sending Files. Sending live photos by a URL is currently unsupported.

  • photo (object) – The static photo to send. Pass a file_id to send a file that exists on the Telegram servers (recommended) or pass ‘attach://’ to upload a new one using multipart/form-data under name. More information on Sending Files. Sending live photos by a URL is currently unsupported.

caption: str | None = None
caption_entities: List[MessageEntity] | None = None
has_spoiler: bool | None = None
parse_mode: str | None = None
show_caption_above_media: bool | None = None
to_dict(media_ref: str, photo_ref: str) Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Parameters:
  • media_ref – Value used by this operation.

  • photo_ref – Value used by this operation.

Returns:

Result produced by the operation.

type: str = 'live_photo'
media: object
photo: object
class peyk.platforms.telegram.InputPaidMediaPhoto(media: str, type: str = 'photo')[source]

Bases: object

The paid media to send is a photo.

Variables:
  • type (str) – Type of the media, must be photo

  • media (str) – File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass ‘attach://’ to upload a new one using multipart/form-data under name. More information on Sending Files

classmethod from_dict(data: dict | None) InputPaidMediaPhoto | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

type: str = 'photo'
media: str
class peyk.platforms.telegram.InputPaidMediaType(*values)[source]

Bases: StrEnum

Telegram input-paid-media discriminator values.

PHOTO = 'photo'
VIDEO = 'video'
LIVE_PHOTO = 'live_photo'
class peyk.platforms.telegram.InputPaidMediaVideo(media: str, type: str = 'video', thumbnail: str | None = None, cover: str | None = None, start_timestamp: int | None = None, width: int | None = None, height: int | None = None, duration: int | None = None, supports_streaming: bool | None = None)[source]

Bases: object

The paid media to send is a video.

Variables:
  • type (str) – Type of the media, must be video

  • media (str) – File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass ‘attach://’ to upload a new one using multipart/form-data under name. More information on Sending Files

  • thumbnail (str | None) – Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail’s width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass ‘attach://’ if the thumbnail was uploaded using multipart/form-data under . More information on Sending Files

  • cover (str | None) – Cover for the video in the message. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass ‘attach://’ to upload a new one using multipart/form-data under name. More information on Sending Files

  • start_timestamp (int | None) – Start timestamp for the video in the message

  • width (int | None) – Video width

  • height (int | None) – Video height

  • duration (int | None) – Video duration in seconds

  • supports_streaming (bool | None) – Pass True if the uploaded video is suitable for streaming

cover: str | None = None
duration: int | None = None
classmethod from_dict(data: dict | None) InputPaidMediaVideo | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

height: int | None = None
start_timestamp: int | None = None
supports_streaming: bool | None = None
thumbnail: str | None = None
type: str = 'video'
width: int | None = None
media: str
class peyk.platforms.telegram.InputPollOption(text: str, text_parse_mode: str | None = None, text_entities: List[MessageEntity] | None = None, media: InputMediaPhoto | InputMediaVideo | InputMediaAnimation | InputMediaLink | InputMediaLivePhoto | InputMediaLocation | InputMediaVenue | None = None)[source]

Bases: object

This object contains information about one answer option in a poll to be sent.

Variables:
media: InputMediaPhoto | InputMediaVideo | InputMediaAnimation | InputMediaLink | InputMediaLivePhoto | InputMediaLocation | InputMediaVenue | None = None
text_entities: List[MessageEntity] | None = None
text_parse_mode: str | None = None
to_dict() Dict[str, object][source]

Serialize this type to the Telegram API request shape.

Returns:

A JSON-compatible mapping representing this value.

Raises:

ValueError – Raised when the operation cannot complete.

text: str
class peyk.platforms.telegram.InputProfilePhotoAnimated(photo: object, type: str = 'animated', main_frame_timestamp: float | None = None)[source]

Bases: object

An animated profile photo in the MPEG4 format.

Variables:
  • type (str) – Type of the profile photo, must be animated

  • animation – The animated profile photo. Profile photos can’t be reused and can only be uploaded as a new file, so you can pass ‘attach://’ if the photo was uploaded using multipart/form-data under . More information on Sending Files

  • main_frame_timestamp (float | None) – Timestamp in seconds of the frame that will be used as the static profile photo. Defaults to 0.0.

main_frame_timestamp: float | None = None
to_dict(photo_ref: str) Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Parameters:

photo_ref – Value used by this operation.

Returns:

Result produced by the operation.

type: str = 'animated'
photo: object
class peyk.platforms.telegram.InputProfilePhotoStatic(photo: object, type: str = 'static')[source]

Bases: object

A static profile photo in the .JPG format.

Variables:
  • type (str) – Type of the profile photo, must be static

  • photo (object) – The static profile photo. Profile photos can’t be reused and can only be uploaded as a new file, so you can pass ‘attach://’ if the photo was uploaded using multipart/form-data under . More information on Sending Files

to_dict(photo_ref: str) Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Parameters:

photo_ref – Value used by this operation.

Returns:

Result produced by the operation.

type: str = 'static'
photo: object
class peyk.platforms.telegram.InputProfilePhotoType(*values)[source]

Bases: StrEnum

Telegram input-profile-photo discriminator values.

STATIC = 'static'
ANIMATED = 'animated'
class peyk.platforms.telegram.InputRichBlockAnchor(name: str = '', text: str = '')[source]

Bases: object

A block with an anchor, corresponding to the HTML tag with the attribute name.

Variables:
  • type – Type of the block, always ‘anchor’

  • name (str) – The name of the anchor

name: str = ''
text: str = ''
to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

class peyk.platforms.telegram.InputRichBlockAnimation(animation: object = None, caption: str | None = None)[source]

Bases: object

A block with an animation, corresponding to the HTML tag .

Variables:
  • type – Type of the block, always ‘animation’

  • animation (object) – The animation. Caption is ignored.

  • caption (str | None) – Caption of the block

animation: object = None
caption: str | None = None
to_dict(media_ref: str) Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Parameters:

media_ref – Value used by this operation.

Returns:

Result produced by the operation.

class peyk.platforms.telegram.InputRichBlockAudio(audio: object = None, caption: str | None = None)[source]

Bases: object

A block with a music file, corresponding to the HTML tag .

Variables:
  • type – Type of the block, always ‘audio’

  • audio (object) – The audio. Caption is ignored.

  • caption (str | None) – Caption of the block

audio: object = None
caption: str | None = None
to_dict(media_ref: str) Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Parameters:

media_ref – Value used by this operation.

Returns:

Result produced by the operation.

class peyk.platforms.telegram.InputRichBlockBlockQuotation(text: str = '')[source]

Bases: object

A block quotation, corresponding to the HTML tag .

Variables:
  • type – Type of the block, always ‘blockquote’

  • blocks – Content of the block

  • credit – Credit of the block

text: str = ''
to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

class peyk.platforms.telegram.InputRichBlockButtons(buttons: List[object] | None = None)[source]

Bases: object

InputRichBlockButtons Telegram Bot API type.

buttons: List[object] | None = None
to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

class peyk.platforms.telegram.InputRichBlockCollage(items: List[object] | None = None)[source]

Bases: object

A collage, corresponding to the custom HTML tag .

Variables:
  • type – Type of the block, always ‘collage’

  • blocks – Elements of the collage

  • caption – Caption of the block

items: List[object] | None = None
to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

class peyk.platforms.telegram.InputRichBlockDetails(title: str = '', text: str = '')[source]

Bases: object

An expandable block for details disclosure, corresponding to the HTML tag .

Variables:
  • type – Type of the block, always ‘details’

  • summary – Always shown summary of the block

  • blocks – Content of the block

  • is_open – Pass True if the content of the block is visible by default

text: str = ''
title: str = ''
to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

class peyk.platforms.telegram.InputRichBlockDivider[source]

Bases: object

A divider, corresponding to the HTML tag .

Variables:

type – Type of the block, always ‘divider’

to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

class peyk.platforms.telegram.InputRichBlockDocument(document: object = None, caption: str | None = None)[source]

Bases: object

InputRichBlockDocument Telegram Bot API type.

caption: str | None = None
document: object = None
to_dict(media_ref: str) Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Parameters:

media_ref – Value used by this operation.

Returns:

Result produced by the operation.

class peyk.platforms.telegram.InputRichBlockExpandableBlockQuotation(text: str = '')[source]

Bases: object

InputRichBlockExpandableBlockQuotation Telegram Bot API type.

text: str = ''
to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

class peyk.platforms.telegram.InputRichBlockFooter(text: str = '')[source]

Bases: object

A footer, corresponding to the HTML tag .

Variables:
  • type – Type of the block, always ‘footer’

  • text (str) – Text of the block

text: str = ''
to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

class peyk.platforms.telegram.InputRichBlockList(items: List[object] | None = None)[source]

Bases: object

A list of blocks, corresponding to the HTML tag or with multiple nested tags .

Variables:
  • type – Type of the block, always ‘list’

  • items (List[object] | None) – Items of the list

items: List[object] | None = None
to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

class peyk.platforms.telegram.InputRichBlockListItem(text: str = '', parse_mode: str | None = None, text_entities: List[MessageEntity] | None = None)[source]

Bases: object

An item of a list to be sent.

Variables:
  • blocks – The content of the item

  • has_checkbox – Pass True if the item has a checkbox

  • is_checked – Pass True if the item has a checked checkbox

  • value – For ordered lists, the numeric value of the item label

  • type – For ordered lists, the type of the item label; must be one of ‘a’ for lowercase letters, ‘A’ for uppercase letters, ‘i’ for lowercase Roman numerals, ‘I’ for uppercase Roman numerals, or ‘1’ for decimal numbers

parse_mode: str | None = None
text: str = ''
text_entities: List[MessageEntity] | None = None
to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

class peyk.platforms.telegram.InputRichBlockMap(latitude: float = 0.0, longitude: float = 0.0)[source]

Bases: object

A block with a map, corresponding to the custom HTML tag . The map’s width and height must not exceed 10000 in total. The width and height ratio must be at most 20.

Variables:
  • type – Type of the block, always ‘map’

  • location – Location of the center of the map

  • zoom – Map zoom level; 0-24

  • width – Map width; 0-10000

  • height – Map height; 0-10000

  • caption – Caption of the block

latitude: float = 0.0
longitude: float = 0.0
to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

class peyk.platforms.telegram.InputRichBlockMathematicalExpression(expression: str = '')[source]

Bases: object

A block with a mathematical expression in LaTeX format, corresponding to the custom HTML tag .

Variables:
  • type – Type of the block, always ‘mathematical_expression’

  • expression (str) – The mathematical expression in LaTeX format

expression: str = ''
to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

class peyk.platforms.telegram.InputRichBlockParagraph(text: str = '')[source]

Bases: object

A text paragraph, corresponding to the HTML tag .

Variables:
  • type – Type of the block, always ‘paragraph’

  • text (str) – Text of the block

text: str = ''
to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

class peyk.platforms.telegram.InputRichBlockPhoto(photo: object = None, caption: str | None = None)[source]

Bases: object

A block with a photo, corresponding to the HTML tag .

Variables:
  • type – Type of the block, always ‘photo’

  • photo (object) – The photo. Caption is ignored.

  • caption (str | None) – Caption of the block

caption: str | None = None
photo: object = None
to_dict(media_ref: str) Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Parameters:

media_ref – Value used by this operation.

Returns:

Result produced by the operation.

class peyk.platforms.telegram.InputRichBlockPreformatted(text: str = '', language: str = '')[source]

Bases: object

A preformatted text block, corresponding to the nested HTML tags and .

Variables:
  • type – Type of the block, always ‘pre’

  • text (str) – Text of the block

  • language (str) – The programming language of the text

language: str = ''
text: str = ''
to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

class peyk.platforms.telegram.InputRichBlockPullQuotation(text: str = '')[source]

Bases: object

A quotation with centered text, loosely corresponding to the HTML tag .

Variables:
  • type – Type of the block, always ‘pullquote’

  • text (str) – Text of the block

  • credit – Credit of the block

text: str = ''
to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

class peyk.platforms.telegram.InputRichBlockSectionHeading(text: str = '')[source]

Bases: object

A section heading, corresponding to the HTML tags , , , , , or .

Variables:
  • type – Type of the block, always ‘heading’

  • text (str) – Text of the block

  • size – Relative size of the text font; 1-6, 1 is the largest, 6 is the smallest

text: str = ''
to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

class peyk.platforms.telegram.InputRichBlockSlideshow(items: List[object] | None = None)[source]

Bases: object

A slideshow, corresponding to the custom HTML tag .

Variables:
  • type – Type of the block, always ‘slideshow’

  • blocks – Elements of the slideshow

  • caption – Caption of the block

items: List[object] | None = None
to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

class peyk.platforms.telegram.InputRichBlockTable(cells: List[object] | None = None, is_compact: bool | None = None)[source]

Bases: object

A table, corresponding to the HTML tag .

Variables:
  • type – Type of the block, always ‘table’

  • cells (List[object] | None) – Cells of the table

  • is_bordered – Pass True if the table has borders

  • is_striped – Pass True if the table is striped

  • caption – Caption of the table

cells: List[object] | None = None
is_compact: bool | None = None
to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

class peyk.platforms.telegram.InputRichBlockThinking(text: str = '')[source]

Bases: object

A block with a ‘Thinking…’ placeholder, corresponding to the custom HTML tag . The block may be used only in sendRichMessageDraft, therefore it can’t be received in messages. See https://t.me/addemoji/AIActions for examples of custom emoji that are recommended for usage in the block.

Variables:
  • type – Type of the block, always ‘thinking’

  • text (str) – Text of the block. See https://t.me/addemoji/AIActions for examples of custom emoji that are recommended for usage in the block.

text: str = ''
to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

class peyk.platforms.telegram.InputRichBlockType(*values)[source]

Bases: str, Enum

InputRichBlockType defines a public API type for peyk.

PARAGRAPH = 'paragraph'
HEADING = 'heading'
PRE = 'pre'
FOOTER = 'footer'
DIVIDER = 'divider'
MATHEMATICAL_EXPRESSION = 'mathematical_expression'
ANCHOR = 'anchor'
LIST = 'list'
BLOCKQUOTE = 'blockquote'
EXPANDABLE_BLOCKQUOTE = 'expandable_blockquote'
PULLQUOTE = 'pullquote'
COLLAGE = 'collage'
SLIDESHOW = 'slideshow'
TABLE = 'table'
DETAILS = 'details'
MAP = 'map'
BUTTONS = 'buttons'
ANIMATION = 'animation'
AUDIO = 'audio'
DOCUMENT = 'document'
PHOTO = 'photo'
VIDEO = 'video'
VOICE_NOTE = 'voice_note'
THINKING = 'thinking'
class peyk.platforms.telegram.InputRichBlockVideo(video: object = None, caption: str | None = None)[source]

Bases: object

A block with a video, corresponding to the HTML tag .

Variables:
  • type – Type of the block, always ‘video’

  • video (object) – The video. Caption is ignored.

  • caption (str | None) – Caption of the block

caption: str | None = None
to_dict(media_ref: str) Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Parameters:

media_ref – Value used by this operation.

Returns:

Result produced by the operation.

video: object = None
class peyk.platforms.telegram.InputRichBlockVoiceNote(voice: object = None, caption: str | None = None)[source]

Bases: object

A block with a voice note, corresponding to the HTML tag .

Variables:
  • type – Type of the block, always ‘voice_note’

  • voice_note – The voice note. Caption is ignored.

  • caption (str | None) – Caption of the block

caption: str | None = None
to_dict(media_ref: str) Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Parameters:

media_ref – Value used by this operation.

Returns:

Result produced by the operation.

voice: object = None
class peyk.platforms.telegram.InputRichMessage(text: str | None = None, parse_mode: str | None = None, blocks: object | None = None, media: object | None = None, is_rtl: bool | None = None, skip_entity_detection: bool | None = None)[source]

Bases: object

Describes a rich message to be sent. Exactly one of the fields html, markdown, or blocks must be used.

Variables:
  • html – Content of the rich message to send described using HTML formatting. See rich message formatting options for more details. Use media field to specify the media used in the message.

  • markdown – Content of the rich message to send described using Markdown formatting. See rich message formatting options for more details. Use media field to specify the media used in the message.

  • is_rtl (bool | None) – Pass True if the rich message must be shown right-to-left

  • skip_entity_detection (bool | None) – Pass True to skip automatic detection of entities (e.g., URLs, email addresses, username mentions, hashtags, cashtags, bot commands, or phone numbers) in the text

  • blocks (object | None) – Content of the rich message to send described as a list of blocks

  • media (object | None) – List of media that are specified in the markdown or html fields using tg://photo?id=, tg://video?id=, and tg://audio?id= links

blocks: object | None = None
classmethod from_dict(data: dict | None) InputRichMessage | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

is_rtl: bool | None = None
media: object | None = None
parse_mode: str | None = None
skip_entity_detection: bool | None = None
text: str | None = None
to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

class peyk.platforms.telegram.InputRichMessageContent(rich_message: InputRichMessage | None = None)[source]

Bases: object

Represents the content of a rich message to be sent as the result of an inline query.

Variables:

rich_message (peyk.platforms.telegram.types.input_rich_message.InputRichMessage | None) – The message to be sent

classmethod from_dict(data: dict | None) InputRichMessageContent | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

rich_message: InputRichMessage | None = None
to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

class peyk.platforms.telegram.InputRichMessageMedia(media: object = None, type: str | None = None)[source]

Bases: object

Describes a media element embedded in an outgoing rich message.

Variables:
  • id – Unique identifier of the media used in a tg://photo?id=, tg://video?id=, or tg://audio?id= link. 1-64 characters, only A-Z, a-z, 0-9, _ and - are allowed.

  • media (object) – The media to be sent. Everything except the media itself and its properties is ignored.

media: object = None
to_dict(media_ref: str) Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Parameters:

media_ref – Value used by this operation.

Returns:

Result produced by the operation.

type: str | None = None
class peyk.platforms.telegram.InputSticker(sticker: object, format: str, emoji_list: List[str], mask_position: MaskPosition | None = None, keywords: List[str] | None = None)[source]

Bases: object

This object describes a sticker to be added to a sticker set.

Variables:
  • sticker (object) – The added sticker. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or pass ‘attach://’ to upload a new file using multipart/form-data under name. Animated and video stickers can’t be uploaded via HTTP URL. More information on Sending Files

  • format (str) – Format of the added sticker, must be one of ‘static’ for a .WEBP or .PNG image, ‘animated’ for a .TGS animation, ‘video’ for a .WEBM video

  • emoji_list (List[str]) – List of 1-20 emoji associated with the sticker

  • mask_position (peyk.platforms.telegram.types.mask_position.MaskPosition | None) – Position where the mask should be placed on faces. For ‘mask’ stickers only.

  • keywords (List[str] | None) – List of 0-20 search keywords for the sticker with total length of up to 64 characters. For ‘regular’ and ‘custom_emoji’ stickers only.

keywords: List[str] | None = None
mask_position: MaskPosition | None = None
to_dict(sticker_ref: str) Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Parameters:

sticker_ref – Value used by this operation.

Returns:

Result produced by the operation.

sticker: object
format: str
emoji_list: List[str]
class peyk.platforms.telegram.InputStoryContentPhoto(media: object = None, photo: object = None, type: str = 'photo', caption: str | None = None, parse_mode: str | None = None, caption_entities: List[MessageEntity] | None = None)[source]

Bases: object

Describes a photo to post as a story.

Variables:
  • type (str) – Type of the content, must be photo

  • photo (object) – The photo to post as a story. The photo must be of the size 1080x1920 and must not exceed 10 MB. The photo can’t be reused and can only be uploaded as a new file, so you can pass ‘attach://’ if the photo was uploaded using multipart/form-data under . More information on Sending Files

caption: str | None = None
caption_entities: List[MessageEntity] | None = None
classmethod from_dict(data: dict | None) InputStoryContentPhoto | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

media: object = None
parse_mode: str | None = None
photo: object = None
to_dict(media_ref: str | None = None) Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Parameters:

media_ref – Value used by this operation.

Returns:

Result produced by the operation.

type: str = 'photo'
class peyk.platforms.telegram.InputStoryContentType(*values)[source]

Bases: StrEnum

Telegram input-story-content discriminator values.

PHOTO = 'photo'
VIDEO = 'video'
class peyk.platforms.telegram.InputStoryContentVideo(video: str, type: str = 'video', duration: float | None = None, cover_frame_timestamp: float | None = None, is_animation: bool | None = None)[source]

Bases: object

Describes a video to post as a story.

Variables:
  • type (str) – Type of the content, must be video

  • video (str) – The video to post as a story. The video must be of the size 720x1280, streamable, encoded with H.265 codec, with key frames added each second in the MPEG4 format, and must not exceed 30 MB. The video can’t be reused and can only be uploaded as a new file, so you can pass ‘attach://’ if the video was uploaded using multipart/form-data under . More information on Sending Files

  • duration (float | None) – Precise duration of the video in seconds; 0-60

  • cover_frame_timestamp (float | None) – Timestamp in seconds of the frame that will be used as the static cover for the story. Defaults to 0.0.

  • is_animation (bool | None) – Pass True if the video has no sound

cover_frame_timestamp: float | None = None
duration: float | None = None
classmethod from_dict(data: dict | None) InputStoryContentVideo | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

is_animation: bool | None = None
type: str = 'video'
video: str
class peyk.platforms.telegram.InputTextMessageContent(message_text: str, parse_mode: str | None = None, entities: Sequence[MessageEntity | Mapping[str, object]] | None = None, link_preview_options: LinkPreviewOptions | Mapping[str, object] | None = None)[source]

Bases: object

Represents the content of a text message to be sent as the result of an inline query.

Variables:
  • message_text (str) – Text of the message to be sent, 1-4096 characters

  • parse_mode (str | None) – Mode for parsing entities in the message text. See formatting options for more details.

  • entities (Sequence[peyk.platforms.telegram.types.message_entity.MessageEntity | Mapping[str, object]] | None) – List of special entities that appear in message text, which can be specified instead of parse_mode

  • link_preview_options (peyk.platforms.telegram.types.link_preview_options.LinkPreviewOptions | Mapping[str, object] | None) – Link preview generation options for the message

  • disable_web_page_preview – Disables link previews for links in the sent message

entities: Sequence[MessageEntity | Mapping[str, object]] | None = None
parse_mode: str | None = None
to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

message_text: str
class peyk.platforms.telegram.InputVenueMessageContent(latitude: float, longitude: float, title: str, address: str, foursquare_id: str | None = None, foursquare_type: str | None = None, google_place_id: str | None = None, google_place_type: str | None = None)[source]

Bases: object

Represents the content of a venue message to be sent as the result of an inline query.

Variables:
  • latitude (float) – Latitude of the venue in degrees

  • longitude (float) – Longitude of the venue in degrees

  • title (str) – Name of the venue

  • address (str) – Address of the venue

  • foursquare_id (str | None) – Foursquare identifier of the venue, if known

  • foursquare_type (str | None) – Foursquare type of the venue, if known. (For example, ‘arts_entertainment/default’, ‘arts_entertainment/aquarium’ or ‘food/icecream’.)

  • google_place_id (str | None) – Google Places identifier of the venue

  • google_place_type (str | None) – Google Places type of the venue. (See supported types.)

foursquare_id: str | None = None
foursquare_type: str | None = None
google_place_id: str | None = None
google_place_type: str | None = None
to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

latitude: float
longitude: float
title: str
address: str
class peyk.platforms.telegram.Invoice(title: str, description: str, start_parameter: str, currency: str, total_amount: int)[source]

Bases: object

This object contains basic information about an invoice.

Variables:
  • title (str) – Product name

  • description (str) – Product description

  • start_parameter (str) – Unique bot deep-linking parameter that can be used to generate this invoice

  • currency (str) – Three-letter ISO 4217 currency code, or ‘XTR’ for payments in Telegram Stars

  • total_amount (int) – Total price in the smallest units of the currency (integer, not float/double). For example, for a price of US$ 1.45 pass amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies).

classmethod from_dict(data: dict | None) Invoice | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

title: str
description: str
start_parameter: str
currency: str
total_amount: int
class peyk.platforms.telegram.KeyboardButton(text: str = '', icon_custom_emoji_id: str | None = None, style: str | None = None, request_users: KeyboardButtonRequestUsers | None = None, request_chat: KeyboardButtonRequestChat | None = None, request_managed_bot: KeyboardButtonRequestManagedBot | None = None, request_contact: bool | None = None, request_location: bool | None = None, request_poll: KeyboardButtonPollType | None = None, web_app: WebAppInfo | None = None)[source]

Bases: object

This object represents one button of the reply keyboard. At most one of the fields other than text, icon_custom_emoji_id, and style must be used to specify the type of the button. For simple text buttons, String can be used instead of this object to specify the button text.

Variables:
  • text (str) – Text of the button. If none of the fields other than text, icon_custom_emoji_id, and style are used, it will be sent as a message when the button is pressed.

  • icon_custom_emoji_id (str | None) – Unique identifier of the custom emoji shown before the text of the button. Can only be used by bots that purchased additional usernames on Fragment or in the messages directly sent by the bot to private, group and supergroup chats if the owner of the bot has a Telegram Premium subscription.

  • style (str | None) – Style of the button. Must be one of ‘danger’ (red), ‘success’ (green) or ‘primary’ (blue). If omitted, then an app-specific style is used.

  • request_users (peyk.platforms.telegram.types.keyboard_button_request_users.KeyboardButtonRequestUsers | None) – If specified, pressing the button will open a list of suitable users. Identifiers of selected users will be sent to the bot in a ‘users_shared’ service message. Available in private chats only.

  • request_chat (peyk.platforms.telegram.types.keyboard_button_request_chat.KeyboardButtonRequestChat | None) – If specified, pressing the button will open a list of suitable chats. Tapping on a chat will send its identifier to the bot in a ‘chat_shared’ service message. Available in private chats only.

  • request_managed_bot (peyk.platforms.telegram.types.keyboard_button_request_managed_bot.KeyboardButtonRequestManagedBot | None) – If specified, pressing the button will ask the user to create and share a bot that will be managed by the current bot. Available for bots that enabled management of other bots in the @BotFather Mini App. Available in private chats only.

  • request_contact (bool | None) – If True, the user’s phone number will be sent as a contact when the button is pressed. Available in private chats only.

  • request_location (bool | None) – If True, the user’s current location will be sent when the button is pressed. Available in private chats only.

  • request_poll (peyk.platforms.telegram.types.keyboard_button_poll_type.KeyboardButtonPollType | None) – If specified, the user will be asked to create a poll and send it to the bot when the button is pressed. Available in private chats only.

  • web_app (peyk.platforms.telegram.types.web_app_info.WebAppInfo | None) – If specified, the described Web App will be launched when the button is pressed. The Web App will be able to send a ‘web_app_data’ service message. Available in private chats only.

  • request_user – If specified, pressing the button will open a list of suitable users. Tapping on any user will send their identifier to the bot in a ‘user_shared’ service message. Available in private chats only.

classmethod from_dict(data: dict | None) KeyboardButton | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

icon_custom_emoji_id: str | None = None
request_chat: KeyboardButtonRequestChat | None = None
request_contact: bool | None = None
request_location: bool | None = None
request_managed_bot: KeyboardButtonRequestManagedBot | None = None
request_poll: KeyboardButtonPollType | None = None
request_users: KeyboardButtonRequestUsers | None = None
style: str | None = None
text: str = ''
to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

web_app: WebAppInfo | None = None
class peyk.platforms.telegram.KeyboardButtonPollType(type: str | None = None)[source]

Bases: object

This object represents type of a poll, which is allowed to be created and sent when the corresponding button is pressed.

Variables:

type (str | None) – If quiz is passed, the user will be allowed to create only polls in the quiz mode. If regular is passed, only regular polls will be allowed. Otherwise, the user will be allowed to create a poll of any type.

classmethod from_dict(data: dict | None) KeyboardButtonPollType | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

type: str | None = None
class peyk.platforms.telegram.KeyboardButtonPollTypeType(*values)[source]

Bases: str, Enum

KeyboardButtonPollTypeType defines a public API type for peyk.

QUIZ = 'quiz'
REGULAR = 'regular'
class peyk.platforms.telegram.KeyboardButtonRequestChat(request_id: int = 0, chat_is_channel: bool = False, chat_is_forum: bool | None = None, chat_has_username: bool | None = None, chat_is_created: bool | None = None, user_administrator_rights: ChatAdministratorRights | None = None, bot_administrator_rights: ChatAdministratorRights | None = None, bot_is_member: bool | None = None, request_title: bool | None = None, request_username: bool | None = None, request_photo: bool | None = None)[source]

Bases: object

This object defines the criteria used to request a suitable chat. Information about the selected chat will be shared with the bot when the corresponding button is pressed. The bot will be granted requested rights in the chat if appropriate..

Variables:
  • request_id (int) – Signed 32-bit identifier of the request, which will be received back in the ChatShared object. Must be unique within the message.

  • chat_is_channel (bool) – Pass True to request a channel chat, pass False to request a group or a supergroup chat

  • chat_is_forum (bool | None) – Pass True to request a forum supergroup, pass False to request a non-forum chat. If not specified, no additional restrictions are applied.

  • chat_has_username (bool | None) – Pass True to request a supergroup or a channel with a username, pass False to request a chat without a username. If not specified, no additional restrictions are applied.

  • chat_is_created (bool | None) – Pass True to request a chat owned by the user. Otherwise, no additional restrictions are applied.

  • user_administrator_rights (peyk.platforms.telegram.types.chat_administrator_rights.ChatAdministratorRights | None) – A JSON-serialized object listing the required administrator rights of the user in the chat. The rights must be a superset of bot_administrator_rights. If not specified, no additional restrictions are applied.

  • bot_administrator_rights (peyk.platforms.telegram.types.chat_administrator_rights.ChatAdministratorRights | None) – A JSON-serialized object listing the required administrator rights of the bot in the chat. The rights must be a subset of user_administrator_rights. If not specified, no additional restrictions are applied.

  • bot_is_member (bool | None) – Pass True to request a chat with the bot as a member. Otherwise, no additional restrictions are applied.

  • request_title (bool | None) – Pass True to request the chat’s title

  • request_username (bool | None) – Pass True to request the chat’s username

  • request_photo (bool | None) – Pass True to request the chat’s photo

bot_administrator_rights: ChatAdministratorRights | None = None
bot_is_member: bool | None = None
chat_has_username: bool | None = None
chat_is_channel: bool = False
chat_is_created: bool | None = None
chat_is_forum: bool | None = None
classmethod from_dict(data: dict | None) KeyboardButtonRequestChat | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

request_id: int = 0
request_photo: bool | None = None
request_title: bool | None = None
request_username: bool | None = None
to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

user_administrator_rights: ChatAdministratorRights | None = None
class peyk.platforms.telegram.KeyboardButtonRequestManagedBot(request_id: int = 0, suggested_name: str | None = None, suggested_username: str | None = None)[source]

Bases: object

This object defines the parameters for the creation of a managed bot. Information about the created bot will be shared with the bot using the update managed_bot and a Message with the field managed_bot_created.

Variables:
  • request_id (int) – Signed 32-bit identifier of the request. Must be unique within the message.

  • suggested_name (str | None) – Suggested name for the bot

  • suggested_username (str | None) – Suggested username for the bot

classmethod from_dict(data: dict | None) KeyboardButtonRequestManagedBot | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

request_id: int = 0
suggested_name: str | None = None
suggested_username: str | None = None
to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

class peyk.platforms.telegram.KeyboardButtonRequestUsers(request_id: int = 0, user_is_bot: bool | None = None, user_is_premium: bool | None = None, max_quantity: int | None = None, request_name: bool | None = None, request_username: bool | None = None, request_photo: bool | None = None)[source]

Bases: object

This object defines the criteria used to request suitable users. Information about the selected users will be shared with the bot when the corresponding button is pressed.

Variables:
  • request_id (int) – Signed 32-bit identifier of the request that will be received back in the UsersShared object. Must be unique within the message.

  • user_is_bot (bool | None) – Pass True to request bots, pass False to request regular users. If not specified, no additional restrictions are applied.

  • user_is_premium (bool | None) – Pass True to request premium users, pass False to request non-premium users. If not specified, no additional restrictions are applied.

  • max_quantity (int | None) – The maximum number of users to be selected; 1-10. Defaults to 1.

  • request_name (bool | None) – Pass True to request the users’ first and last names

  • request_username (bool | None) – Pass True to request the users’ usernames

  • request_photo (bool | None) – Pass True to request the users’ photos

classmethod from_dict(data: dict | None) KeyboardButtonRequestUsers | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

max_quantity: int | None = None
request_id: int = 0
request_name: bool | None = None
request_photo: bool | None = None
request_username: bool | None = None
to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

user_is_bot: bool | None = None
user_is_premium: bool | None = None
class peyk.platforms.telegram.LabeledPrice(label: str, amount: int)[source]

Bases: object

This object represents a portion of the price for goods or services.

Variables:
  • label (str) – Portion label

  • amount (int) – Price of the product in the smallest units of the currency (integer, not float/double). For example, for a price of US$ 1.45 pass amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies).

classmethod from_dict(data: dict | None) LabeledPrice | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

label: str
amount: int

Bases: object

Represents an HTTP link.

Variables:

url (str) – URL of the link

classmethod from_dict(data: dict | None) Link | None[source]

Parse a Telegram API mapping into this type.

Parameters:

data – Raw Telegram API mapping, or None.

Returns:

Parsed type instance, or None when data is None.

url: str
class peyk.platforms.telegram.LinkPreviewOptions(is_disabled: bool | None = None, url: str | None = None, prefer_small_media: bool | None = None, prefer_large_media: bool | None = None, show_above_text: bool | None = None)[source]

Bases: object

Describes the options used for link preview generation.

Variables:
  • is_disabled (bool | None) – True, if the link preview is disabled

  • url (str | None) – URL to use for the link preview. If empty, then the first URL found in the message text will be used.

  • prefer_small_media (bool | None) – True, if the media in the link preview is supposed to be shrunk; ignored if the URL isn’t explicitly specified or media size change isn’t supported for the preview

  • prefer_large_media (bool | None) – True, if the media in the link preview is supposed to be enlarged; ignored if the URL isn’t explicitly specified or media size change isn’t supported for the preview

  • show_above_text (bool | None) – True, if the link preview must be shown above the message text; otherwise, the link preview will be shown below the message text

classmethod from_dict(data: dict | None) LinkPreviewOptions | None[source]

Parse a Telegram API mapping into this type.

Parameters:

data – Raw Telegram API mapping, or None.

Returns:

Parsed type instance, or None when data is None.

is_disabled: bool | None = None
prefer_large_media: bool | None = None
prefer_small_media: bool | None = None
show_above_text: bool | None = None
to_dict() Dict[str, object][source]

Serialize this type to the Telegram API request shape.

Returns:

A JSON-compatible mapping representing this value.

url: str | None = None
class peyk.platforms.telegram.LivePhoto(file_id: str, file_unique_id: str, width: int, height: int, duration: int, photo: List[PhotoSize] | None = None, mime_type: str | None = None, file_size: int | None = None)[source]

Bases: object

This object represents a live photo.

Variables:
  • file_id (str) – Identifier for the video file which can be used to download or reuse the file

  • file_unique_id (str) – Unique identifier for the video file which is supposed to be the same over time and for different bots. Can’t be used to download or reuse the file.

  • width (int) – Video width as defined by the sender

  • height (int) – Video height as defined by the sender

  • duration (int) – Duration of the video in seconds as defined by the sender

  • photo (List[peyk.platforms.telegram.types.photo_size.PhotoSize] | None) – Available sizes of the corresponding static photo

  • mime_type (str | None) – MIME type of the file as defined by the sender

  • file_size (int | None) – File size in bytes. It can be bigger than 2^31 and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this value.

file_size: int | None = None
classmethod from_dict(data: dict | None) LivePhoto | None[source]

Parse a Telegram API mapping into this type.

Parameters:

data – Raw Telegram API mapping, or None.

Returns:

Parsed type instance, or None when data is None.

mime_type: str | None = None
photo: List[PhotoSize] | None = None
file_id: str
file_unique_id: str
width: int
height: int
duration: int
class peyk.platforms.telegram.Location(latitude: float, longitude: float, horizontal_accuracy: float | None = None, live_period: int | None = None, heading: int | None = None, proximity_alert_radius: int | None = None)[source]

Bases: object

This object represents a point on the map.

Variables:
  • latitude (float) – Latitude as defined by the sender

  • longitude (float) – Longitude as defined by the sender

  • horizontal_accuracy (float | None) – The radius of uncertainty for the location, measured in meters; 0-1500

  • live_period (int | None) – Time relative to the message sending date, during which the location can be updated; in seconds. For active live locations only.

  • heading (int | None) – The direction in which user is moving, in degrees; 1-360. For active live locations only.

  • proximity_alert_radius (int | None) – The maximum distance for proximity alerts about approaching another chat member, in meters. For sent live locations only.

classmethod from_dict(data: dict | None) Location | None[source]

Parse a Telegram API mapping into this type.

Parameters:

data – Raw Telegram API mapping, or None.

Returns:

Parsed type instance, or None when data is None.

heading: int | None = None
horizontal_accuracy: float | None = None
live_period: int | None = None
proximity_alert_radius: int | None = None
latitude: float
longitude: float
class peyk.platforms.telegram.LocationAddress(country_code: str, state: str | None = None, city: str | None = None, street_line1: str | None = None, street_line2: str | None = None, post_code: str | None = None)[source]

Bases: object

Describes the physical address of a location.

Variables:
  • country_code (str) – The two-letter ISO 3166-1 alpha-2 country code of the country where the location is located

  • state (str | None) – State of the location

  • city (str | None) – City of the location

  • street – Street address of the location

city: str | None = None
classmethod from_dict(data: dict | None) LocationAddress | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

post_code: str | None = None
state: str | None = None
street_line1: str | None = None
street_line2: str | None = None
country_code: str
class peyk.platforms.telegram.LoginUrl(url: str = '', forward_text: str | None = None, bot_username: str | None = None, request_write_access: bool | None = None)[source]

Bases: object

This object represents a parameter of the inline keyboard button used to automatically authorize a user. Serves as a great replacement for the Telegram Login Widget when the user is coming from Telegram. All the user needs to do is tap/click a button and confirm that they want to log in: Telegram apps support these buttons as of version 5.7. Sample bot: @discussbot

Variables:

url (str) – An HTTPS URL to be opened with user authorization data added to the query string when the button is pressed. If the user refuses to provide authorization data, the original URL without information about the user will be opened. The data added is the same as described in Receiving authorization data.

NOTE: You must always check the hash of the received data to verify the authentication and the integrity of the data as described in Checking authorization.

forward_text: New text of the button in forwarded messages bot_username: Username of a bot, which will be used for user authorization. See Setting up a bot for more details. If not specified, the current bot’s username will be assumed. The url’s domain must be the same as the domain linked with the bot. See Linking your domain to the bot for more details. request_write_access: Pass True to request the permission for your bot to send messages to the user

bot_username: str | None = None
forward_text: str | None = None
classmethod from_dict(data: dict | None) LoginUrl | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

request_write_access: bool | None = None
to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

url: str = ''
class peyk.platforms.telegram.ManagedBotCreated(id: str = '', user: User | None = None)[source]

Bases: object

This object contains information about the bot that was created to be managed by the current bot.

Variables:

bot – Information about the bot. The bot’s token can be fetched using the method getManagedBotToken.

classmethod from_dict(data: dict | None) ManagedBotCreated | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

id: str = ''
user: User | None = None
class peyk.platforms.telegram.ManagedBotUpdated(id: str = '', user: User | None = None, token: str | None = None)[source]

Bases: object

This object contains information about the creation, token update, or owner update of a bot that is managed by the current bot.

Variables:
classmethod from_dict(data: dict | None) ManagedBotUpdated | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

id: str = ''
token: str | None = None
user: User | None = None
class peyk.platforms.telegram.MaskPosition(point: str, x_shift: float, y_shift: float, scale: float)[source]

Bases: object

This object describes the position on faces where a mask should be placed by default.

Variables:
  • point (str) – The part of the face relative to which the mask should be placed. One of ‘forehead’, ‘eyes’, ‘mouth’, or ‘chin’.

  • x_shift (float) – Shift by X-axis measured in widths of the mask scaled to the face size, from left to right. For example, choosing -1.0 will place mask just to the left of the default mask position.

  • y_shift (float) – Shift by Y-axis measured in heights of the mask scaled to the face size, from top to bottom. For example, 1.0 will place the mask just below the default mask position.

  • scale (float) – Mask scaling coefficient. For example, 2.0 means double size.

classmethod from_dict(data: dict | None) MaskPosition | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

point: str
x_shift: float
y_shift: float
scale: float
class peyk.platforms.telegram.MaskPositionPoint(*values)[source]

Bases: str, Enum

MaskPositionPoint defines a public API type for peyk.

FOREHEAD = 'forehead'
EYES = 'eyes'
MOUTH = 'mouth'
CHIN = 'chin'
class peyk.platforms.telegram.MenuButtonCommands(type: str = 'commands')[source]

Bases: object

Represents a menu button, which opens the bot’s list of commands.

Variables:

type (str) – Type of the button, must be commands

classmethod from_dict(data: dict | None) MenuButtonCommands | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

type: str = 'commands'
class peyk.platforms.telegram.MenuButtonDefault(type: str = 'default')[source]

Bases: object

Describes that no specific value for the menu button was set.

Variables:

type (str) – Type of the button, must be default

classmethod from_dict(data: dict | None) MenuButtonDefault | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

type: str = 'default'
class peyk.platforms.telegram.MenuButtonType(*values)[source]

Bases: str, Enum

MenuButtonType defines a public API type for peyk.

COMMANDS = 'commands'
WEB_APP = 'web_app'
DEFAULT = 'default'
class peyk.platforms.telegram.MenuButtonWebApp(type: str = 'web_app', text: str = '', web_app: WebAppInfo | None = None)[source]

Bases: object

Represents a menu button, which launches a Web App.

Variables:
  • type (str) – Type of the button, must be web_app

  • text (str) – Text on the button

  • web_app (peyk.platforms.telegram.types.web_app_info.WebAppInfo | None) – Description of the Web App that will be launched when the user presses the button. The Web App will be able to send an arbitrary message on behalf of the user using the method answerWebAppQuery. Alternatively, a t.me link to a Web App of the bot can be specified in the object instead of the Web App’s URL, in which case the Web App will be opened as if the user pressed the link.

classmethod from_dict(data: dict | None) MenuButtonWebApp | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

text: str = ''
to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

type: str = 'web_app'
web_app: WebAppInfo | None = None
class peyk.platforms.telegram.Message(message_id: int, date: int, chat: Chat, message_thread_id: int | None = None, from_: User | None = None, sender_chat: Chat | None = None, sender_boost_count: int | None = None, sender_business_bot: User | None = None, business_connection_id: str | None = None, forward_origin: object | None = None, is_topic_message: bool | None = None, is_automatic_forward: bool | None = None, reply_to_message: Message | None = None, external_reply: ExternalReplyInfo | None = None, quote: TextQuote | None = None, reply_to_story: object | None = None, via_bot: User | None = None, author_signature: str | None = None, text: str | None = None, entities: List[MessageEntity] | None = None, link_preview_options: object | None = None, effect_id: str | None = None, animation: Animation | None = None, audio: Audio | None = None, document: Document | None = None, paid_media: object | None = None, photo: List[PhotoSize] | None = None, sticker: object | None = None, story: object | None = None, video: Video | None = None, video_note: VideoNote | None = None, voice: Voice | None = None, live_photo: LivePhoto | None = None, caption: str | None = None, caption_entities: List[MessageEntity] | None = None, show_caption_above_media: bool | None = None, has_media_spoiler: bool | None = None, contact: Contact | None = None, dice: Dice | None = None, game: object | None = None, poll: Poll | None = None, venue: Venue | None = None, location: Location | None = None, new_chat_members: List[User] | None = None, left_chat_member: User | None = None, new_chat_title: str | None = None, new_chat_photo: object | None = None, delete_chat_photo: bool | None = None, group_chat_created: bool | None = None, supergroup_chat_created: bool | None = None, channel_chat_created: bool | None = None, message_auto_delete_timer_changed: object | None = None, migrate_to_chat_id: int | None = None, migrate_from_chat_id: int | None = None, pinned_message: Message | None = None, invoice: object | None = None, successful_payment: object | None = None, users_shared: object | None = None, chat_shared: object | None = None, connected_website: str | None = None, write_access_allowed: object | None = None, passport_data: object | None = None, proximity_alert_triggered: object | None = None, boost_added: object | None = None, chat_background_set: object | None = None, forum_topic_created: ForumTopicCreated | None = None, forum_topic_edited: ForumTopicEdited | None = None, forum_topic_closed: ForumTopicClosed | None = None, forum_topic_reopened: ForumTopicReopened | None = None, general_forum_topic_hidden: GeneralForumTopicHidden | None = None, general_forum_topic_unhidden: GeneralForumTopicUnhidden | None = None, giveaway_created: object | None = None, giveaway: object | None = None, giveaway_winners: object | None = None, giveaway_completed: object | None = None, paid_message_price_changed: object | None = None, video_chat_scheduled: object | None = None, video_chat_started: object | None = None, video_chat_ended: object | None = None, video_chat_participants_invited: object | None = None, web_app_data: object | None = None, reply_markup: InlineKeyboardMarkup | None = None)[source]

Bases: object

This object represents a message.

Variables:
  • message_id (int) – Unique message identifier inside this chat; 0 for ephemeral messages. In specific instances (e.g., a message containing a video sent to a big chat), the server might automatically schedule a message instead of sending it immediately. In such cases, this field will be 0 and the relevant message will be unusable until it is actually sent.

  • date (int) – Date the message was sent in Unix time. It is always a positive number, representing a valid date.

  • chat (peyk.platforms.telegram.types.chat.Chat) – Chat the message belongs to

  • message_thread_id (int | None) – Unique identifier of a message thread or forum topic to which the message belongs; for supergroups and private chats only

  • direct_messages_topic – Information about the direct messages chat topic that contains the message

  • from – Sender of the message; may be empty for messages sent to channels. For backward compatibility, if the message was sent on behalf of a chat, the field contains a fake sender user in non-channel chats.

  • sender_chat (peyk.platforms.telegram.types.chat.Chat | None) – Sender of the message when sent on behalf of a chat. For example, the supergroup itself for messages sent by its anonymous administrators or a linked channel for messages automatically forwarded to the channel’s discussion group. For backward compatibility, if the message was sent on behalf of a chat, the field from contains a fake sender user in non-channel chats.

  • sender_boost_count (int | None) – If the sender of the message boosted the chat, the number of boosts added by the user

  • sender_business_bot (peyk.platforms.telegram.types.user.User | None) – The bot that actually sent the message on behalf of the business account. Available only for outgoing messages sent on behalf of the connected business account.

  • sender_tag – Tag or custom title of the sender of the message; for supergroups only

  • guest_query_id – The unique identifier for the guest query. Use this identifier with the method answerGuestQuery to send a response message. If non-empty, the message belongs to the chat where the guest bot was summoned, which may not coincide with other existing bot chats sharing the same identifier.

  • business_connection_id (str | None) – Unique identifier of the business connection from which the message was received. If non-empty, the message belongs to a chat of the corresponding business account that is independent from any potential bot chat which might share the same identifier.

  • forward_origin (object | None) – Information about the original message for forwarded messages

  • is_topic_message (bool | None) – True, if the message is sent to a topic in a forum supergroup or a private chat with the bot

  • is_automatic_forward (bool | None) – True, if the message is a channel post that was automatically forwarded to the connected discussion group

  • reply_to_message (peyk.platforms.telegram.types.message.Message | None) – For replies in the same chat and message thread, the original message. Note that the Message object in this field will not contain further reply_to_message fields even if it itself is a reply. If the message is a reply to an ephemeral message, then this field may be omitted.

  • external_reply (peyk.platforms.telegram.types.external_reply_info.ExternalReplyInfo | None) – Information about the message that is being replied to, which may come from another chat or forum topic

  • quote (peyk.platforms.telegram.types.text_quote.TextQuote | None) – For replies that quote part of the original message, the quoted part of the message

  • reply_to_story (object | None) – For replies to a story, the original story

  • reply_to_checklist_task_id – Identifier of the specific checklist task that is being replied to

  • reply_to_poll_option_id – Persistent identifier of the specific poll option that is being replied to

  • via_bot (peyk.platforms.telegram.types.user.User | None) – Bot through which the message was sent

  • guest_bot_caller_user – For a message sent by a guest bot, this is the user whose original message triggered the bot’s response

  • guest_bot_caller_chat – For a message sent by a guest bot, this is the chat whose original message triggered the bot’s response

  • edit_date – Date the message was last edited in Unix time

  • has_protected_content – True, if the message can’t be forwarded

  • is_from_offline – True, if the message was sent by an implicit action, for example, as an away or a greeting business message, or as a scheduled message

  • is_paid_post – True, if the message is a paid post. Note that such posts must not be deleted for 24 hours to receive the payment and can’t be edited.

  • media_group_id – The unique identifier inside this chat of a media message group this message belongs to

  • author_signature (str | None) – Signature of the post author for messages in channels, or the custom title of an anonymous group administrator

  • paid_star_count – The number of Telegram Stars that were paid by the sender of the message to send it

  • text (str | None) – For text messages, the actual UTF-8 text of the message

  • entities (List[peyk.platforms.telegram.types.message_entity.MessageEntity] | None) – For text messages, special entities like usernames, URLs, bot commands, etc. that appear in the text

  • link_preview_options (object | None) – Options used for link preview generation for the message, if it is a text message and link preview options were changed

  • suggested_post_info – Information about suggested post parameters if the message is a suggested post in a channel direct messages chat. If the message is an approved or declined suggested post, then it can’t be edited.

  • effect_id (str | None) – Unique identifier of the message effect added to the message

  • animation (peyk.platforms.telegram.types.animation.Animation | None) – Message is an animation, information about the animation. For backward compatibility, when this field is set, the document field will also be set.

  • audio (peyk.platforms.telegram.types.audio.Audio | None) – Message is an audio file, information about the file

  • document (peyk.platforms.telegram.types.document.Document | None) – Message is a general file, information about the file

  • live_photo (peyk.platforms.telegram.types.live_photo.LivePhoto | None) – Message is a live photo, information about the live photo. For backward compatibility, when this field is set, the photo field will also be set.

  • paid_media (object | None) – Message contains paid media; information about the paid media

  • photo (List[peyk.platforms.telegram.types.photo_size.PhotoSize] | None) – Message is a photo, available sizes of the photo

  • sticker (object | None) – Message is a sticker, information about the sticker

  • story (object | None) – Message is a forwarded story

  • video (peyk.platforms.telegram.types.video.Video | None) – Message is a video, information about the video

  • video_note (peyk.platforms.telegram.types.video_note.VideoNote | None) – Message is a video note, information about the video message

  • voice (peyk.platforms.telegram.types.voice.Voice | None) – Message is a voice message, information about the file

  • caption (str | None) – Caption for the animation, audio, document, paid media, photo, video or voice

  • caption_entities (List[peyk.platforms.telegram.types.message_entity.MessageEntity] | None) – For messages with a caption, special entities like usernames, URLs, bot commands, etc. that appear in the caption

  • show_caption_above_media (bool | None) – True, if the caption must be shown above the message media

  • has_media_spoiler (bool | None) – True, if the message media is covered by a spoiler animation

  • checklist – Message is a checklist

  • contact (peyk.platforms.telegram.types.contact.Contact | None) – Message is a shared contact, information about the contact

  • dice (peyk.platforms.telegram.types.dice.Dice | None) – Message is a dice with random value

  • game (object | None) – Message is a game, information about the game.

  • poll (peyk.platforms.telegram.types.poll.Poll | None) – Message is a native poll, information about the poll

  • venue (peyk.platforms.telegram.types.venue.Venue | None) – Message is a venue, information about the venue. For backward compatibility, when this field is set, the location field will also be set.

  • location (peyk.platforms.telegram.types.location.Location | None) – Message is a shared location, information about the location

  • new_chat_members (List[peyk.platforms.telegram.types.user.User] | None) – New members that were added to the group or supergroup and information about them (the bot itself may be one of these members)

  • left_chat_member (peyk.platforms.telegram.types.user.User | None) – A member was removed from the group, information about them (this member may be the bot itself)

  • chat_owner_left – Service message: chat owner has left

  • chat_owner_changed – Service message: chat owner has changed

  • new_chat_title (str | None) – A chat title was changed to this value

  • new_chat_photo (object | None) – A chat photo was change to this value

  • delete_chat_photo (bool | None) – Service message: the chat photo was deleted

  • group_chat_created (bool | None) – Service message: the group has been created

  • supergroup_chat_created (bool | None) – Service message: the supergroup has been created. This field can’t be received in a message coming through updates, because bot can’t be a member of a supergroup when it is created. It can only be found in reply_to_message if someone replies to a very first message in a directly created supergroup.

  • channel_chat_created (bool | None) – Service message: the channel has been created. This field can’t be received in a message coming through updates, because bot can’t be a member of a channel when it is created. It can only be found in reply_to_message if someone replies to a very first message in a channel.

  • message_auto_delete_timer_changed (object | None) – Service message: auto-delete timer settings changed in the chat

  • migrate_to_chat_id (int | None) – The group has been migrated to a supergroup with the specified identifier. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this identifier.

  • migrate_from_chat_id (int | None) – The supergroup has been migrated from a group with the specified identifier. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this identifier.

  • pinned_message (peyk.platforms.telegram.types.message.Message | None) – Specified message was pinned. Note that the Message object in this field will not contain further reply_to_message fields even if it itself is a reply.

  • invoice (object | None) – Message is an invoice for a payment, information about the invoice.

  • successful_payment (object | None) – Message is a service message about a successful payment, information about the payment.

  • refunded_payment – Message is a service message about a refunded payment, information about the payment.

  • users_shared (object | None) – Service message: users were shared with the bot

  • chat_shared (object | None) – Service message: a chat was shared with the bot

  • gift – Service message: a regular gift was sent or received

  • unique_gift – Service message: a unique gift was sent or received

  • gift_upgrade_sent – Service message: upgrade of a gift was purchased after the gift was sent

  • connected_website (str | None) – The domain name of the website on which the user has logged in.

  • write_access_allowed (object | None) – Service message: the user allowed the bot to write messages after adding it to the attachment or side menu, launching a Web App from a link, or accepting an explicit request from a Web App sent by the method requestWriteAccess

  • passport_data (object | None) – Telegram Passport data

  • proximity_alert_triggered (object | None) – Service message. A user in the chat triggered another user’s proximity alert while sharing Live Location.

  • boost_added (object | None) – Service message: user boosted the chat

  • chat_background_set (object | None) – Service message: chat background set

  • checklist_tasks_done – Service message: some tasks in a checklist were marked as done or not done

  • checklist_tasks_added – Service message: tasks were added to a checklist

  • direct_message_price_changed – Service message: the price for paid messages in the corresponding direct messages chat of a channel has changed

  • forum_topic_created (peyk.platforms.telegram.types.forum_topic_created.ForumTopicCreated | None) – Service message: forum topic created

  • forum_topic_edited (peyk.platforms.telegram.types.forum_topic_edited.ForumTopicEdited | None) – Service message: forum topic edited

  • forum_topic_closed (peyk.platforms.telegram.types.forum_topic_closed.ForumTopicClosed | None) – Service message: forum topic closed

  • forum_topic_reopened (peyk.platforms.telegram.types.forum_topic_reopened.ForumTopicReopened | None) – Service message: forum topic reopened

  • general_forum_topic_hidden (peyk.platforms.telegram.types.general_forum_topic_hidden.GeneralForumTopicHidden | None) – Service message: the ‘General’ forum topic hidden

  • general_forum_topic_unhidden (peyk.platforms.telegram.types.general_forum_topic_unhidden.GeneralForumTopicUnhidden | None) – Service message: the ‘General’ forum topic unhidden

  • giveaway_created (object | None) – Service message: a scheduled giveaway was created

  • giveaway (object | None) – The message is a scheduled giveaway message

  • giveaway_winners (object | None) – A giveaway with public winners was completed

  • giveaway_completed (object | None) – Service message: a giveaway without public winners was completed

  • managed_bot_created – Service message: user created a bot that will be managed by the current bot

  • paid_message_price_changed (object | None) – Service message: the price for paid messages has changed in the chat

  • poll_option_added – Service message: answer option was added to a poll

  • poll_option_deleted – Service message: answer option was deleted from a poll

  • suggested_post_approved – Service message: a suggested post was approved

  • suggested_post_approval_failed – Service message: approval of a suggested post has failed

  • suggested_post_declined – Service message: a suggested post was declined

  • suggested_post_paid – Service message: payment for a suggested post was received

  • suggested_post_refunded – Service message: payment for a suggested post was refunded

  • video_chat_scheduled (object | None) – Service message: video chat scheduled

  • video_chat_started (object | None) – Service message: video chat started

  • video_chat_ended (object | None) – Service message: video chat ended

  • video_chat_participants_invited (object | None) – Service message: new participants invited to a video chat

  • web_app_data (object | None) – Service message: data sent by a Web App

  • reply_markup (peyk.platforms.telegram.types.inline_keyboard_markup.InlineKeyboardMarkup | None) – Inline keyboard attached to the message. login_url buttons are represented as ordinary url buttons.

  • rich_message – Message is a rich formatted message

  • receiver_user – For ephemeral messages, the user who received the message

  • ephemeral_message_id – For ephemeral messages, identifier of the ephemeral message inside this chat. The identifier may be reused for another ephemeral message after the message is deleted or expires.

  • community_chat_added – Service message: chat added to a Community

  • community_chat_removed – Service message: chat removed from a Community

  • forward_date – For forwarded messages, date the original message was sent in Unix time

  • forward_from – For forwarded messages, sender of the original message

  • forward_from_chat – For messages forwarded from channels or from anonymous administrators, information about the original sender chat

  • forward_from_message_id – For messages forwarded from channels, identifier of the original message in the channel

  • forward_sender_name – Sender’s name for messages forwarded from users who disallow adding a link to their account in forwarded messages

  • forward_signature – For forwarded messages that were originally sent in channels or by an anonymous chat administrator, signature of the message sender if present

  • user_shared – Service message: a user was shared with the bot

animation: Animation | None = None
audio: Audio | None = None
author_signature: str | None = None
boost_added: object | None = None
business_connection_id: str | None = None
caption: str | None = None
caption_entities: List[MessageEntity] | None = None
channel_chat_created: bool | None = None
chat_background_set: object | None = None
chat_boost = None
chat_owner_changed = None
chat_owner_left = None
chat_shared: object | None = None
checklist = None
community_chat_added = None
community_chat_joined = None
community_chat_removed = None
connected_website: str | None = None
contact: Contact | None = None
delete_chat_photo: bool | None = None
dice: Dice | None = None
direct_messages_topic = None
document: Document | None = None
edit_date = None
effect_id: str | None = None
entities: List[MessageEntity] | None = None
ephemeral_message_id = None
external_reply: ExternalReplyInfo | None = None
forum_topic_closed: ForumTopicClosed | None = None
forum_topic_created: ForumTopicCreated | None = None
forum_topic_edited: ForumTopicEdited | None = None
forum_topic_reopened: ForumTopicReopened | None = None
forward_origin: object | None = None
from_: User | None = None
classmethod from_dict(data)
game: object | None = None
general_forum_topic_hidden: GeneralForumTopicHidden | None = None
general_forum_topic_unhidden: GeneralForumTopicUnhidden | None = None
giveaway: object | None = None
giveaway_completed: object | None = None
giveaway_created: object | None = None
giveaway_winners: object | None = None
group_chat_created: bool | None = None
guest_bot_caller_chat = None
guest_bot_caller_user = None
guest_query_id = None
has_media_spoiler: bool | None = None
has_protected_content = None
invoice: object | None = None
is_automatic_forward: bool | None = None
is_from_offline = None
is_paid_post = None
is_topic_message: bool | None = None
left_chat_member: User | None = None
classmethod list_from_result(data: List[dict] | None) List[Message][source]

Parse a Telegram API result list into this type.

Parameters:

data – Raw result list, or None.

Returns:

Parsed type instances.

live_photo: LivePhoto | None = None
location: Location | None = None
media_group_id = None
message_auto_delete_timer_changed: object | None = None
message_thread_id: int | None = None
migrate_from_chat_id: int | None = None
migrate_to_chat_id: int | None = None
new_chat_members: List[User] | None = None
new_chat_photo: object | None = None
new_chat_title: str | None = None
paid_media: object | None = None
paid_message_price_changed: object | None = None
paid_star_count = None
passport_data: object | None = None
photo: List[PhotoSize] | None = None
pinned_message: Message | None = None
poll: Poll | None = None
proximity_alert_triggered: object | None = None
quote: TextQuote | None = None
receiver_user = None
refunded_payment = None
removed_chat_boost = None
reply_markup: InlineKeyboardMarkup | None = None
reply_to_message: Message | None = None
reply_to_story: object | None = None
rich_message = None
sender_boost_count: int | None = None
sender_business_bot: User | None = None
sender_chat: Chat | None = None
sender_tag = None
show_caption_above_media: bool | None = None
sticker: object | None = None
story: object | None = None
successful_payment: object | None = None
suggested_post_info = None
supergroup_chat_created: bool | None = None
text: str | None = None
users_shared: object | None = None
venue: Venue | None = None
via_bot: User | None = None
video: Video | None = None
video_chat_ended: object | None = None
video_chat_participants_invited: object | None = None
video_chat_scheduled: object | None = None
video_chat_started: object | None = None
video_note: VideoNote | None = None
voice: Voice | None = None
web_app_data: object | None = None
write_access_allowed: object | None = None
message_id: int
date: int
chat: Chat
class peyk.platforms.telegram.MessageAutoDeleteTimerChanged(message_auto_delete_time: int = 0)[source]

Bases: object

This object represents a service message about a change in auto-delete timer settings.

Variables:

message_auto_delete_time (int) – New auto-delete time for messages in the chat; in seconds

classmethod from_dict(data: dict | None) MessageAutoDeleteTimerChanged | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

message_auto_delete_time: int = 0
class peyk.platforms.telegram.MessageEntity(type: str, offset: int, length: int, url: str | None = None, user: User | None = None, language: str | None = None, custom_emoji_id: str | None = None)[source]

Bases: object

This object represents one special entity in a text message. For example, hashtags, usernames, URLs, etc.

Variables:
  • type (str) – Type of the entity. Currently, can be ‘mention’ (@username), ‘hashtag’ (#hashtag or #hashtag@chatusername), ‘cashtag’ ($USD or $USD@chatusername), ‘bot_command’ (/start@jobs_bot), ‘url’ (https://telegram.org), ‘email’ (do-not-reply@telegram.org), ‘phone_number’ (+1-212-555-0123), ‘bold’ (bold text), ‘italic’ (italic text), ‘underline’ (underlined text), ‘strikethrough’ (strikethrough text), ‘spoiler’ (spoiler message), ‘blockquote’ (block quotation), ‘expandable_blockquote’ (collapsed-by-default block quotation), ‘code’ (monowidth string), ‘pre’ (monowidth block), ‘text_link’ (for clickable text URLs), ‘text_mention’ (for users without usernames), ‘custom_emoji’ (for inline custom emoji stickers), or ‘date_time’ (for formatted date and time).

  • offset (int) – Offset in UTF-16 code units to the start of the entity

  • length (int) – Length of the entity in UTF-16 code units

  • url (str | None) – For ‘text_link’ only, URL that will be opened after user taps on the text

  • user (peyk.platforms.telegram.types.user.User | None) – For ‘text_mention’ only, the mentioned user

  • language (str | None) – For ‘pre’ only, the programming language of the entity text

  • custom_emoji_id (str | None) – For ‘custom_emoji’ only, unique identifier of the custom emoji. Use getCustomEmojiStickers to get full information about the sticker.

  • unix_time – For ‘date_time’ only, the Unix time associated with the entity

  • date_time_format – For ‘date_time’ only, the string that defines the formatting of the date and time. See date-time entity formatting for more details.

custom_emoji_id: str | None = None
classmethod from_dict(data: dict | None) MessageEntity | None[source]

Parse a Telegram API mapping into this type.

Parameters:

data – Raw Telegram API mapping, or None.

Returns:

Parsed type instance, or None when data is None.

language: str | None = None
classmethod list_from(data: List[dict] | None) List[MessageEntity] | None[source]

Parse a Telegram API result list into this type.

Parameters:

data – Raw result list, or None.

Returns:

Parsed type instances.

to_dict() Dict[str, object][source]

Serialize for outgoing request bodies (T2: send/edit params).

Returns:

The operation result (Dict[str, object]).

url: str | None = None
user: User | None = None
type: str
offset: int
length: int
class peyk.platforms.telegram.MessageEntityType(*values)[source]

Bases: StrEnum

Finite Telegram message-entity type values.

MENTION = 'mention'
HASHTAG = 'hashtag'
CASHTAG = 'cashtag'
BOT_COMMAND = 'bot_command'
URL = 'url'
EMAIL = 'email'
PHONE_NUMBER = 'phone_number'
BOLD = 'bold'
ITALIC = 'italic'
UNDERLINE = 'underline'
STRIKETHROUGH = 'strikethrough'
SPOILER = 'spoiler'
BLOCKQUOTE = 'blockquote'
CODE = 'code'
PRE = 'pre'
TEXT_MENTION = 'text_mention'
CUSTOM_EMOJI = 'custom_emoji'
class peyk.platforms.telegram.MessageGenerationStopped(chat_id: int = 0, message_id: int | None = None, message_thread_id: int | None = None, draft_id: int | None = None)[source]

Bases: object

MessageGenerationStopped Telegram Bot API type.

chat_id: int = 0
draft_id: int | None = None
classmethod from_dict(data: dict | None) MessageGenerationStopped | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

message_id: int | None = None
message_thread_id: int | None = None
class peyk.platforms.telegram.MessageId(message_id: int)[source]

Bases: object

This object represents a unique message identifier.

Variables:

message_id (int) – Unique message identifier. In specific instances (e.g., message containing a video sent to a big chat), the server might automatically schedule a message instead of sending it immediately. In such cases, this field will be 0 and the relevant message will be unusable until it is actually sent.

classmethod from_dict(data: dict | None) MessageId | None[source]

Parse a Telegram API mapping into this type.

Parameters:

data – Raw Telegram API mapping, or None.

Returns:

Parsed type instance, or None when data is None.

message_id: int
class peyk.platforms.telegram.MessageOriginChannel(type: str = 'channel', date: int = 0, chat: Chat | None = None, message_id: int | None = None, author_signature: str | None = None)[source]

Bases: object

The message was originally sent to a channel chat.

Variables:
  • type (str) – Type of the message origin, always ‘channel’

  • date (int) – Date the message was sent originally in Unix time

  • chat (peyk.platforms.telegram.types.chat.Chat | None) – Channel chat to which the message was originally sent

  • message_id (int | None) – Unique message identifier inside the chat

  • author_signature (str | None) – Signature of the original post author

author_signature: str | None = None
chat: Chat | None = None
date: int = 0
classmethod from_dict(data: dict | None) MessageOriginChannel | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

message_id: int | None = None
type: str = 'channel'
class peyk.platforms.telegram.MessageOriginChat(type: str = 'chat', date: int = 0, sender_chat: Chat | None = None, author_signature: str | None = None)[source]

Bases: object

The message was originally sent on behalf of a chat to a group chat.

Variables:
  • type (str) – Type of the message origin, always ‘chat’

  • date (int) – Date the message was sent originally in Unix time

  • sender_chat (peyk.platforms.telegram.types.chat.Chat | None) – Chat that sent the message originally

  • author_signature (str | None) – For messages originally sent by an anonymous chat administrator, original message author signature

author_signature: str | None = None
date: int = 0
classmethod from_dict(data: dict | None) MessageOriginChat | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

sender_chat: Chat | None = None
type: str = 'chat'
class peyk.platforms.telegram.MessageOriginHiddenUser(type: str = 'hidden_user', date: int = 0, sender_user_name: str = '')[source]

Bases: object

The message was originally sent by an unknown user.

Variables:
  • type (str) – Type of the message origin, always ‘hidden_user’

  • date (int) – Date the message was sent originally in Unix time

  • sender_user_name (str) – Name of the user that sent the message originally

date: int = 0
classmethod from_dict(data: dict | None) MessageOriginHiddenUser | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

sender_user_name: str = ''
type: str = 'hidden_user'
class peyk.platforms.telegram.MessageOriginType(*values)[source]

Bases: StrEnum

Telegram message-origin discriminator values.

USER = 'user'
HIDDEN_USER = 'hidden_user'
CHAT = 'chat'
CHANNEL = 'channel'
class peyk.platforms.telegram.MessageOriginUser(type: str = 'user', date: int = 0, sender_user: User | None = None)[source]

Bases: object

The message was originally sent by a known user.

Variables:
  • type (str) – Type of the message origin, always ‘user’

  • date (int) – Date the message was sent originally in Unix time

  • sender_user (peyk.platforms.telegram.types.user.User | None) – User that sent the message originally

date: int = 0
classmethod from_dict(data: dict | None) MessageOriginUser | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

sender_user: User | None = None
type: str = 'user'
class peyk.platforms.telegram.MessageReactionCountUpdated(chat: Chat, message_id: int, date: int, reactions: List[ReactionCount] | None = None)[source]

Bases: object

This object represents reaction changes on a message with anonymous reactions.

Variables:
classmethod from_dict(data: dict | None) MessageReactionCountUpdated | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

reactions: List[ReactionCount] | None = None
chat: Chat
message_id: int
date: int
class peyk.platforms.telegram.MessageReactionUpdated(chat: Chat, message_id: int, date: int, old_reaction: List[ReactionTypeEmoji | ReactionTypeCustomEmoji | ReactionTypePaid] | None = None, new_reaction: List[ReactionTypeEmoji | ReactionTypeCustomEmoji | ReactionTypePaid] | None = None, user: User | None = None, actor_chat: Chat | None = None)[source]

Bases: object

This object represents a change of a reaction on a message performed by a user.

Variables:
actor_chat: Chat | None = None
classmethod from_dict(data: dict | None) MessageReactionUpdated | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

new_reaction: List[ReactionTypeEmoji | ReactionTypeCustomEmoji | ReactionTypePaid] | None = None
old_reaction: List[ReactionTypeEmoji | ReactionTypeCustomEmoji | ReactionTypePaid] | None = None
user: User | None = None
chat: Chat
message_id: int
date: int
class peyk.platforms.telegram.OrderInfo(name: str | None = None, phone_number: str | None = None, email: str | None = None, shipping_address: ShippingAddress | None = None)[source]

Bases: object

This object represents information about an order.

Variables:
email: str | None = None
classmethod from_dict(data: dict | None) OrderInfo | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

name: str | None = None
phone_number: str | None = None
shipping_address: ShippingAddress | None = None
class peyk.platforms.telegram.OwnedGiftRegular(gift: Gift, send_date: int, type: str = 'regular', owned_gift_id: str | None = None, sender_user: User | None = None, text: str | None = None, entities: List[MessageEntity] | None = None, is_private: bool | None = None, is_saved: bool | None = None, can_be_upgraded: bool | None = None, was_refunded: bool | None = None, convert_star_count: int | None = None, prepaid_upgrade_star_count: int | None = None, is_upgrade_separate: bool | None = None, unique_gift_number: int | None = None)[source]

Bases: object

Describes a regular gift owned by a user or a chat.

Variables:
  • type (str) – Type of the gift, always ‘regular’

  • gift (peyk.platforms.telegram.types.gift.Gift) – Information about the regular gift

  • send_date (int) – Date the gift was sent in Unix time

  • owned_gift_id (str | None) – Unique identifier of the gift for the bot; for gifts received on behalf of business accounts only

  • sender_user (peyk.platforms.telegram.types.user.User | None) – Sender of the gift if it is a known user

  • text (str | None) – Text of the message that was added to the gift

  • entities (List[peyk.platforms.telegram.types.message_entity.MessageEntity] | None) – Special entities that appear in the text

  • is_private (bool | None) – True, if the sender and gift text are shown only to the gift receiver; otherwise, everyone will be able to see them

  • is_saved (bool | None) – True, if the gift is displayed on the account’s profile page; for gifts received on behalf of business accounts only

  • can_be_upgraded (bool | None) – True, if the gift can be upgraded to a unique gift; for gifts received on behalf of business accounts only

  • was_refunded (bool | None) – True, if the gift was refunded and isn’t available anymore

  • convert_star_count (int | None) – Number of Telegram Stars that can be claimed by the receiver instead of the gift; omitted if the gift cannot be converted to Telegram Stars; for gifts received on behalf of business accounts only

  • prepaid_upgrade_star_count (int | None) – Number of Telegram Stars that were paid for the ability to upgrade the gift

  • is_upgrade_separate (bool | None) – True, if the gift’s upgrade was purchased after the gift was sent; for gifts received on behalf of business accounts only

  • unique_gift_number (int | None) – Unique number reserved for this gift when upgraded. See the number field in UniqueGift.

can_be_upgraded: bool | None = None
convert_star_count: int | None = None
date = None
entities: List[MessageEntity] | None = None
classmethod from_dict(data)
is_private: bool | None = None
is_saved: bool | None = None
is_upgrade_separate: bool | None = None
owned_gift_id: str | None = None
prepaid_upgrade_star_count: int | None = None
sender_user: User | None = None
text: str | None = None
type: str = 'regular'
unique_gift_number: int | None = None
was_refunded: bool | None = None
gift: Gift
send_date: int
class peyk.platforms.telegram.OwnedGiftType(*values)[source]

Bases: StrEnum

Telegram owned-gift discriminator values.

REGULAR = 'regular'
UNIQUE = 'unique'
class peyk.platforms.telegram.OwnedGiftUnique(gift: UniqueGift, send_date: int, type: str = 'unique', owned_gift_id: str | None = None, sender_user: User | None = None, is_saved: bool | None = None, can_be_transferred: bool | None = None, transfer_star_count: int | None = None, next_transfer_date: int | None = None)[source]

Bases: object

Describes a unique gift received and owned by a user or a chat.

Variables:
  • type (str) – Type of the gift, always ‘unique’

  • gift (peyk.platforms.telegram.types.unique_gift.UniqueGift) – Information about the unique gift

  • send_date (int) – Date the gift was sent in Unix time

  • owned_gift_id (str | None) – Unique identifier of the received gift for the bot; for gifts received on behalf of business accounts only

  • sender_user (peyk.platforms.telegram.types.user.User | None) – Sender of the gift if it is a known user

  • is_saved (bool | None) – True, if the gift is displayed on the account’s profile page; for gifts received on behalf of business accounts only

  • can_be_transferred (bool | None) – True, if the gift can be transferred to another owner; for gifts received on behalf of business accounts only

  • transfer_star_count (int | None) – Number of Telegram Stars that must be paid to transfer the gift; omitted if the bot cannot transfer the gift

  • next_transfer_date (int | None) – Point in time (Unix timestamp) when the gift can be transferred. If it is in the past, then the gift can be transferred now.

can_be_transferred: bool | None = None
date = None
classmethod from_dict(data)
is_saved: bool | None = None
next_transfer_date: int | None = None
owned_gift_id: str | None = None
sender_user: User | None = None
transfer_star_count: int | None = None
type: str = 'unique'
gift: UniqueGift
send_date: int
class peyk.platforms.telegram.OwnedGifts(total_count: int, gifts: List[OwnedGiftRegular | OwnedGiftUnique], next_offset: str | None = None)[source]

Bases: object

Contains the list of gifts received and owned by a user or a chat.

Variables:
classmethod from_dict(data: dict | None) OwnedGifts | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

next_offset: str | None = None
total_count: int
gifts: List[OwnedGiftRegular | OwnedGiftUnique]
class peyk.platforms.telegram.PaidMediaInfo(star_count: int, paid_media: List[PaidMediaLivePhoto | PaidMediaPhoto | PaidMediaPreview | PaidMediaVideo])[source]

Bases: object

Describes the paid media added to a message.

Variables:
classmethod from_dict(data: dict | None) PaidMediaInfo | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

star_count: int
paid_media: List[PaidMediaLivePhoto | PaidMediaPhoto | PaidMediaPreview | PaidMediaVideo]
class peyk.platforms.telegram.PaidMediaLivePhoto(type: str = 'live_photo', live_photo: LivePhoto | None = None)[source]

Bases: object

The paid media is a live photo.

Variables:
classmethod from_dict(data: dict | None) PaidMediaLivePhoto | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

live_photo: LivePhoto | None = None
type: str = 'live_photo'
class peyk.platforms.telegram.PaidMediaPhoto(photo: List[PhotoSize], type: str = 'photo')[source]

Bases: object

The paid media is a photo.

Variables:
classmethod from_dict(data: dict | None) PaidMediaPhoto | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

type: str = 'photo'
photo: List[PhotoSize]
class peyk.platforms.telegram.PaidMediaPreview(type: str = 'preview', width: int | None = None, height: int | None = None, duration: int | None = None)[source]

Bases: object

The paid media isn’t available before the payment.

Variables:
  • type (str) – Type of the paid media, always ‘preview’

  • width (int | None) – Media width as defined by the sender

  • height (int | None) – Media height as defined by the sender

  • duration (int | None) – Duration of the media in seconds as defined by the sender

duration: int | None = None
classmethod from_dict(data: dict | None) PaidMediaPreview | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

height: int | None = None
type: str = 'preview'
width: int | None = None
class peyk.platforms.telegram.PaidMediaPurchased(user: User | None = None, paid_media_payload: str = '')[source]

Bases: object

This object contains information about a paid media purchase.

Variables:
  • from – User who purchased the media

  • paid_media_payload (str) – Bot-specified paid media payload

classmethod from_dict(data: dict | None) PaidMediaPurchased | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

paid_media_payload: str = ''
user: User | None = None
class peyk.platforms.telegram.PaidMediaType(*values)[source]

Bases: StrEnum

Telegram paid-media discriminator values.

PHOTO = 'photo'
VIDEO = 'video'
PREVIEW = 'preview'
LIVE_PHOTO = 'live_photo'
class peyk.platforms.telegram.PaidMediaVideo(video: Video, type: str = 'video')[source]

Bases: object

The paid media is a video.

Variables:
classmethod from_dict(data: dict | None) PaidMediaVideo | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

type: str = 'video'
video: Video
class peyk.platforms.telegram.PaidMessagePriceChanged(paid_message_star_count: int | None = None)[source]

Bases: object

Describes a service message about a change in the price of paid messages within a chat.

Variables:

paid_message_star_count (int | None) – The new number of Telegram Stars that must be paid by non-administrator users of the supergroup chat for each sent message

classmethod from_dict(data: dict | None) PaidMessagePriceChanged | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

paid_message_star_count: int | None = None
class peyk.platforms.telegram.ParseMode(*values)[source]

Bases: StrEnum

Telegram Bot API parse-mode values.

MARKDOWN = 'Markdown'
MARKDOWN_V2 = 'MarkdownV2'
HTML = 'HTML'
class peyk.platforms.telegram.PassportData(data: List[EncryptedPassportElement], credentials: EncryptedCredentials)[source]

Bases: object

Describes Telegram Passport data shared with the bot by the user.

Variables:
classmethod from_dict(data: dict | None) PassportData | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

data: List[EncryptedPassportElement]
credentials: EncryptedCredentials
class peyk.platforms.telegram.PassportElementErrorDataField(type: str, field_name: str, data_hash: str, message: str, source: str = 'data')

Bases: object

PassportElementErrorDataField Telegram Bot API type.

classmethod from_dict(data)

Executes the from_dict operation.

Parameters:

data – Value of the declared parameter type.

Returns:

The operation result (Any).

classmethod list_from(data)

Executes the list_from operation.

Parameters:

data – Value of the declared parameter type.

Returns:

The operation result (Any).

source: str = 'data'
to_dict()

Executes the to_dict operation.

Returns:

The operation result (Any).

type: str
field_name: str
data_hash: str
message: str
class peyk.platforms.telegram.PassportElementErrorFile(type: str, file_hash: str, message: str, source: str = 'file')

Bases: object

PassportElementErrorFile Telegram Bot API type.

classmethod from_dict(data)

Executes the from_dict operation.

Parameters:

data – Value of the declared parameter type.

Returns:

The operation result (Any).

classmethod list_from(data)

Executes the list_from operation.

Parameters:

data – Value of the declared parameter type.

Returns:

The operation result (Any).

source: str = 'file'
to_dict()

Executes the to_dict operation.

Returns:

The operation result (Any).

type: str
file_hash: str
message: str
class peyk.platforms.telegram.PassportElementErrorFiles(type: str, file_hashes: List[str], message: str, source: str = 'files')

Bases: object

PassportElementErrorFiles Telegram Bot API type.

classmethod from_dict(data)

Executes the from_dict operation.

Parameters:

data – Value of the declared parameter type.

Returns:

The operation result (Any).

classmethod list_from(data)

Executes the list_from operation.

Parameters:

data – Value of the declared parameter type.

Returns:

The operation result (Any).

source: str = 'files'
to_dict()

Executes the to_dict operation.

Returns:

The operation result (Any).

type: str
file_hashes: List[str]
message: str
class peyk.platforms.telegram.PassportElementErrorFrontSide(type: str, file_hash: str, message: str, source: str = 'front_side')

Bases: object

PassportElementErrorFrontSide Telegram Bot API type.

classmethod from_dict(data)

Executes the from_dict operation.

Parameters:

data – Value of the declared parameter type.

Returns:

The operation result (Any).

classmethod list_from(data)

Executes the list_from operation.

Parameters:

data – Value of the declared parameter type.

Returns:

The operation result (Any).

source: str = 'front_side'
to_dict()

Executes the to_dict operation.

Returns:

The operation result (Any).

type: str
file_hash: str
message: str
class peyk.platforms.telegram.PassportElementErrorReverseSide(type: str, file_hash: str, message: str, source: str = 'reverse_side')

Bases: object

PassportElementErrorReverseSide Telegram Bot API type.

classmethod from_dict(data)

Executes the from_dict operation.

Parameters:

data – Value of the declared parameter type.

Returns:

The operation result (Any).

classmethod list_from(data)

Executes the list_from operation.

Parameters:

data – Value of the declared parameter type.

Returns:

The operation result (Any).

source: str = 'reverse_side'
to_dict()

Executes the to_dict operation.

Returns:

The operation result (Any).

type: str
file_hash: str
message: str
class peyk.platforms.telegram.PassportElementErrorSelfie(type: str, file_hash: str, message: str, source: str = 'selfie')

Bases: object

PassportElementErrorSelfie Telegram Bot API type.

classmethod from_dict(data)

Executes the from_dict operation.

Parameters:

data – Value of the declared parameter type.

Returns:

The operation result (Any).

classmethod list_from(data)

Executes the list_from operation.

Parameters:

data – Value of the declared parameter type.

Returns:

The operation result (Any).

source: str = 'selfie'
to_dict()

Executes the to_dict operation.

Returns:

The operation result (Any).

type: str
file_hash: str
message: str
class peyk.platforms.telegram.PassportElementErrorSource(*values)[source]

Bases: StrEnum

Telegram Passport element-error source values.

DATA = 'data'
FRONT_SIDE = 'front_side'
REVERSE_SIDE = 'reverse_side'
SELFIE = 'selfie'
FILE = 'file'
FILES = 'files'
TRANSLATION_FILE = 'translation_file'
TRANSLATION_FILES = 'translation_files'
UNSPECIFIED = 'unspecified'
class peyk.platforms.telegram.PassportElementErrorTranslationFile(type: str, file_hash: str, message: str, source: str = 'translation_file')

Bases: object

PassportElementErrorTranslationFile Telegram Bot API type.

classmethod from_dict(data)

Executes the from_dict operation.

Parameters:

data – Value of the declared parameter type.

Returns:

The operation result (Any).

classmethod list_from(data)

Executes the list_from operation.

Parameters:

data – Value of the declared parameter type.

Returns:

The operation result (Any).

source: str = 'translation_file'
to_dict()

Executes the to_dict operation.

Returns:

The operation result (Any).

type: str
file_hash: str
message: str
class peyk.platforms.telegram.PassportElementErrorTranslationFiles(type: str, file_hashes: List[str], message: str, source: str = 'translation_files')

Bases: object

PassportElementErrorTranslationFiles Telegram Bot API type.

classmethod from_dict(data)

Executes the from_dict operation.

Parameters:

data – Value of the declared parameter type.

Returns:

The operation result (Any).

classmethod list_from(data)

Executes the list_from operation.

Parameters:

data – Value of the declared parameter type.

Returns:

The operation result (Any).

source: str = 'translation_files'
to_dict()

Executes the to_dict operation.

Returns:

The operation result (Any).

type: str
file_hashes: List[str]
message: str
class peyk.platforms.telegram.PassportElementErrorUnspecified(type: str, element_hash: str, message: str, source: str = 'unspecified')

Bases: object

PassportElementErrorUnspecified Telegram Bot API type.

classmethod from_dict(data)

Executes the from_dict operation.

Parameters:

data – Value of the declared parameter type.

Returns:

The operation result (Any).

classmethod list_from(data)

Executes the list_from operation.

Parameters:

data – Value of the declared parameter type.

Returns:

The operation result (Any).

source: str = 'unspecified'
to_dict()

Executes the to_dict operation.

Returns:

The operation result (Any).

type: str
element_hash: str
message: str
class peyk.platforms.telegram.PassportFile(file_id: str, file_unique_id: str, file_size: int, file_date: int)[source]

Bases: object

This object represents a file uploaded to Telegram Passport. Currently all Telegram Passport files are in JPEG format when decrypted and don’t exceed 10MB.

Variables:
  • file_id (str) – Identifier for this file, which can be used to download or reuse the file

  • file_unique_id (str) – Unique identifier for this file, which is supposed to be the same over time and for different bots. Can’t be used to download or reuse the file.

  • file_size (int) – File size in bytes

  • file_date (int) – Unix time when the file was uploaded

classmethod from_dict(data: dict | None) PassportFile | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

file_id: str
file_unique_id: str
file_size: int
file_date: int
class peyk.platforms.telegram.PhotoSize(file_id: str, file_unique_id: str, width: int, height: int, file_size: int | None = None)[source]

Bases: object

This object represents one size of a photo or a file / sticker thumbnail.

Variables:
  • file_id (str) – Identifier for this file, which can be used to download or reuse the file

  • file_unique_id (str) – Unique identifier for this file, which is supposed to be the same over time and for different bots. Can’t be used to download or reuse the file.

  • width (int) – Photo width

  • height (int) – Photo height

  • file_size (int | None) – File size in bytes

file_size: int | None = None
classmethod from_dict(data: dict | None) PhotoSize | None[source]

Parse a Telegram API mapping into this type.

Parameters:

data – Raw Telegram API mapping, or None.

Returns:

Parsed type instance, or None when data is None.

classmethod list_from(data: List[dict] | None) List[PhotoSize] | None[source]

Parse a Telegram API result list into this type.

Parameters:

data – Raw result list, or None.

Returns:

Parsed type instances.

file_id: str
file_unique_id: str
width: int
height: int
class peyk.platforms.telegram.Poll(id: str, question: str, options: List[PollOption], total_voter_count: int = 0, is_closed: bool = False, is_anonymous: bool = True, type: str = 'regular', allows_multiple_answers: bool = False, allows_revoting: bool = False, members_only: bool | None = None, country_codes: List[str] | None = None, question_entities: List[MessageEntity] | None = None, correct_option_ids: List[int] | None = None, explanation: str | None = None, explanation_entities: List[MessageEntity] | None = None, explanation_media: PollMedia | None = None, open_period: int | None = None, close_date: int | None = None, description: str | None = None, description_entities: List[MessageEntity] | None = None, media: PollMedia | None = None)[source]

Bases: object

This object contains information about a poll.

Variables:
  • id (str) – Unique poll identifier

  • question (str) – Poll question, 1-300 characters

  • options (List[peyk.platforms.telegram.types.poll_option.PollOption]) – List of poll options

  • total_voter_count (int) – Total number of users that voted in the poll

  • is_closed (bool) – True, if the poll is closed

  • is_anonymous (bool) – True, if the poll is anonymous

  • type (str) – Poll type, currently can be ‘regular’ or ‘quiz’

  • allows_multiple_answers (bool) – True, if the poll allows multiple answers

  • allows_revoting (bool) – True, if the poll allows to change the chosen answer options

  • members_only (bool | None) – True if voting is limited to users who have been members of the chat where the poll was originally sent for more than 24 hours

  • question_entities (List[peyk.platforms.telegram.types.message_entity.MessageEntity] | None) – Special entities that appear in the question. Currently, only custom emoji entities are allowed in poll questions

  • country_codes (List[str] | None) – A list of two-letter ISO 3166-1 alpha-2 country codes indicating the countries from which users can vote in the poll. The country code ‘FT’ is used for users with anonymous numbers. If omitted, then users from any country can participate in the poll.

  • correct_option_ids (List[int] | None) – Array of 0-based identifiers of the correct answer options. Available only for polls in quiz mode which are closed or were sent (not forwarded) by the bot or to the private chat with the bot.

  • explanation (str | None) – Text that is shown when a user chooses an incorrect answer or taps on the lamp icon in a quiz-style poll, 0-200 characters

  • explanation_entities (List[peyk.platforms.telegram.types.message_entity.MessageEntity] | None) – Special entities like usernames, URLs, bot commands, etc. that appear in the explanation

  • explanation_media (peyk.platforms.telegram.types.poll_media.PollMedia | None) – Media added to the quiz explanation

  • open_period (int | None) – Amount of time in seconds the poll will be active after creation

  • close_date (int | None) – Point in time (Unix timestamp) when the poll will be automatically closed

  • description (str | None) – Description of the poll; for polls inside the Message object only

  • description_entities (List[peyk.platforms.telegram.types.message_entity.MessageEntity] | None) – Special entities like usernames, URLs, bot commands, etc. that appear in the description

  • media (peyk.platforms.telegram.types.poll_media.PollMedia | None) – Media added to the poll description; for polls inside the Message object only

  • correct_option_id – 0-based identifier of the correct answer option. Available only for polls in the quiz mode, which are closed, or was sent (not forwarded) by the bot or to the private chat with the bot.

allows_multiple_answers: bool = False
allows_revoting: bool = False
close_date: int | None = None
correct_option_ids: List[int] | None = None
country_codes: List[str] | None = None
description: str | None = None
description_entities: List[MessageEntity] | None = None
explanation: str | None = None
explanation_entities: List[MessageEntity] | None = None
explanation_media: PollMedia | None = None
classmethod from_dict(data: dict | None) Poll | None[source]

Parse a Telegram API mapping into this type.

Parameters:

data – Raw Telegram API mapping, or None.

Returns:

Parsed type instance, or None when data is None.

is_anonymous: bool = True
is_closed: bool = False
media: PollMedia | None = None
members_only: bool | None = None
open_period: int | None = None
question_entities: List[MessageEntity] | None = None
total_voter_count: int = 0
type: str = 'regular'
id: str
question: str
options: List[PollOption]
class peyk.platforms.telegram.PollAnswer(poll_id: str, voter_chat: Chat | None = None, user: User | None = None, option_ids: List[int] | None = None, option_persistent_ids: List[str] | None = None)[source]

Bases: object

This object represents an answer of a user in a non-anonymous poll.

Variables:
  • poll_id (str) – Unique poll identifier

  • option_ids (List[int] | None) – 0-based identifiers of chosen answer options. May be empty if the vote was retracted.

  • option_persistent_ids (List[str] | None) – Persistent identifiers of the chosen answer options. May be empty if the vote was retracted.

  • voter_chat (peyk.platforms.telegram.types.chat.Chat | None) – The chat that changed the answer to the poll, if the voter is anonymous

  • user (peyk.platforms.telegram.types.user.User | None) – The user that changed the answer to the poll, if the voter isn’t anonymous

classmethod from_dict(data: dict | None) PollAnswer | None[source]

Parse a Telegram API mapping into this type.

Parameters:

data – Raw Telegram API mapping, or None.

Returns:

Parsed type instance, or None when data is None.

option_ids: List[int] | None = None
option_persistent_ids: List[str] | None = None
user: User | None = None
voter_chat: Chat | None = None
poll_id: str
class peyk.platforms.telegram.PollMedia(animation: Animation | None = None, audio: Audio | None = None, document: Document | None = None, link: Link | None = None, live_photo: LivePhoto | None = None, location: Location | None = None, photo: List[PhotoSize] | None = None, sticker: object | None = None, venue: Venue | None = None, video: Video | None = None)[source]

Bases: object

At most one of the optional fields can be present in any given object.

Variables:
animation: Animation | None = None
audio: Audio | None = None
document: Document | None = None
classmethod from_dict(data: dict | None) PollMedia | None[source]

Parse a Telegram API mapping into this type.

Parameters:

data – Raw Telegram API mapping, or None.

Returns:

Parsed type instance, or None when data is None.

live_photo: LivePhoto | None = None
location: Location | None = None
photo: List[PhotoSize] | None = None
sticker: object | None = None
venue: Venue | None = None
video: Video | None = None
class peyk.platforms.telegram.PollOption(persistent_id: str | None = None, text: str = '', text_entities: List[MessageEntity] | None = None, media: PollMedia | None = None, voter_count: int = 0, added_by_user: User | None = None, added_by_chat: Chat | None = None, addition_date: int | None = None)[source]

Bases: object

This object contains information about one answer option in a poll.

Variables:
  • persistent_id (str | None) – Unique identifier of the option, persistent on option addition and deletion

  • text (str) – Option text, 1-100 characters

  • voter_count (int) – Number of users who voted for this option; may be 0 if unknown

  • text_entities (List[peyk.platforms.telegram.types.message_entity.MessageEntity] | None) – Special entities that appear in the option text. Currently, only custom emoji entities are allowed in poll option texts

  • media (peyk.platforms.telegram.types.poll_media.PollMedia | None) – Media added to the poll option

  • added_by_user (peyk.platforms.telegram.types.user.User | None) – User who added the option; omitted if the option wasn’t added by a user after poll creation

  • added_by_chat (peyk.platforms.telegram.types.chat.Chat | None) – Chat that added the option; omitted if the option wasn’t added by a chat after poll creation

  • addition_date (int | None) – Point in time (Unix timestamp) when the option was added; omitted if the option existed in the original poll

added_by_chat: Chat | None = None
added_by_user: User | None = None
addition_date: int | None = None
classmethod from_dict(data: dict | None) PollOption | None[source]

Parse a Telegram API mapping into this type.

Parameters:

data – Raw Telegram API mapping, or None.

Returns:

Parsed type instance, or None when data is None.

media: PollMedia | None = None
persistent_id: str | None = None
text: str = ''
text_entities: List[MessageEntity] | None = None
voter_count: int = 0
class peyk.platforms.telegram.PollOptionAdded(option: PollOption | None = None, voter_count: int = 0)[source]

Bases: object

Describes a service message about an option added to a poll.

Variables:
  • option_persistent_id – Unique identifier of the added option

  • option_text – Option text

  • poll_message – Message containing the poll to which the option was added, if known. Note that the Message object in this field will not contain the reply_to_message field even if it itself is a reply.

  • option_text_entities – Special entities that appear in the option_text

classmethod from_dict(data: dict | None) PollOptionAdded | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

option: PollOption | None = None
voter_count: int = 0
class peyk.platforms.telegram.PollOptionDeleted(option: PollOption | None = None)[source]

Bases: object

Describes a service message about an option deleted from a poll.

Variables:
  • option_persistent_id – Unique identifier of the deleted option

  • option_text – Option text

  • poll_message – Message containing the poll from which the option was deleted, if known. Note that the Message object in this field will not contain the reply_to_message field even if it itself is a reply.

  • option_text_entities – Special entities that appear in the option_text

classmethod from_dict(data: dict | None) PollOptionDeleted | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

option: PollOption | None = None
class peyk.platforms.telegram.PollType(*values)[source]

Bases: StrEnum

Telegram poll type values.

REGULAR = 'regular'
QUIZ = 'quiz'
class peyk.platforms.telegram.PreCheckoutQuery(id: str, from_: User, currency: str, total_amount: int, invoice_payload: str, shipping_option_id: str | None = None, order_info: OrderInfo | None = None)[source]

Bases: object

This object contains information about an incoming pre-checkout query.

Variables:
  • id (str) – Unique query identifier

  • from – User who sent the query

  • currency (str) – Three-letter ISO 4217 currency code, or ‘XTR’ for payments in Telegram Stars

  • total_amount (int) – Total price in the smallest units of the currency (integer, not float/double). For example, for a price of US$ 1.45 pass amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies).

  • invoice_payload (str) – Bot-specified invoice payload

  • shipping_option_id (str | None) – Identifier of the shipping option chosen by the user

  • order_info (peyk.platforms.telegram.types.order_info.OrderInfo | None) – Order information provided by the user

classmethod from_dict(data: dict | None) PreCheckoutQuery | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

order_info: OrderInfo | None = None
shipping_option_id: str | None = None
id: str
from_: User
currency: str
total_amount: int
invoice_payload: str
class peyk.platforms.telegram.PreparedInlineMessage(id: str = '', expiration_date: int = 0)[source]

Bases: object

Describes an inline message to be sent by a user of a Mini App.

Variables:
  • id (str) – Unique identifier of the prepared message

  • expiration_date (int) – Expiration date of the prepared message, in Unix time. Expired prepared messages can no longer be used.

expiration_date: int = 0
classmethod from_dict(data: dict | None) PreparedInlineMessage | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

id: str = ''
class peyk.platforms.telegram.PreparedKeyboardButton(text: str = '')[source]

Bases: object

Describes a keyboard button to be used by a user of a Mini App.

Variables:

id – Unique identifier of the keyboard button

classmethod from_dict(data: dict | None) PreparedKeyboardButton | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

text: str = ''
class peyk.platforms.telegram.ProximityAlertTriggered(traveler: User | None = None, watcher: User | None = None, distance: int = 0)[source]

Bases: object

This object represents the content of a service message, sent whenever a user in the chat triggers a proximity alert set by another user.

Variables:
distance: int = 0
classmethod from_dict(data: dict | None) ProximityAlertTriggered | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

traveler: User | None = None
watcher: User | None = None
class peyk.platforms.telegram.ReactionCount(type: ReactionTypeEmoji | ReactionTypeCustomEmoji | ReactionTypePaid, total_count: int = 0)[source]

Bases: object

Represents a reaction added to a message along with the number of times it was added.

Variables:
classmethod from_dict(data: dict | None) ReactionCount | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

total_count: int = 0
type: ReactionTypeEmoji | ReactionTypeCustomEmoji | ReactionTypePaid
class peyk.platforms.telegram.ReactionType(*values)[source]

Bases: StrEnum

Telegram reaction type discriminator values.

EMOJI = 'emoji'
CUSTOM_EMOJI = 'custom_emoji'
PAID = 'paid'
class peyk.platforms.telegram.ReactionTypeCustomEmoji(type: str = 'custom_emoji', custom_emoji_id: str = '')[source]

Bases: object

The reaction is based on a custom emoji.

Variables:
  • type (str) – Type of the reaction, always ‘custom_emoji’

  • custom_emoji_id (str) – Custom emoji identifier

custom_emoji_id: str = ''
classmethod from_dict(data: dict | None) ReactionTypeCustomEmoji | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

type: str = 'custom_emoji'
class peyk.platforms.telegram.ReactionTypeEmoji(type: str = 'emoji', emoji: str = '')[source]

Bases: object

The reaction is based on an emoji.

Variables:
  • type (str) – Type of the reaction, always ‘emoji’

  • emoji (str) – Reaction emoji. Currently, it can be one of “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”, “”.

emoji: str = ''
classmethod from_dict(data: dict | None) ReactionTypeEmoji | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

type: str = 'emoji'
class peyk.platforms.telegram.ReactionTypePaid(type: str = 'paid')[source]

Bases: object

The reaction is paid.

Variables:

type (str) – Type of the reaction, always ‘paid’

classmethod from_dict(data: dict | None) ReactionTypePaid | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

type: str = 'paid'
class peyk.platforms.telegram.RefundedPayment(currency: str, total_amount: int, invoice_payload: str, telegram_payment_charge_id: str, provider_payment_charge_id: str | None = None)[source]

Bases: object

This object contains basic information about a refunded payment.

Variables:
  • currency (str) – Three-letter ISO 4217 currency code, or ‘XTR’ for payments in Telegram Stars. Currently, always ‘XTR’.

  • total_amount (int) – Total refunded price in the smallest units of the currency (integer, not float/double). For example, for a price of US$ 1.45, total_amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies).

  • invoice_payload (str) – Bot-specified invoice payload

  • telegram_payment_charge_id (str) – Telegram payment identifier

  • provider_payment_charge_id (str | None) – Provider payment identifier

classmethod from_dict(data: dict | None) RefundedPayment | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

provider_payment_charge_id: str | None = None
currency: str
total_amount: int
invoice_payload: str
telegram_payment_charge_id: str
class peyk.platforms.telegram.ReplyKeyboardMarkup(keyboard: ~typing.List[~typing.List[~peyk.platforms.telegram.types.keyboard_button.KeyboardButton | ~typing.Mapping[str, object] | str]] = <factory>, is_persistent: bool | None = None, resize_keyboard: bool | None = None, one_time_keyboard: bool | None = None, input_field_placeholder: str | None = None, selective: bool | None = None)[source]

Bases: object

This object represents a custom keyboard with reply options (see Introduction to bots for details and examples). Not supported in channels and for messages sent on behalf of a business account.

Variables:
  • keyboard (List[List[peyk.platforms.telegram.types.keyboard_button.KeyboardButton | Mapping[str, object] | str]]) – Array of button rows, each represented by an Array of KeyboardButton objects

  • is_persistent (bool | None) – Requests clients to always show the keyboard when the regular keyboard is hidden. Defaults to False, in which case the custom keyboard can be hidden and opened with a keyboard icon.

  • resize_keyboard (bool | None) – Requests clients to resize the keyboard vertically for optimal fit (e.g., make the keyboard smaller if there are just two rows of buttons). Defaults to False, in which case the custom keyboard is always of the same height as the app’s standard keyboard.

  • one_time_keyboard (bool | None) – Requests clients to hide the keyboard as soon as it’s been used. The keyboard will still be available, but clients will automatically display the usual letter-keyboard in the chat - the user can press a special button in the input field to see the custom keyboard again. Defaults to False.

  • input_field_placeholder (str | None) – The placeholder to be shown in the input field when the keyboard is active; 1-64 characters

  • selective (bool | None) – Use this parameter if you want to show the keyboard to specific users only. Targets: 1) users that are @mentioned in the text of the Message object; 2) if the bot’s message is a reply to a message in the same chat and forum topic, sender of the original message.

Example: A user requests to change the bot’s language, bot replies to the request with a keyboard to select the new language. Other users in the group don’t see the keyboard.

classmethod from_dict(data: dict | None) ReplyKeyboardMarkup | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

input_field_placeholder: str | None = None
is_persistent: bool | None = None
one_time_keyboard: bool | None = None
resize_keyboard: bool | None = None
selective: bool | None = None
to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

keyboard: List[List[KeyboardButton | Mapping[str, object] | str]]
class peyk.platforms.telegram.ReplyKeyboardRemove(remove_keyboard: bool = True, selective: bool | None = None)[source]

Bases: object

Upon receiving a message with this object, Telegram clients will remove the current custom keyboard and display the default letter-keyboard. By default, custom keyboards are displayed until a new keyboard is sent by a bot. An exception is made for one-time keyboards that are hidden immediately after the user presses a button (see ReplyKeyboardMarkup). Not supported in channels and for messages sent on behalf of a business account.

Variables:
  • remove_keyboard (bool) – Requests clients to remove the custom keyboard (user will not be able to summon this keyboard; if you want to hide the keyboard from sight but keep it accessible, use one_time_keyboard in ReplyKeyboardMarkup)

  • selective (bool | None) – Use this parameter if you want to remove the keyboard for specific users only. Targets: 1) users that are @mentioned in the text of the Message object; 2) if the bot’s message is a reply to a message in the same chat and forum topic, sender of the original message.

Example: A user votes in a poll, bot returns confirmation message in reply to the vote and removes the keyboard for that user, while still showing the keyboard with poll options to users who haven’t voted yet.

classmethod from_dict(data: dict | None) ReplyKeyboardRemove | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

remove_keyboard: bool = True
selective: bool | None = None
to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

class peyk.platforms.telegram.ReplyParameters(message_id: int | None = None, chat_id: object | None = None, quote: str | None = None, quote_parse_mode: str | None = None, quote_entities: List[MessageEntity] | None = None, quote_position: int | None = None, checklist_task_id: int | None = None, allow_sending_without_reply: bool | None = None, ephemeral_message_id: int | None = None)[source]

Bases: object

Describes reply parameters for the message that is being sent.

Variables:
  • message_id (int | None) – Identifier of the message that will be replied to in the current chat, or in the chat chat_id if it is specified. Required if ephemeral_message_id isn’t specified.

  • chat_id (object | None) – If the message to be replied to is from a different chat, unique identifier for the chat or username of the bot, supergroup or channel in the format @username. Not supported for messages sent on behalf of a business account, messages from channel direct messages chats and ephemeral messages.

  • allow_sending_without_reply (bool | None) – Pass True if the message should be sent even if the specified message to be replied to is not found. Always False for replies in another chat or forum topic, and sent ephemeral messages. Always True for messages sent on behalf of a business account.

  • quote (str | None) – Quoted part of the message to be replied to; 0-1024 characters after entities parsing. The quote must be an exact substring of the message to be replied to, including bold, italic, underline, strikethrough, spoiler, custom_emoji, and date_time entities. The message will fail to send if the quote isn’t found in the original message. Ignored for ephemeral messages.

  • quote_parse_mode (str | None) – Mode for parsing entities in the quote. See formatting options for more details.

  • quote_entities (List[peyk.platforms.telegram.types.message_entity.MessageEntity] | None) – A JSON-serialized list of special entities that appear in the quote. It can be specified instead of quote_parse_mode.

  • quote_position (int | None) – Position of the quote in the original message in UTF-16 code units

  • checklist_task_id (int | None) – Identifier of the specific checklist task to be replied to

  • poll_option_id – Persistent identifier of the specific poll option to be replied to

  • ephemeral_message_id (int | None) – Identifier of the incoming ephemeral message that will be replied to in the current chat. A reply to an ephemeral message must itself be an ephemeral message. An ephemeral message may only be replied to within 15 seconds of being sent. Required if message_id isn’t specified.

allow_sending_without_reply: bool | None = None
chat_id: object | None = None
checklist_task_id: int | None = None
ephemeral_message_id: int | None = None
classmethod from_dict(data: dict | None) ReplyParameters | None[source]

Parse a Telegram API mapping into this type.

Parameters:

data – Raw Telegram API mapping, or None.

Returns:

Parsed type instance, or None when data is None.

message_id: int | None = None
quote: str | None = None
quote_entities: List[MessageEntity] | None = None
quote_parse_mode: str | None = None
quote_position: int | None = None
to_dict() Dict[str, object][source]

Serialize this type to the Telegram API request shape.

Returns:

A JSON-compatible mapping representing this value.

class peyk.platforms.telegram.ResponseParameters(migrate_to_chat_id: int | None = None, retry_after: int | None = None)[source]

Bases: object

Describes why a request was unsuccessful.

Variables:
  • migrate_to_chat_id (int | None) – The group has been migrated to a supergroup with the specified identifier. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this identifier.

  • retry_after (int | None) – In case of exceeding flood control, the number of seconds left to wait before the request can be repeated

classmethod from_dict(data: dict | None) ResponseParameters | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

migrate_to_chat_id: int | None = None
retry_after: int | None = None
class peyk.platforms.telegram.RevenueWithdrawalStateFailed(type: str = 'failed')[source]

Bases: object

The withdrawal failed and the transaction was refunded.

Variables:

type (str) – Type of the state, always ‘failed’

classmethod from_dict(data: dict | None) RevenueWithdrawalStateFailed | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

type: str = 'failed'
class peyk.platforms.telegram.RevenueWithdrawalStatePending(type: str = 'pending')[source]

Bases: object

The withdrawal is in progress.

Variables:

type (str) – Type of the state, always ‘pending’

classmethod from_dict(data: dict | None) RevenueWithdrawalStatePending | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

type: str = 'pending'
class peyk.platforms.telegram.RevenueWithdrawalStateSucceeded(type: str = 'succeeded', date: int = 0, url: str = '')[source]

Bases: object

The withdrawal succeeded.

Variables:
  • type (str) – Type of the state, always ‘succeeded’

  • date (int) – Date the withdrawal was completed in Unix time

  • url (str) – An HTTPS URL that can be used to see transaction details

date: int = 0
classmethod from_dict(data: dict | None) RevenueWithdrawalStateSucceeded | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

type: str = 'succeeded'
url: str = ''
class peyk.platforms.telegram.RevenueWithdrawalStateType(*values)[source]

Bases: StrEnum

Telegram revenue-withdrawal-state discriminator values.

PENDING = 'pending'
SUCCEEDED = 'succeeded'
FAILED = 'failed'
class peyk.platforms.telegram.RichBlockAnchor(name: str = '', text: str = '')[source]

Bases: object

A block with an anchor, corresponding to the HTML tag with the attribute name.

Variables:
  • type – Type of the block, always ‘anchor’

  • name (str) – The name of the anchor

classmethod from_dict(data)[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

name: str = ''
text: str = ''
class peyk.platforms.telegram.RichBlockAnimation(animation: Animation | None = None)[source]

Bases: object

A block with an animation, corresponding to the HTML tag .

Variables:
  • type – Type of the block, always ‘animation’

  • animation (peyk.platforms.telegram.types.animation.Animation | None) – The animation

  • has_spoiler – True, if the media preview is covered by a spoiler animation

  • caption – Caption of the block

animation: Animation | None = None
classmethod from_dict(data)[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

class peyk.platforms.telegram.RichBlockAudio(audio: Audio | None = None)[source]

Bases: object

A block with a music file, corresponding to the HTML tag .

Variables:
audio: Audio | None = None
classmethod from_dict(data)[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

class peyk.platforms.telegram.RichBlockBlockQuotation(text: str = '')[source]

Bases: object

A block quotation, corresponding to the HTML tag .

Variables:
  • type – Type of the block, always ‘blockquote’

  • blocks – Content of the block

  • credit – Credit of the block

classmethod from_dict(data)[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

text: str = ''
class peyk.platforms.telegram.RichBlockButtons(buttons: List[object] | None = None)[source]

Bases: object

RichBlockButtons Telegram Bot API type.

buttons: List[object] | None = None
classmethod from_dict(data)[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

class peyk.platforms.telegram.RichBlockCaption(text: str = '')[source]

Bases: object

Caption of a rich formatted block.

Variables:
  • text (str) – Block caption

  • credit – Block credit which corresponds to the HTML tag

classmethod from_dict(data)[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

text: str = ''
class peyk.platforms.telegram.RichBlockCollage(items: List[object] | None = None)[source]

Bases: object

A collage, corresponding to the custom HTML tag .

Variables:
  • type – Type of the block, always ‘collage’

  • blocks – Elements of the collage

  • caption – Caption of the block

classmethod from_dict(data)[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

items: List[object] | None = None
class peyk.platforms.telegram.RichBlockDetails(title: str = '', text: str = '')[source]

Bases: object

An expandable block for details disclosure, corresponding to the HTML tag .

Variables:
  • type – Type of the block, always ‘details’

  • summary – Always shown summary of the block

  • blocks – Content of the block

  • is_open – True, if the content of the block is visible by default

classmethod from_dict(data)[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

text: str = ''
title: str = ''
class peyk.platforms.telegram.RichBlockDivider[source]

Bases: object

A divider, corresponding to the HTML tag .

Variables:

type – Type of the block, always ‘divider’

classmethod from_dict(data)[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

class peyk.platforms.telegram.RichBlockDocument(document: Document | None = None)[source]

Bases: object

RichBlockDocument Telegram Bot API type.

document: Document | None = None
classmethod from_dict(data)[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

class peyk.platforms.telegram.RichBlockExpandableBlockQuotation(text: str = '')[source]

Bases: object

RichBlockExpandableBlockQuotation Telegram Bot API type.

classmethod from_dict(data)[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

text: str = ''
class peyk.platforms.telegram.RichBlockFooter(text: str = '')[source]

Bases: object

A footer, corresponding to the HTML tag .

Variables:
  • type – Type of the block, always ‘footer’

  • text (str) – Text of the block

classmethod from_dict(data)[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

text: str = ''
class peyk.platforms.telegram.RichBlockList(items: List[object] | None = None)[source]

Bases: object

A list of blocks, corresponding to the HTML tag or with multiple nested tags .

Variables:
  • type – Type of the block, always ‘list’

  • items (List[object] | None) – Items of the list

classmethod from_dict(data)[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

items: List[object] | None = None
class peyk.platforms.telegram.RichBlockListItem(text: str = '')[source]

Bases: object

An item of a list.

Variables:
  • label – Label of the item

  • blocks – The content of the item

  • has_checkbox – True, if the item has a checkbox

  • is_checked – True, if the item has a checked checkbox

  • value – For ordered lists, the numeric value of the item label

  • type – For ordered lists, the type of the item label; must be one of ‘a’ for lowercase letters, ‘A’ for uppercase letters, ‘i’ for lowercase Roman numerals, ‘I’ for uppercase Roman numerals, or ‘1’ for decimal numbers

classmethod from_dict(data)[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

text: str = ''
class peyk.platforms.telegram.RichBlockMap(latitude: float = 0.0, longitude: float = 0.0)[source]

Bases: object

A block with a map, corresponding to the custom HTML tag .

Variables:
  • type – Type of the block, always ‘map’

  • location – Location of the center of the map

  • zoom – Map zoom level; 13-20

  • width – Expected width of the map

  • height – Expected height of the map

  • caption – Caption of the block

classmethod from_dict(data)[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

latitude: float = 0.0
longitude: float = 0.0
class peyk.platforms.telegram.RichBlockMathematicalExpression(expression: str = '')[source]

Bases: object

A block with a mathematical expression in LaTeX format, corresponding to the custom HTML tag .

Variables:
  • type – Type of the block, always ‘mathematical_expression’

  • expression (str) – The mathematical expression in LaTeX format

expression: str = ''
classmethod from_dict(data)[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

class peyk.platforms.telegram.RichBlockParagraph(text: str = '')[source]

Bases: object

A text paragraph, corresponding to the HTML tag .

Variables:
  • type – Type of the block, always ‘paragraph’

  • text (str) – Text of the block

classmethod from_dict(data)[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

text: str = ''
class peyk.platforms.telegram.RichBlockPhoto(photo: List[PhotoSize] | None = None)[source]

Bases: object

A block with a photo, corresponding to the HTML tag .

Variables:
  • type – Type of the block, always ‘photo’

  • photo (List[peyk.platforms.telegram.types.photo_size.PhotoSize] | None) – Available sizes of the photo

  • has_spoiler – True, if the media preview is covered by a spoiler animation

  • caption – Caption of the block

classmethod from_dict(data)[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

photo: List[PhotoSize] | None = None
class peyk.platforms.telegram.RichBlockPreformatted(text: str = '', language: str = '')[source]

Bases: object

A preformatted text block, corresponding to the nested HTML tags and .

Variables:
  • type – Type of the block, always ‘pre’

  • text (str) – Text of the block

  • language (str) – The programming language of the text

classmethod from_dict(data)[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

language: str = ''
text: str = ''
class peyk.platforms.telegram.RichBlockPullQuotation(text: str = '')[source]

Bases: object

A quotation with centered text, loosely corresponding to the HTML tag .

Variables:
  • type – Type of the block, always ‘pullquote’

  • text (str) – Text of the block

  • credit – Credit of the block

classmethod from_dict(data)[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

text: str = ''
class peyk.platforms.telegram.RichBlockSectionHeading(text: str = '')[source]

Bases: object

A section heading, corresponding to the HTML tags , , , , , or .

Variables:
  • type – Type of the block, always ‘heading’

  • text (str) – Text of the block

  • size – Relative size of the text font; 1-6, 1 is the largest, 6 is the smallest

classmethod from_dict(data)[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

text: str = ''
class peyk.platforms.telegram.RichBlockSlideshow(items: List[object] | None = None)[source]

Bases: object

A slideshow, corresponding to the custom HTML tag .

Variables:
  • type – Type of the block, always ‘slideshow’

  • blocks – Elements of the slideshow

  • caption – Caption of the block

classmethod from_dict(data)[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

items: List[object] | None = None
class peyk.platforms.telegram.RichBlockTable(cells: List[object] | None = None, is_compact: bool | None = None)[source]

Bases: object

A table, corresponding to the HTML tag .

Variables:
  • type – Type of the block, always ‘table’

  • cells (List[object] | None) – Cells of the table

  • is_bordered – True, if the table has borders

  • is_striped – True, if the table is striped

  • caption – Caption of the table

cells: List[object] | None = None
classmethod from_dict(data)[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

is_compact: bool | None = None
class peyk.platforms.telegram.RichBlockTableCell(text: str = '')[source]

Bases: object

Cell in a table.

Variables:
  • align – Horizontal cell content alignment. Currently, must be one of ‘left’, ‘center’, or ‘right’.

  • valign – Vertical cell content alignment. Currently, must be one of ‘top’, ‘middle’, or ‘bottom’.

  • text (str) – Text in the cell. If omitted, then the cell is invisible.

  • is_header – True, if the cell is a header cell

  • colspan – The number of columns the cell spans if it is bigger than 1

  • rowspan – The number of rows the cell spans if it is bigger than 1

classmethod from_dict(data)[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

text: str = ''
class peyk.platforms.telegram.RichBlockThinking(text: str = '')[source]

Bases: object

A block with a ‘Thinking…’ placeholder, corresponding to the custom HTML tag . The block may be used only in sendRichMessageDraft, therefore it can’t be received in messages. See https://t.me/addemoji/AIActions for examples of custom emoji that are recommended for usage in the block.

Variables:
  • type – Type of the block, always ‘thinking’

  • text (str) – Text of the block. See https://t.me/addemoji/AIActions for examples of custom emoji that are recommended for usage in the block.

classmethod from_dict(data)[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

text: str = ''
class peyk.platforms.telegram.RichBlockType(*values)[source]

Bases: str, Enum

RichBlockType defines a public API type for peyk.

PARAGRAPH = 'paragraph'
HEADING = 'heading'
PRE = 'pre'
FOOTER = 'footer'
DIVIDER = 'divider'
MATHEMATICAL_EXPRESSION = 'mathematical_expression'
ANCHOR = 'anchor'
LIST = 'list'
BLOCKQUOTE = 'blockquote'
EXPANDABLE_BLOCKQUOTE = 'expandable_blockquote'
PULLQUOTE = 'pullquote'
COLLAGE = 'collage'
SLIDESHOW = 'slideshow'
TABLE = 'table'
DETAILS = 'details'
MAP = 'map'
BUTTONS = 'buttons'
ANIMATION = 'animation'
AUDIO = 'audio'
DOCUMENT = 'document'
PHOTO = 'photo'
VIDEO = 'video'
VOICE_NOTE = 'voice_note'
THINKING = 'thinking'
class peyk.platforms.telegram.RichBlockVideo(video: Video | None = None)[source]

Bases: object

A block with a video, corresponding to the HTML tag .

Variables:
  • type – Type of the block, always ‘video’

  • video (peyk.platforms.telegram.types.video.Video | None) – The video

  • has_spoiler – True, if the media preview is covered by a spoiler animation

  • caption – Caption of the block

classmethod from_dict(data)[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

video: Video | None = None
class peyk.platforms.telegram.RichBlockVoiceNote(voice: Voice | None = None)[source]

Bases: object

A block with a voice note, corresponding to the HTML tag .

Variables:
  • type – Type of the block, always ‘voice_note’

  • voice_note – The voice note

  • caption – Caption of the block

classmethod from_dict(data)[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

voice: Voice | None = None
class peyk.platforms.telegram.RichMessage(text: str = '', blocks: object | None = None, is_rtl: bool | None = None)[source]

Bases: object

Rich formatted message.

Variables:
  • blocks (object | None) – Content of the message

  • is_rtl (bool | None) – True, if the rich message must be shown right-to-left

blocks: object | None = None
classmethod from_dict(data: dict | None) RichMessage | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

is_rtl: bool | None = None
text: str = ''
class peyk.platforms.telegram.RichMessageButton(text: str = '', type: str = 'button')[source]

Bases: object

Rich message button.

classmethod from_dict(data)[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

text: str = ''
type: str = 'button'
class peyk.platforms.telegram.RichTextAnchor(text: str = '', name: str = '', type: str = 'anchor')[source]

Bases: object

An anchor.

Variables:
  • type (str) – Type of the rich text, always ‘anchor’

  • name (str) – The name of the anchor

classmethod from_dict(data)[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

name: str = ''
text: str = ''
type: str = 'anchor'

Bases: object

A link to an anchor.

Variables:
  • type (str) – Type of the rich text, always ‘anchor_link’

  • text (str) – The link text

  • anchor_name (str) – The name of the anchor. If the name is empty, then the link brings back to the top of the message.

anchor_name: str = ''
classmethod from_dict(data)[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

text: str = ''
type: str = 'anchor_link'
class peyk.platforms.telegram.RichTextBankCardNumber(text: str = '', bank_card_number: str = '', type: str = 'bank_card_number')[source]

Bases: object

A text with a bank card number.

Variables:
  • type (str) – Type of the rich text, always ‘bank_card_number’

  • text (str) – The text

  • bank_card_number (str) – The bank card number

bank_card_number: str = ''
classmethod from_dict(data)[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

text: str = ''
type: str = 'bank_card_number'
class peyk.platforms.telegram.RichTextBold(text: str = '', type: str = 'bold')[source]

Bases: object

A bold text.

Variables:
  • type (str) – Type of the rich text, always ‘bold’

  • text (str) – The text

classmethod from_dict(data)[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

text: str = ''
type: str = 'bold'
class peyk.platforms.telegram.RichTextBotCommand(text: str = '', type: str = 'bot_command')[source]

Bases: object

A bot command.

Variables:
  • type (str) – Type of the rich text, always ‘bot_command’

  • text (str) – The text

  • bot_command – The bot command

classmethod from_dict(data)[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

text: str = ''
type: str = 'bot_command'
class peyk.platforms.telegram.RichTextButton(text: str = '', type: str = 'button')[source]

Bases: object

Rich text button.

classmethod from_dict(data)[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

text: str = ''
type: str = 'button'
class peyk.platforms.telegram.RichTextCashtag(text: str = '', type: str = 'cashtag')[source]

Bases: object

A cashtag.

Variables:
  • type (str) – Type of the rich text, always ‘cashtag’

  • text (str) – The text

  • cashtag – The cashtag

classmethod from_dict(data)[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

text: str = ''
type: str = 'cashtag'
class peyk.platforms.telegram.RichTextCode(text: str = '', type: str = 'code')[source]

Bases: object

A monowidth text.

Variables:
  • type (str) – Type of the rich text, always ‘code’

  • text (str) – The text

classmethod from_dict(data)[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

text: str = ''
type: str = 'code'
class peyk.platforms.telegram.RichTextCustomEmoji(text: str = '', document_id: str = '', type: str = 'custom_emoji')[source]

Bases: object

A custom emoji.

Variables:
  • type (str) – Type of the rich text, always ‘custom_emoji’

  • custom_emoji_id – Unique identifier of the custom emoji. Use getCustomEmojiStickers to get full information about the sticker.

  • alternative_text – Alternative emoji for the custom emoji

document_id: str = ''
classmethod from_dict(data)[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

text: str = ''
type: str = 'custom_emoji'
class peyk.platforms.telegram.RichTextDateTime(text: str = '', type: str = 'date_time')[source]

Bases: object

Formatted date and time.

Variables:
  • type (str) – Type of the rich text, always ‘date_time’

  • text (str) – The text

  • unix_time – The Unix time associated with the entity

  • date_time_format – The string that defines the formatting of the date and time. See date-time entity formatting for more details.

classmethod from_dict(data)[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

text: str = ''
type: str = 'date_time'
class peyk.platforms.telegram.RichTextEmailAddress(text: str = '', email: str = '', type: str = 'email_address')[source]

Bases: object

A text with an email address.

Variables:
  • type (str) – Type of the rich text, always ‘email_address’

  • text (str) – The text

  • email_address – The email address

email: str = ''
classmethod from_dict(data)[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

text: str = ''
type: str = 'email_address'
class peyk.platforms.telegram.RichTextHashtag(text: str = '', type: str = 'hashtag')[source]

Bases: object

A hashtag.

Variables:
  • type (str) – Type of the rich text, always ‘hashtag’

  • text (str) – The text

  • hashtag – The hashtag

classmethod from_dict(data)[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

text: str = ''
type: str = 'hashtag'
class peyk.platforms.telegram.RichTextItalic(text: str = '', type: str = 'italic')[source]

Bases: object

An italicized text.

Variables:
  • type (str) – Type of the rich text, always ‘italic’

  • text (str) – The text

classmethod from_dict(data)[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

text: str = ''
type: str = 'italic'
class peyk.platforms.telegram.RichTextMarked(text: str = '', type: str = 'marked')[source]

Bases: object

A marked text.

Variables:
  • type (str) – Type of the rich text, always ‘marked’

  • text (str) – The text

classmethod from_dict(data)[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

text: str = ''
type: str = 'marked'
class peyk.platforms.telegram.RichTextMathematicalExpression(text: str = '', type: str = 'mathematical_expression')[source]

Bases: object

A mathematical expression.

Variables:
  • type (str) – Type of the rich text, always ‘mathematical_expression’

  • expression – The expression in LaTeX format

classmethod from_dict(data)[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

text: str = ''
type: str = 'mathematical_expression'
class peyk.platforms.telegram.RichTextMention(text: str = '', user_id: int = 0, type: str = 'mention')[source]

Bases: object

A mention by a username.

Variables:
  • type (str) – Type of the rich text, always ‘mention’

  • text (str) – The text

  • username – The username

classmethod from_dict(data)[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

text: str = ''
type: str = 'mention'
user_id: int = 0
class peyk.platforms.telegram.RichTextPhoneNumber(text: str = '', phone_number: str = '', type: str = 'phone_number')[source]

Bases: object

A text with a phone number.

Variables:
  • type (str) – Type of the rich text, always ‘phone_number’

  • text (str) – The text

  • phone_number (str) – The phone number

classmethod from_dict(data)[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

phone_number: str = ''
text: str = ''
type: str = 'phone_number'
class peyk.platforms.telegram.RichTextReference(text: str = '', type: str = 'reference')[source]

Bases: object

A reference.

Variables:
  • type (str) – Type of the rich text, always ‘reference’

  • text (str) – Text of the reference

  • name – The name of the reference

classmethod from_dict(data)[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

text: str = ''
type: str = 'reference'

Bases: object

A link to a reference.

Variables:
  • type (str) – Type of the rich text, always ‘reference_link’

  • text (str) – The link text

  • reference_name (str) – The name of the reference

classmethod from_dict(data)[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

reference_name: str = ''
text: str = ''
type: str = 'reference_link'
class peyk.platforms.telegram.RichTextSpoiler(text: str = '', type: str = 'spoiler')[source]

Bases: object

A text covered by a spoiler.

Variables:
  • type (str) – Type of the rich text, always ‘spoiler’

  • text (str) – The text

classmethod from_dict(data)[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

text: str = ''
type: str = 'spoiler'
class peyk.platforms.telegram.RichTextStrikethrough(text: str = '', type: str = 'strikethrough')[source]

Bases: object

A strikethrough text.

Variables:
  • type (str) – Type of the rich text, always ‘strikethrough’

  • text (str) – The text

classmethod from_dict(data)[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

text: str = ''
type: str = 'strikethrough'
class peyk.platforms.telegram.RichTextSubscript(text: str = '', type: str = 'subscript')[source]

Bases: object

A subscript text.

Variables:
  • type (str) – Type of the rich text, always ‘subscript’

  • text (str) – The text

classmethod from_dict(data)[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

text: str = ''
type: str = 'subscript'
class peyk.platforms.telegram.RichTextSuperscript(text: str = '', type: str = 'superscript')[source]

Bases: object

A superscript text.

Variables:
  • type (str) – Type of the rich text, always ‘superscript’

  • text (str) – The text

classmethod from_dict(data)[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

text: str = ''
type: str = 'superscript'
class peyk.platforms.telegram.RichTextTextMention(text: str = '', user: User | None = None, type: str = 'text_mention')[source]

Bases: object

A mention of a Telegram user by their identifier.

Variables:
classmethod from_dict(data)[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

text: str = ''
type: str = 'text_mention'
user: User | None = None
class peyk.platforms.telegram.RichTextType(*values)[source]

Bases: str, Enum

RichTextType defines a public API type for peyk.

BOLD = 'bold'
ITALIC = 'italic'
UNDERLINE = 'underline'
STRIKETHROUGH = 'strikethrough'
SPOILER = 'spoiler'
DATETIME = 'datetime'
TEXT_MENTION = 'text_mention'
SUBSCRIPT = 'subscript'
SUPERSCRIPT = 'superscript'
MARKED = 'marked'
CODE = 'code'
CUSTOM_EMOJI = 'custom_emoji'
MATHEMATICAL_EXPRESSION = 'mathematical_expression'
URL = 'url'
EMAIL_ADDRESS = 'email_address'
PHONE_NUMBER = 'phone_number'
BANK_CARD_NUMBER = 'bank_card_number'
MENTION = 'mention'
HASHTAG = 'hashtag'
CASHTAG = 'cashtag'
BOT_COMMAND = 'bot_command'
BUTTON = 'button'
ANCHOR = 'anchor'
REFERENCE = 'reference'
class peyk.platforms.telegram.RichTextUnderline(text: str = '', type: str = 'underline')[source]

Bases: object

An underlined text.

Variables:
  • type (str) – Type of the rich text, always ‘underline’

  • text (str) – The text

classmethod from_dict(data)[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

text: str = ''
type: str = 'underline'
class peyk.platforms.telegram.RichTextUrl(text: str = '', url: str = '', type: str = 'url')[source]

Bases: object

A text with a link.

Variables:
  • type (str) – Type of the rich text, always ‘url’

  • text (str) – The text

  • url (str) – URL of the link

classmethod from_dict(data)[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

text: str = ''
type: str = 'url'
url: str = ''
class peyk.platforms.telegram.SentGuestMessage(chat_id: int = 0, message_id: int | None = None, inline_message_id: str | None = None)[source]

Bases: object

Describes an inline message sent by a guest bot.

Variables:

inline_message_id (str | None) – Identifier of the sent inline message

chat_id: int = 0
classmethod from_dict(data: dict | None) SentGuestMessage | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

inline_message_id: str | None = None
message_id: int | None = None
class peyk.platforms.telegram.SentWebAppMessage(inline_message_id: str | None = None)[source]

Bases: object

Describes an inline message sent by a Web App on behalf of a user.

Variables:

inline_message_id (str | None) – Identifier of the sent inline message. Available only if there is an inline keyboard attached to the message.

classmethod from_dict(data: dict | None) SentWebAppMessage | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

inline_message_id: str | None = None
class peyk.platforms.telegram.SharedUser(user_id: int = 0, first_name: str | None = None, last_name: str | None = None, username: str | None = None, photo: List[PhotoSize] | None = None)[source]

Bases: object

This object contains information about a user that was shared with the bot using a KeyboardButtonRequestUsers button.

Variables:
  • user_id (int) – Identifier of the shared user. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so 64-bit integers or double-precision float types are safe for storing these identifiers. The bot may not have access to the user and could be unable to use this identifier, unless the user is already known to the bot by some other means.

  • first_name (str | None) – First name of the user, if the name was requested by the bot

  • last_name (str | None) – Last name of the user, if the name was requested by the bot

  • username (str | None) – Username of the user, if the username was requested by the bot

  • photo (List[peyk.platforms.telegram.types.photo_size.PhotoSize] | None) – Available sizes of the chat photo, if the photo was requested by the bot

first_name: str | None = None
classmethod from_dict(data: dict | None) SharedUser | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

last_name: str | None = None
photo: List[PhotoSize] | None = None
user_id: int = 0
username: str | None = None
class peyk.platforms.telegram.ShippingAddress(country_code: str, state: str, city: str, street_line1: str, street_line2: str, post_code: str)[source]

Bases: object

This object represents a shipping address.

Variables:
  • country_code (str) – Two-letter ISO 3166-1 alpha-2 country code

  • state (str) – State, if applicable

  • city (str) – City

  • street_line1 (str) – First line for the address

  • street_line2 (str) – Second line for the address

  • post_code (str) – Address post code

classmethod from_dict(data: dict | None) ShippingAddress | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

country_code: str
state: str
city: str
street_line1: str
street_line2: str
post_code: str
class peyk.platforms.telegram.ShippingOption(id: str, title: str, prices: List[LabeledPrice])[source]

Bases: object

This object represents one shipping option.

Variables:
classmethod from_dict(data: dict | None) ShippingOption | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

to_dict()

_shipping_option_to_dict Telegram model helper.

id: str
title: str
prices: List[LabeledPrice]
class peyk.platforms.telegram.ShippingQuery(id: str, from_: User, invoice_payload: str, shipping_address: ShippingAddress)[source]

Bases: object

This object contains information about an incoming shipping query.

Variables:
classmethod from_dict(data: dict | None) ShippingQuery | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

id: str
from_: User
invoice_payload: str
shipping_address: ShippingAddress
class peyk.platforms.telegram.StarAmount(amount: int, nanostar_amount: int | None = None)[source]

Bases: object

Describes an amount of Telegram Stars.

Variables:
  • amount (int) – Integer amount of Telegram Stars, rounded to 0; can be negative

  • nanostar_amount (int | None) – The number of 1/1000000000 shares of Telegram Stars; from -999999999 to 999999999; can be negative if and only if amount is non-positive

classmethod from_dict(data: dict | None) StarAmount | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

nanostar_amount: int | None = None
amount: int
class peyk.platforms.telegram.StarTransaction(id: str, amount: int, date: int, nanostar_amount: int | None = None, source: TransactionPartnerUser | TransactionPartnerFragment | TransactionPartnerTelegramAds | TransactionPartnerOther | TransactionPartnerAffiliateProgram | TransactionPartnerChat | TransactionPartnerTelegramApi | None = None, receiver: TransactionPartnerUser | TransactionPartnerFragment | TransactionPartnerTelegramAds | TransactionPartnerOther | TransactionPartnerAffiliateProgram | TransactionPartnerChat | TransactionPartnerTelegramApi | None = None)[source]

Bases: object

Describes a Telegram Star transaction. Note that if the buyer initiates a chargeback with the payment provider from whom they acquired Stars (e.g., Apple, Google) following this transaction, the refunded Stars will be deducted from the bot’s balance. This is outside of Telegram’s control.

Variables:
classmethod from_dict(data: dict | None) StarTransaction | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

nanostar_amount: int | None = None
receiver: TransactionPartnerUser | TransactionPartnerFragment | TransactionPartnerTelegramAds | TransactionPartnerOther | TransactionPartnerAffiliateProgram | TransactionPartnerChat | TransactionPartnerTelegramApi | None = None
source: TransactionPartnerUser | TransactionPartnerFragment | TransactionPartnerTelegramAds | TransactionPartnerOther | TransactionPartnerAffiliateProgram | TransactionPartnerChat | TransactionPartnerTelegramApi | None = None
id: str
amount: int
date: int
class peyk.platforms.telegram.StarTransactions(transactions: List[StarTransaction])[source]

Bases: object

Contains a list of Telegram Star transactions.

Variables:

transactions (List[peyk.platforms.telegram.types.star_transaction.StarTransaction]) – The list of transactions

classmethod from_dict(data: dict | None) StarTransactions | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

transactions: List[StarTransaction]
class peyk.platforms.telegram.Sticker(file_id: str, file_unique_id: str, type: str, width: int, height: int, is_animated: bool = False, is_video: bool = False, thumbnail: PhotoSize | None = None, emoji: str | None = None, set_name: str | None = None, premium_animation: File | None = None, mask_position: MaskPosition | None = None, custom_emoji_id: str | None = None, needs_repainting: bool | None = None, file_size: int | None = None)[source]

Bases: object

This object represents a sticker.

Variables:
  • file_id (str) – Identifier for this file, which can be used to download or reuse the file

  • file_unique_id (str) – Unique identifier for this file, which is supposed to be the same over time and for different bots. Can’t be used to download or reuse the file.

  • type (str) – Type of the sticker, currently one of ‘regular’, ‘mask’, ‘custom_emoji’. The type of the sticker is independent from its format, which is determined by the fields is_animated and is_video.

  • width (int) – Sticker width

  • height (int) – Sticker height

  • is_animated (bool) – True, if the sticker is animated

  • is_video (bool) – True, if the sticker is a video sticker

  • thumbnail (peyk.platforms.telegram.types.photo_size.PhotoSize | None) – Sticker thumbnail in the .WEBP or .JPG format

  • emoji (str | None) – Emoji associated with the sticker

  • set_name (str | None) – Name of the sticker set to which the sticker belongs

  • premium_animation (peyk.platforms.telegram.types.file.File | None) – For premium regular stickers, premium animation for the sticker

  • mask_position (peyk.platforms.telegram.types.mask_position.MaskPosition | None) – For mask stickers, the position where the mask should be placed

  • custom_emoji_id (str | None) – For custom emoji stickers, unique identifier of the custom emoji

  • needs_repainting (bool | None) – True, if the sticker must be repainted to a text color in messages, the color of the Telegram Premium badge in emoji status, white color on chat photos, or another appropriate color in other places

  • file_size (int | None) – File size in bytes

custom_emoji_id: str | None = None
emoji: str | None = None
file_size: int | None = None
classmethod from_dict(data: dict | None) Sticker | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

is_animated: bool = False
is_video: bool = False
classmethod list_from(data: List[dict] | None) List[Sticker] | None[source]

Provides the list from operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

mask_position: MaskPosition | None = None
needs_repainting: bool | None = None
premium_animation: File | None = None
set_name: str | None = None
thumbnail: PhotoSize | None = None
file_id: str
file_unique_id: str
type: str
width: int
height: int
class peyk.platforms.telegram.StickerFormat(*values)[source]

Bases: str, Enum

StickerFormat defines a public API type for peyk.

STATIC = 'static'
ANIMATED = 'animated'
VIDEO = 'video'
class peyk.platforms.telegram.StickerSet(name: str, title: str, sticker_type: str, stickers: List[Sticker], is_animated: bool = False, is_video: bool = False, thumbnail: PhotoSize | None = None)[source]

Bases: object

This object represents a sticker set.

Variables:
  • name (str) – Sticker set name

  • title (str) – Sticker set title

  • sticker_type (str) – Type of stickers in the set, currently one of ‘regular’, ‘mask’, ‘custom_emoji’

  • stickers (List[peyk.platforms.telegram.types.sticker.Sticker]) – List of all set stickers

  • thumbnail (peyk.platforms.telegram.types.photo_size.PhotoSize | None) – Sticker set thumbnail in the .WEBP, .TGS, or .WEBM format

  • is_animated (bool) – True, if the sticker set contains animated stickers

  • is_video (bool) – True, if the sticker set contains video stickers

classmethod from_dict(data: dict | None) StickerSet | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

is_animated: bool = False
is_video: bool = False
thumbnail: PhotoSize | None = None
name: str
title: str
sticker_type: str
stickers: List[Sticker]
class peyk.platforms.telegram.StickerType(*values)[source]

Bases: StrEnum

Telegram sticker type values.

REGULAR = 'regular'
MASK = 'mask'
CUSTOM_EMOJI = 'custom_emoji'
class peyk.platforms.telegram.Story(chat: Chat | None = None, id: int | None = None)[source]

Bases: object

This object represents a story.

Variables:
chat: Chat | None = None
classmethod from_dict(data: dict | None) Story | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

id: int | None = None
class peyk.platforms.telegram.StoryArea(position: StoryAreaPosition | None = None, type: StoryAreaTypeLocation | StoryAreaTypeSuggestedReaction | StoryAreaTypeLink | StoryAreaTypeWeather | StoryAreaTypeUniqueGift | None = None)[source]

Bases: object

Describes a clickable area on a story media.

Variables:
classmethod from_dict(data: dict | None) StoryArea | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

position: StoryAreaPosition | None = None
type: StoryAreaTypeLocation | StoryAreaTypeSuggestedReaction | StoryAreaTypeLink | StoryAreaTypeWeather | StoryAreaTypeUniqueGift | None = None
class peyk.platforms.telegram.StoryAreaPosition(x_percentage: float = 0.0, y_percentage: float = 0.0, width_percentage: float = 0.0, height_percentage: float = 0.0, rotation_angle: float = 0.0, radius_percentage: float | None = None)[source]

Bases: object

Describes the position of a clickable area within a story.

Variables:
  • x_percentage (float) – The abscissa of the area’s center, as a percentage of the media width

  • y_percentage (float) – The ordinate of the area’s center, as a percentage of the media height

  • width_percentage (float) – The width of the area’s rectangle, as a percentage of the media width

  • height_percentage (float) – The height of the area’s rectangle, as a percentage of the media height

  • rotation_angle (float) – The clockwise rotation angle of the rectangle, in degrees; 0-360

  • corner_radius_percentage – The radius of the rectangle corner rounding, as a percentage of the media width

classmethod from_dict(data: dict | None) StoryAreaPosition | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

height_percentage: float = 0.0
radius_percentage: float | None = None
rotation_angle: float = 0.0
width_percentage: float = 0.0
x_percentage: float = 0.0
y_percentage: float = 0.0
class peyk.platforms.telegram.StoryAreaType(*values)[source]

Bases: StrEnum

Telegram story-area discriminator values.

LOCATION = 'location'
SUGGESTED_REACTION = 'suggested_reaction'
WEATHER = 'weather'
UNIQUE_GIFT = 'unique_gift'

Bases: object

Describes a story area pointing to an HTTP or tg:// link. Currently, a story can have up to 3 link areas.

Variables:
  • type (str) – Type of the area, always ‘link’

  • url (str) – HTTP or tg:// URL to be opened when the area is clicked

classmethod from_dict(data: dict | None) StoryAreaTypeLink | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

type: str = 'link'
url: str
class peyk.platforms.telegram.StoryAreaTypeLocation(latitude: float, longitude: float, type: str = 'location', address: LocationAddress | None = None)[source]

Bases: object

Describes a story area pointing to a location. Currently, a story can have up to 10 location areas.

Variables:
address: LocationAddress | None = None
classmethod from_dict(data: dict | None) StoryAreaTypeLocation | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

type: str = 'location'
latitude: float
longitude: float
class peyk.platforms.telegram.StoryAreaTypeSuggestedReaction(reaction_type: ReactionTypeEmoji | ReactionTypeCustomEmoji | ReactionTypePaid, type: str = 'suggested_reaction', is_dark: bool | None = None, is_flipped: bool | None = None)[source]

Bases: object

Describes a story area pointing to a suggested reaction. Currently, a story can have up to 5 suggested reaction areas.

Variables:
classmethod from_dict(data: dict | None) StoryAreaTypeSuggestedReaction | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

is_dark: bool | None = None
is_flipped: bool | None = None
type: str = 'suggested_reaction'
reaction_type: ReactionTypeEmoji | ReactionTypeCustomEmoji | ReactionTypePaid
class peyk.platforms.telegram.StoryAreaTypeUniqueGift(type: str = 'unique_gift', name: str = '')[source]

Bases: object

Describes a story area pointing to a unique gift. Currently, a story can have at most 1 unique gift area.

Variables:
  • type (str) – Type of the area, always ‘unique_gift’

  • name (str) – Unique name of the gift

classmethod from_dict(data: dict | None) StoryAreaTypeUniqueGift | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

name: str = ''
type: str = 'unique_gift'
class peyk.platforms.telegram.StoryAreaTypeWeather(temperature: float, emoji: str, background_color: int, type: str = 'weather')[source]

Bases: object

Describes a story area containing weather information. Currently, a story can have up to 3 weather areas.

Variables:
  • type (str) – Type of the area, always ‘weather’

  • temperature (float) – Temperature, in degree Celsius

  • emoji (str) – Emoji representing the weather

  • background_color (int) – A color of the area background in the ARGB format

classmethod from_dict(data: dict | None) StoryAreaTypeWeather | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

type: str = 'weather'
temperature: float
emoji: str
background_color: int
class peyk.platforms.telegram.SuccessfulPayment(currency: str, total_amount: int, invoice_payload: str, telegram_payment_charge_id: str, provider_payment_charge_id: str, subscription_expiration_date: int | None = None, is_recurring: bool | None = None, is_first_recurring: bool | None = None, shipping_option_id: str | None = None, order_info: OrderInfo | None = None)[source]

Bases: object

This object contains basic information about a successful payment. Note that if the buyer initiates a chargeback with the relevant payment provider following this transaction, the funds may be debited from your balance. This is outside of Telegram’s control.

Variables:
  • currency (str) – Three-letter ISO 4217 currency code, or ‘XTR’ for payments in Telegram Stars

  • total_amount (int) – Total price in the smallest units of the currency (integer, not float/double). For example, for a price of US$ 1.45 pass amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies).

  • invoice_payload (str) – Bot-specified invoice payload

  • telegram_payment_charge_id (str) – Telegram payment identifier

  • provider_payment_charge_id (str) – Provider payment identifier

  • subscription_expiration_date (int | None) – Expiration date of the subscription, in Unix time; for recurring payments only

  • is_recurring (bool | None) – True, if the payment is a recurring payment for a subscription

  • is_first_recurring (bool | None) – True, if the payment is the first payment for a subscription

  • shipping_option_id (str | None) – Identifier of the shipping option chosen by the user

  • order_info (peyk.platforms.telegram.types.order_info.OrderInfo | None) – Order information provided by the user

classmethod from_dict(data: dict | None) SuccessfulPayment | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

is_first_recurring: bool | None = None
is_recurring: bool | None = None
order_info: OrderInfo | None = None
shipping_option_id: str | None = None
subscription_expiration_date: int | None = None
currency: str
total_amount: int
invoice_payload: str
telegram_payment_charge_id: str
provider_payment_charge_id: str
class peyk.platforms.telegram.SuggestedPostApprovalFailed(suggested_post_message: Message | None = None, price: object | None = None)[source]

Bases: object

Describes a service message about the failed approval of a suggested post. Currently, only caused by insufficient user funds at the time of approval.

Variables:
  • price (object | None) – Expected price of the post

  • suggested_post_message (peyk.platforms.telegram.types.message.Message | None) – Message containing the suggested post whose approval has failed. Note that the Message object in this field will not contain the reply_to_message field even if it itself is a reply.

classmethod from_dict(data: dict | None) SuggestedPostApprovalFailed | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

price: object | None = None
suggested_post_message: Message | None = None
class peyk.platforms.telegram.SuggestedPostApproved(suggested_post_message: Message | None = None, price: object | None = None)[source]

Bases: object

Describes a service message about the approval of a suggested post.

Variables:
  • send_date – Date when the post will be published

  • suggested_post_message (peyk.platforms.telegram.types.message.Message | None) – Message containing the suggested post. Note that the Message object in this field will not contain the reply_to_message field even if it itself is a reply.

  • price (object | None) – Amount paid for the post

classmethod from_dict(data: dict | None) SuggestedPostApproved | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

price: object | None = None
suggested_post_message: Message | None = None
class peyk.platforms.telegram.SuggestedPostDeclined(suggested_post_message: Message | None = None, comment: str | None = None)[source]

Bases: object

Describes a service message about the rejection of a suggested post.

Variables:
  • suggested_post_message (peyk.platforms.telegram.types.message.Message | None) – Message containing the suggested post. Note that the Message object in this field will not contain the reply_to_message field even if it itself is a reply.

  • comment (str | None) – Comment with which the post was declined

comment: str | None = None
classmethod from_dict(data: dict | None) SuggestedPostDeclined | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

suggested_post_message: Message | None = None
class peyk.platforms.telegram.SuggestedPostInfo(price: object | None = None, send_date: int | None = None, is_approved: bool | None = None, is_declined: bool | None = None, decline_comment: str | None = None, refund_reason: str | None = None)[source]

Bases: object

Contains information about a suggested post.

Variables:
  • state – State of the suggested post. Currently, it can be one of ‘pending’, ‘approved’, ‘declined’.

  • price (object | None) – Proposed price of the post. If the field is omitted, then the post is unpaid.

  • send_date (int | None) – Proposed send date of the post. If the field is omitted, then the post can be published at any time within 30 days at the sole discretion of the user or administrator who approves it.

decline_comment: str | None = None
classmethod from_dict(data: dict | None) SuggestedPostInfo | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

is_approved: bool | None = None
is_declined: bool | None = None
price: object | None = None
refund_reason: str | None = None
send_date: int | None = None
class peyk.platforms.telegram.SuggestedPostPaid(suggested_post_message: Message | None = None, price: object | None = None)[source]

Bases: object

Describes a service message about a successful payment for a suggested post.

Variables:
  • currency – Currency in which the payment was made. Currently, one of ‘XTR’ for Telegram Stars or ‘TON’ for TON grams.

  • suggested_post_message (peyk.platforms.telegram.types.message.Message | None) – Message containing the suggested post. Note that the Message object in this field will not contain the reply_to_message field even if it itself is a reply.

  • amount – The amount of the currency that was received by the channel in nanograms; for payments in TON grams only

  • star_amount – The amount of Telegram Stars that was received by the channel; for payments in Telegram Stars only

classmethod from_dict(data: dict | None) SuggestedPostPaid | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

price: object | None = None
suggested_post_message: Message | None = None
class peyk.platforms.telegram.SuggestedPostParameters(price: object | None = None, send_date: int | None = None)[source]

Bases: object

Contains parameters of a post that is being suggested by the bot.

Variables:
  • price (object | None) – Proposed price for the post. If the field is omitted, then the post is unpaid.

  • send_date (int | None) – Proposed send date of the post. If specified, then the date must be between 300 second and 2678400 seconds (30 days) in the future. If the field is omitted, then the post can be published at any time within 30 days at the sole discretion of the user who approves it.

price: object | None = None
send_date: int | None = None
to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

class peyk.platforms.telegram.SuggestedPostPrice(label: str = '', amount: int = 0)[source]

Bases: object

Describes the price of a suggested post.

Variables:
  • currency – Currency in which the post will be paid. Currently, must be one of ‘XTR’ for Telegram Stars or ‘TON’ for TON grams.

  • amount (int) – The amount of the currency that will be paid for the post in the smallest units of the currency, i.e. Telegram Stars or nanograms. Currently, price in Telegram Stars must be between 5 and 100000, and price in nanograms must be between 10000000 and 10000000000000.

amount: int = 0
classmethod from_dict(data: dict | None) SuggestedPostPrice | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

label: str = ''
class peyk.platforms.telegram.SuggestedPostRefunded(suggested_post_message: Message | None = None, price: object | None = None, reason: str | None = None)[source]

Bases: object

Describes a service message about a payment refund for a suggested post.

Variables:
  • reason (str | None) – Reason for the refund. Currently, one of ‘post_deleted’ if the post was deleted within 24 hours of being posted or removed from scheduled messages without being posted, or ‘payment_refunded’ if the payer refunded their payment.

  • suggested_post_message (peyk.platforms.telegram.types.message.Message | None) – Message containing the suggested post. Note that the Message object in this field will not contain the reply_to_message field even if it itself is a reply.

classmethod from_dict(data: dict | None) SuggestedPostRefunded | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

price: object | None = None
reason: str | None = None
suggested_post_message: Message | None = None
class peyk.platforms.telegram.SwitchInlineQueryChosenChat(query: str | None = None, allow_user_chats: bool | None = None, allow_bot_chats: bool | None = None, allow_group_chats: bool | None = None, allow_channel_chats: bool | None = None)[source]

Bases: object

This object represents an inline button that switches the current user to inline mode in a chosen chat, with an optional default inline query.

Variables:
  • query (str | None) – The default inline query to be inserted in the input field. If left empty, only the bot’s username will be inserted.

  • allow_user_chats (bool | None) – True, if private chats with users can be chosen

  • allow_bot_chats (bool | None) – True, if private chats with bots can be chosen

  • allow_group_chats (bool | None) – True, if group and supergroup chats can be chosen

  • allow_channel_chats (bool | None) – True, if channel chats can be chosen

allow_bot_chats: bool | None = None
allow_channel_chats: bool | None = None
allow_group_chats: bool | None = None
allow_user_chats: bool | None = None
classmethod from_dict(data: dict | None) SwitchInlineQueryChosenChat | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

query: str | None = None
to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

exception peyk.platforms.telegram.TelegramAPIError(message: str, *, error_code: int, description: str, parameters: ResponseParameters | None = None)[source]

Bases: TransportError

Raised when a Telegram API response has ok: false (no rate hint).

Variables:
  • error_code – Telegram’s error_code integer from the response body.

  • description – Telegram’s human-readable description string.

  • parameters – The optional parameters object Telegram sometimes includes alongside an error (a ResponseParameters when the raw dict parses, else the raw value). None when absent. Note: when the parameters carry retry_after, TelegramClient raises RateLimitedError instead of this class – so a TelegramAPIError observed in practice never carries a retry hint (see module docstring).

class peyk.platforms.telegram.TelegramClient(token: str, session: Session | None = None, *, retry_policy: RetryPolicy | None = None, logger: object = None, base_url: str | None = None)[source]

Bases: TelegramLikeClient[User, WebhookInfo, File, ChatFullInfo, ChatMemberOwner | ChatMemberAdministrator | ChatMemberMember | ChatMemberRestricted | ChatMemberLeft | ChatMemberBanned]

A thin, typed async wrapper around the Telegram Bot API.

Parameters:
  • token – The bot token issued by Telegram (@BotFather).

  • session – An existing peyk.transport.Session to reuse. If not given, a default-tuned Session is built.

  • retry_policy – Transport-level retry policy for this client’s calls. Defaults to RetryPolicy()’s defaults.

  • logger – Passed through to a Session this client builds itself; ignored if an existing session is given (that session already has its own logger).

  • base_url – Override for the API base URL. Not part of the real Telegram API surface – exists solely so tests can point this client at a local fake server instead of api.telegram.org.

async add_sticker_to_set(user_id: int, name: str, sticker: InputSticker) bool

Use this method to add a new sticker to a set created by the bot. Emoji sticker sets can have up to 200 stickers. Other sticker sets can have up to 120 stickers. Returns True on success.

Parameters:
  • user_id – User identifier of sticker set owner

  • name – Sticker set name

  • sticker – A JSON-serialized object with information about the added sticker. If exactly the same sticker had already been added to the set, then the set isn’t changed.

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async answer_callback_query(callback_query_id: str, *, text: str | None = None, show_alert: bool | None = None, url: str | None = None, cache_time: int | None = None) bool

Use this method to send answers to callback queries sent from inline keyboards. The answer will be displayed to the user as a notification at the top of the chat screen or as an alert. On success, True is returned. Alternatively, the user can be redirected to the specified Game URL. For this option to work, you must first create a game for your bot via @BotFather and accept the terms. Otherwise, you may use links like t.me/your_bot?start=XXXX that open your bot with a parameter.

Parameters:
  • callback_query_id – Unique identifier for the query to be answered

  • text – Text of the notification. If not specified, nothing will be shown to the user, 0-200 characters.

  • show_alert – If True, an alert will be shown by the client instead of a notification at the top of the chat screen. Defaults to False.

  • url – URL that will be opened by the user’s client. If you have created a Game and accepted the conditions via @BotFather, specify the URL that opens your game - note that this will only work if the query comes from a callback_game button.

Otherwise, you may use links like t.me/your_bot?start=XXXX that open your bot with a parameter.

cache_time: The maximum amount of time in seconds that the result of the callback query may be cached client-side. Telegram apps will support caching starting in version 3.14. Defaults to 0.

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async answer_chat_join_request_query(chat_join_request_query_id: str | None = None, result: str | None = None, *, chat_id: int | None = None, user_id: int | None = None, query_id: str | None = None) bool

Use this method to process a received chat join request query. Returns True on success.

Parameters:
  • chat_join_request_query_id – Unique identifier of the join request query

  • result – Result of the query. Must be either ‘approve’ to allow the user to join the chat, ‘decline’ to disallow the user to join the chat, or ‘queue’ to leave the decision to other administrators.

  • chat_id – Value accepted by this operation.

  • user_id – Value accepted by this operation.

  • query_id – Value accepted by this operation.

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async answer_guest_query(guest_query_id: str, result: InlineQueryResultArticle | InlineQueryResultPhoto | InlineQueryResultGif | InlineQueryResultMpeg4Gif | InlineQueryResultVideo | InlineQueryResultAudio | InlineQueryResultVoice | InlineQueryResultDocument | InlineQueryResultLocation | InlineQueryResultVenue | InlineQueryResultContact | InlineQueryResultGame | InlineQueryResultCachedPhoto | InlineQueryResultCachedGif | InlineQueryResultCachedMpeg4Gif | InlineQueryResultCachedSticker | InlineQueryResultCachedDocument | InlineQueryResultCachedVideo | InlineQueryResultCachedVoice | InlineQueryResultCachedAudio) SentGuestMessage

Use this method to reply to a received guest message. On success, a SentGuestMessage object is returned.

Parameters:
  • guest_query_id – Unique identifier for the query to be answered

  • result – A JSON-serialized object describing the message to be sent

Returns:

Result returned by Telegram on successful execution.

Return type:

SentGuestMessage

async answer_inline_query(inline_query_id: str, results: Sequence[InlineQueryResultArticle | InlineQueryResultPhoto | InlineQueryResultGif | InlineQueryResultMpeg4Gif | InlineQueryResultVideo | InlineQueryResultAudio | InlineQueryResultVoice | InlineQueryResultDocument | InlineQueryResultLocation | InlineQueryResultVenue | InlineQueryResultContact | InlineQueryResultGame | InlineQueryResultCachedPhoto | InlineQueryResultCachedGif | InlineQueryResultCachedMpeg4Gif | InlineQueryResultCachedSticker | InlineQueryResultCachedDocument | InlineQueryResultCachedVideo | InlineQueryResultCachedVoice | InlineQueryResultCachedAudio | Mapping[str, object]], *, cache_time: int | None = None, is_personal: bool | None = None, next_offset: str | None = None, button: InlineQueryResultsButton | Mapping[str, object] | None = None) bool

Use this method to send answers to an inline query. On success, True is returned. No more than 50 results per query are allowed.

Parameters:
  • inline_query_id – Unique identifier for the answered query

  • results – A JSON-serialized Array of results for the inline query

  • cache_time – The maximum amount of time in seconds that the result of the inline query may be cached on the server. Defaults to 300.

  • is_personal – Pass True if results may be cached on the server side only for the user that sent the query. By default, results may be returned to any user who sends the same query.

  • next_offset – Pass the offset that a client should send in the next query with the same text to receive more results. Pass an empty string if there are no more results or if you don’t support pagination. Offset length can’t exceed 64 bytes.

  • button – A JSON-serialized object describing a button to be shown above inline query results

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async answer_pre_checkout_query(pre_checkout_query_id: str, ok: bool, *, error_message: str | None = None) bool

Once the user has confirmed their payment and shipping details, the Bot API sends the final confirmation in the form of an Update with the field pre_checkout_query. Use this method to respond to such pre-checkout queries. On success, True is returned. Note: The Bot API must receive an answer within 10 seconds after the pre-checkout query was sent.

Parameters:
  • pre_checkout_query_id – Unique identifier for the query to be answered

  • ok – Specify True if everything is alright (goods are available, etc.) and the bot is ready to proceed with the order. Use False if there are any problems.

  • error_message – Required if ok is False. Error message in human readable form that explains the reason for failure to proceed with the checkout (e.g. “Sorry, somebody just bought the last of our amazing black T-shirts while you were busy filling out your payment details. Please choose a different color or garment!”). Telegram will display this message to the user.

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async answer_shipping_query(shipping_query_id: str, ok: bool, *, shipping_options: List[ShippingOption] | None = None, error_message: str | None = None) bool

If you sent an invoice requesting a shipping address and the parameter is_flexible was specified, the Bot API will send an Update with a shipping_query field to the bot. Use this method to reply to shipping queries. On success, True is returned.

Parameters:
  • shipping_query_id – Unique identifier for the query to be answered

  • ok – Pass True if delivery to the specified address is possible and False if there are any problems (for example, if delivery to the specified address is not possible)

  • shipping_options – Required if ok is True. A JSON-serialized Array of available shipping options.

  • error_message – Required if ok is False. Error message in human readable form that explains why it is impossible to complete the order (e.g. ‘Sorry, delivery to your desired address is unavailable’). Telegram will display this message to the user.

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async answer_web_app_query(web_app_query_id: str, result: InlineQueryResultArticle | InlineQueryResultPhoto | InlineQueryResultGif | InlineQueryResultMpeg4Gif | InlineQueryResultVideo | InlineQueryResultAudio | InlineQueryResultVoice | InlineQueryResultDocument | InlineQueryResultLocation | InlineQueryResultVenue | InlineQueryResultContact | InlineQueryResultGame | InlineQueryResultCachedPhoto | InlineQueryResultCachedGif | InlineQueryResultCachedMpeg4Gif | InlineQueryResultCachedSticker | InlineQueryResultCachedDocument | InlineQueryResultCachedVideo | InlineQueryResultCachedVoice | InlineQueryResultCachedAudio) SentWebAppMessage

Use this method to set the result of an interaction with a Web App and send a corresponding message on behalf of the user to the chat from which the query originated. On success, a SentWebAppMessage object is returned.

Parameters:
  • web_app_query_id – Unique identifier for the query to be answered

  • result – A JSON-serialized object describing the message to be sent

Returns:

Result returned by Telegram on successful execution.

Return type:

SentWebAppMessage

async approve_chat_join_request(chat_id: int | str, user_id: int) bool

Use this method to approve a chat join request. The bot must be an administrator in the chat for this to work and must have the can_invite_users administrator right. Returns True on success.

Parameters:
  • chat_id – Unique identifier for the target chat or username of the target channel in the format @username

  • user_id – Unique identifier of the target user

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async approve_suggested_post(chat_id: int, message_id: int, *, send_date: int | None = None) bool

Use this method to approve a suggested post in a direct messages chat. The bot must have the ‘can_post_messages’ administrator right in the corresponding channel chat. Returns True on success.

Parameters:
  • chat_id – Unique identifier for the target direct messages chat

  • message_id – Identifier of a suggested post message to approve

  • send_date – Point in time (Unix timestamp) when the post is expected to be published; omit if the date has already been specified when the suggested post was created. If specified, then the date must be not more than 2678400 seconds (30 days) in the future.

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async ban_chat_member(chat_id: int | str, user_id: int, *, until_date: int | None = None, revoke_messages: bool | None = None) bool

Use this method to ban a user in a group, a supergroup or a channel. In the case of supergroups and channels, the user will not be able to return to the chat on their own using invite links, etc., unless unbanned first. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success.

Parameters:
  • chat_id – Unique identifier for the target group or username of the target supergroup or channel in the format @username

  • user_id – Unique identifier of the target user

  • until_date – Date when the user will be unbanned; Unix time. If user is banned for more than 366 days or less than 30 seconds from the current time they are considered to be banned forever. Applied for supergroups and channels only.

  • revoke_messages – Pass True to delete all messages from the chat for the user that is being removed. If False, the user will be able to see messages in the group that were sent before the user was removed. Always True for supergroups and channels.

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async ban_chat_sender_chat(chat_id: int | str, sender_chat_id: int) bool

Use this method to ban a channel chat in a supergroup or a channel. Until the chat is unbanned, the owner of the banned chat won’t be able to send messages on behalf of any of their channels. The bot must be an administrator in the supergroup or channel for this to work and must have the appropriate administrator rights. Returns True on success.

Parameters:
  • chat_id – Unique identifier for the target chat or username of the target channel in the format @username

  • sender_chat_id – Unique identifier of the target sender chat

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

base_url: str = 'https://api.telegram.org'
chat_member_count_method: str = 'getChatMemberCount'
chat_member_parser() ChatMemberOwner | ChatMemberAdministrator | ChatMemberMember | ChatMemberRestricted | ChatMemberLeft | ChatMemberBanned | None

Provides the parse chat member operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

chat_model

alias of ChatFullInfo

async close_bot() bool

Close the bot from the cloud Bot API server.

This name intentionally avoids colliding with TelegramClient.close(), which closes the local HTTP session.

Returns:

The operation result (bool).

async close_forum_topic(chat_id: int | str, message_thread_id: int) bool

Use this method to close an open topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic. Returns True on success.

Parameters:
  • chat_id – Unique identifier for the target chat or username of the target supergroup in the format @username

  • message_thread_id – Unique identifier for the target message thread of the forum topic

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async close_general_forum_topic(chat_id: int | str) bool

Use this method to close an open ‘General’ topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. Returns True on success.

Parameters:

chat_id – Unique identifier for the target chat or username of the target supergroup in the format @username

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async convert_gift_to_stars(business_connection_id: str, owned_gift_id: str) bool

Converts a given regular gift to Telegram Stars. Requires the can_convert_gifts_to_stars business bot right. Returns True on success.

Parameters:
  • business_connection_id – Unique identifier of the business connection

  • owned_gift_id – Unique identifier of the regular gift that should be converted to Telegram Stars

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async copy_message(chat_id: ChatId, from_chat_id: ChatId, message_id: int, *, message_thread_id: int | None = None, caption: str | None = None, parse_mode: str | None = None, caption_entities: EntitiesInput | None = None, show_caption_above_media: bool | None = None, disable_notification: bool | None = None, protect_content: bool | None = None, reply_parameters: ReplyParameters | Mapping[str, object] | None = None, reply_markup: ReplyMarkup | None = None) message

Use this method to copy messages of any kind. Service messages, paid media messages, giveaway messages, giveaway winners messages, and invoice messages can’t be copied. A quiz poll can be copied only if the value of the field correct_option_id is known to the bot. The method is analogous to the method forwardMessage, but the copied message doesn’t have a link to the original message. Returns the MessageId of the sent message on success.

Parameters:
  • chat_id – Unique identifier for the target chat or username of the target bot, supergroup or channel in the format @username

  • from_chat_id – Unique identifier for the chat where the original message was sent (or username of the target bot, supergroup or channel in the format @username)

  • message_id – Message identifier in the chat specified in from_chat_id

  • message_thread_id – Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only

  • caption – New caption for media, 0-1024 characters after entities parsing. If not specified, the original caption is kept.

  • parse_mode – Mode for parsing entities in the new caption. See formatting options for more details.

  • caption_entities – A JSON-serialized list of special entities that appear in the new caption, which can be specified instead of parse_mode

  • show_caption_above_media – Pass True if the caption must be shown above the message media. Ignored if a new caption isn’t specified.

  • disable_notification – Sends the message silently. Users will receive a notification with no sound.

  • protect_content – Protects the contents of the sent message from forwarding and saving

  • reply_parameters – Description of the message to reply to

  • reply_markup – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove a reply keyboard or to force a reply from the user.

Returns:

Result returned by Telegram on successful execution.

Return type:

message

async copy_messages(chat_id: int | str, from_chat_id: int | str, message_ids: Sequence[int], *, message_thread_id: int | None = None, disable_notification: bool | None = None, protect_content: bool | None = None, remove_caption: bool | None = None) List[MessageId]

Use this method to copy messages of any kind. If some of the specified messages can’t be found or copied, they are skipped. Service messages, paid media messages, giveaway messages, giveaway winners messages, and invoice messages can’t be copied. A quiz poll can be copied only if the value of the field correct_option_id is known to the bot. The method is analogous to the method forwardMessages, but the copied messages don’t have a link to the original message. Album grouping is kept for copied messages. On success, an Array of MessageId of the sent messages is returned.

Parameters:
  • chat_id – Unique identifier for the target chat or username of the target bot, supergroup or channel in the format @username

  • from_chat_id – Unique identifier for the chat where the original messages were sent (or username of the target bot, supergroup or channel in the format @username)

  • message_ids – A JSON-serialized list of 1-100 identifiers of messages in the chat from_chat_id to copy. The identifiers must be specified in a strictly increasing order.

  • message_thread_id – Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only

  • disable_notification – Sends the messages silently. Users will receive a notification with no sound.

  • protect_content – Protects the contents of the sent messages from forwarding and saving

  • remove_caption – Pass True to copy the messages without their captions

Returns:

Result returned by Telegram on successful execution.

Return type:

List[MessageId]

Use this method to create an additional invite link for a chat. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. The link can be revoked using the method revokeChatInviteLink. Returns the new invite link as ChatInviteLink object.

Parameters:
  • chat_id – Unique identifier for the target chat or username of the target channel in the format @username

  • name – Invite link name; 0-32 characters

  • expire_date – Point in time (Unix timestamp) when the link will expire

  • member_limit – The maximum number of users that can be members of the chat simultaneously after joining the chat via this invite link; 1-99999

  • creates_join_request – True, if users joining the chat via the link need to be approved by chat administrators. If True, member_limit can’t be specified.

Use this method to create a subscription invite link for a channel chat. The bot must have the can_invite_users administrator rights. The link can be edited using the method editChatSubscriptionInviteLink or revoked using the method revokeChatInviteLink. Returns the new invite link as a ChatInviteLink object.

Parameters:
  • chat_id – Unique identifier for the target channel chat or username of the target channel in the format @username

  • subscription_period – The number of seconds the subscription will be active for before the next payment. Currently, it must always be 2592000 (30 days).

  • subscription_price – The amount of Telegram Stars a user must pay initially and after each subsequent subscription period to be a member of the chat; 1-10000

  • name – Invite link name; 0-32 characters

async create_forum_topic(chat_id: int | str, name: str, *, icon_color: int | None = None, icon_custom_emoji_id: str | None = None) ForumTopic

Use this method to create a topic in a forum supergroup chat or a private chat with a user. In the case of a supergroup chat the bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator right. Returns information about the created topic as a ForumTopic object.

Parameters:
  • chat_id – Unique identifier for the target chat or username of the target supergroup in the format @username

  • name – Topic name, 1-128 characters

  • icon_color – Color of the topic icon in RGB format. Currently, must be one of 7322096 (0x6FB9F0), 16766590 (0xFFD67E), 13338331 (0xCB86DB), 9367192 (0x8EEE98), 16749490 (0xFF93B2), or 16478047 (0xFB6F5F).

  • icon_custom_emoji_id – Unique identifier of the custom emoji shown as the topic icon. Use getForumTopicIconStickers to get all allowed custom emoji identifiers.

Use this method to create a link for an invoice. Returns the created invoice link as String on success.

Parameters:
  • title – Product name, 1-32 characters

  • description – Product description, 1-255 characters

  • payload – Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use it for your internal processes.

  • currency – Three-letter ISO 4217 currency code, see more on currencies. Pass ‘XTR’ for payments in Telegram Stars.

  • prices – Price breakdown, a JSON-serialized list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.). Must contain exactly one item for payments in Telegram Stars.

  • business_connection_id – Unique identifier of the business connection on behalf of which the link will be created. For payments in Telegram Stars only.

  • provider_token – Payment provider token, obtained via @BotFather. Pass an empty string for payments in Telegram Stars.

  • subscription_period – The number of seconds the subscription will be active for before the next payment. The currency must be set to ‘XTR’ (Telegram Stars) if the parameter is used. Currently, it must always be 2592000 (30 days) if specified. Any number of subscriptions can be active for a given bot at the same time, including multiple concurrent subscriptions from the same user. Subscription price must no exceed 10000 Telegram Stars.

  • max_tip_amount – The maximum accepted amount for tips in the smallest units of the currency (integer, not float/double). For example, for a maximum tip of US$ 1.45 pass max_tip_amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). Defaults to 0. Not supported for payments in Telegram Stars.

  • suggested_tip_amounts – A JSON-serialized Array of suggested amounts of tips in the smallest units of the currency (integer, not float/double). At most 4 suggested tip amounts can be specified. The suggested tip amounts must be positive, passed in a strictly increased order and must not exceed max_tip_amount.

  • provider_data – JSON-serialized data about the invoice, which will be shared with the payment provider. A detailed description of required fields should be provided by the payment provider.

  • photo_url – URL of the product photo for the invoice. Can be a photo of the goods or a marketing image for a service.

  • photo_size – Photo size in bytes

  • photo_width – Photo width

  • photo_height – Photo height

  • need_name – Pass True if you require the user’s full name to complete the order. Ignored for payments in Telegram Stars.

  • need_phone_number – Pass True if you require the user’s phone number to complete the order. Ignored for payments in Telegram Stars.

  • need_email – Pass True if you require the user’s email address to complete the order. Ignored for payments in Telegram Stars.

  • need_shipping_address – Pass True if you require the user’s shipping address to complete the order. Ignored for payments in Telegram Stars.

  • send_phone_number_to_provider – Pass True if the user’s phone number should be sent to the provider. Ignored for payments in Telegram Stars.

  • send_email_to_provider – Pass True if the user’s email address should be sent to the provider. Ignored for payments in Telegram Stars.

  • is_flexible – Pass True if the final price depends on the shipping method. Ignored for payments in Telegram Stars.

Returns:

Result returned by Telegram on successful execution.

Return type:

str

async create_new_sticker_set(user_id: int, name: str, title: str, stickers: Sequence[InputSticker], *, sticker_type: str | None = None, needs_repainting: bool | None = None) bool

Use this method to create a new sticker set owned by a user. The bot will be able to edit the sticker set thus created. Returns True on success.

Parameters:
  • user_id – User identifier of created sticker set owner

  • name – Short name of sticker set, to be used in t.me/addstickers/ URLs (e.g., animals). Can contain only English letters, digits and underscores. Must begin with a letter, can’t contain consecutive underscores and must end in “_by_”. is case insensitive. 1-64 characters.

  • title – Sticker set title, 1-64 characters

  • stickers – A JSON-serialized list of 1-50 initial stickers to be added to the sticker set

  • sticker_type – Type of stickers in the set, pass ‘regular’, ‘mask’, or ‘custom_emoji’. By default, a regular sticker set is created.

  • needs_repainting – Pass True if stickers in the sticker set must be repainted to the color of text when used in messages, the accent color if used as emoji status, white on chat photos, or another appropriate color based on context; for custom emoji sticker sets only

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async decline_chat_join_request(chat_id: int | str, user_id: int) bool

Use this method to decline a chat join request. The bot must be an administrator in the chat for this to work and must have the can_invite_users administrator right. Returns True on success.

Parameters:
  • chat_id – Unique identifier for the target chat or username of the target channel in the format @username

  • user_id – Unique identifier of the target user

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async decline_suggested_post(chat_id: int, message_id: int, *, comment: str | None = None) bool

Use this method to decline a suggested post in a direct messages chat. The bot must have the ‘can_manage_direct_messages’ administrator right in the corresponding channel chat. Returns True on success.

Parameters:
  • chat_id – Unique identifier for the target direct messages chat

  • message_id – Identifier of a suggested post message to decline

  • comment – Comment for the creator of the suggested post; 0-128 characters

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async delete_all_message_reactions(chat_id: int | str, message_id: int | None = None, *, user_id: int | None = None, actor_chat_id: int | None = None) bool

Use this method to remove up to 10000 recent reactions in a group or a supergroup chat added by a given user or chat. The bot must have the ‘can_delete_messages’ administrator right in the chat. Returns True on success.

Parameters:
  • chat_id – Unique identifier for the target chat or username of the target supergroup in the format @username

  • message_id – Value accepted by this operation.

  • user_id – Identifier of the user whose reactions will be removed, if the reactions were added by a user

  • actor_chat_id – Identifier of the chat whose reactions will be removed, if the reactions were added by a chat

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async delete_business_messages(business_connection_id: str, message_ids: List[int]) bool

Delete messages on behalf of a business account. Requires the can_delete_sent_messages business bot right to delete messages sent by the bot itself, or the can_delete_all_messages business bot right to delete any message. Returns True on success.

Parameters:
  • business_connection_id – Unique identifier of the business connection on behalf of which to delete the messages

  • message_ids – A JSON-serialized list of 1-100 identifiers of messages to delete. All messages must be from the same chat. See deleteMessage for limitations on which messages can be deleted.

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async delete_chat_sticker_set(chat_id: int | str) bool

Use this method to delete a group sticker set from a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Use the field can_set_sticker_set optionally returned in getChat requests to check if the bot can use this method. Returns True on success.

Parameters:

chat_id – Unique identifier for the target chat or username of the target supergroup in the format @username

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async delete_ephemeral_message(chat_id: int | str, receiver_user_id: int | None = None, ephemeral_message_id: int | None = None) bool

Use this method to delete an ephemeral message. Note that it is not guaranteed that the user will receive the message deletion event, especially if they are offline. Returns True on success.

Parameters:
  • chat_id – Unique identifier for the target chat or username of the target supergroup in the format @username

  • receiver_user_id – Identifier of the user who received the message

  • ephemeral_message_id – Identifier of the ephemeral message to delete

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async delete_forum_topic(chat_id: int | str, message_thread_id: int) bool

Use this method to delete a forum topic along with all its messages in a forum supergroup chat or a private chat with a user. In the case of a supergroup chat the bot must be an administrator in the chat for this to work and must have the can_delete_messages administrator rights. Returns True on success.

Parameters:
  • chat_id – Unique identifier for the target chat or username of the target supergroup in the format @username

  • message_thread_id – Unique identifier for the target message thread of the forum topic

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async delete_message_reaction(chat_id: int | str, message_id: int, *, user_id: int | None = None, actor_chat_id: int | None = None) bool

Use this method to remove a reaction from a message in a group or a supergroup chat. The bot must have the ‘can_delete_messages’ administrator right in the chat. Returns True on success.

Parameters:
  • chat_id – Unique identifier for the target chat or username of the target supergroup in the format @username

  • message_id – Identifier of the target message

  • user_id – Identifier of the user whose reaction will be removed, if the reaction was added by a user

  • actor_chat_id – Identifier of the chat whose reaction will be removed, if the reaction was added by a chat

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async delete_messages(chat_id: int | str, message_ids: Sequence[int]) bool

Use this method to delete multiple messages simultaneously. If some of the specified messages can’t be found, they are skipped. Returns True on success.

Parameters:
  • chat_id – Unique identifier for the target chat or username of the target bot, supergroup or channel in the format @username

  • message_ids – A JSON-serialized list of 1-100 identifiers of messages to delete. See deleteMessage for limitations on which messages can be deleted.

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async delete_my_commands(*, scope: BotCommandScopeDefault | BotCommandScopeAllPrivateChats | BotCommandScopeAllGroupChats | BotCommandScopeAllChatAdministrators | BotCommandScopeChat | BotCommandScopeChatAdministrators | BotCommandScopeChatMember | Mapping[str, object] | None = None, language_code: str | None = None) bool

Use this method to delete the list of the bot’s commands for the given scope and user language. After deletion, higher level commands will be shown to affected users. Returns True on success.

Parameters:
  • scope – A JSON-serialized object, describing scope of users for which the commands are relevant. Defaults to BotCommandScopeDefault.

  • language_code – A two-letter ISO 639-1 language code. If empty, commands will be applied to all users from the given scope, for whose language there are no dedicated commands.

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async delete_sticker_from_set(sticker: str) bool

Use this method to delete a sticker from a set created by the bot. Returns True on success.

Parameters:

sticker – File identifier of the sticker

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async delete_sticker_set(name: str) bool

Use this method to delete a sticker set that was created by the bot. Returns True on success.

Parameters:

name – Sticker set name

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async delete_story(business_connection_id: str, story_id: int) bool

Deletes a story previously posted by the bot on behalf of a managed business account. Requires the can_manage_stories business bot right. Returns True on success.

Parameters:
  • business_connection_id – Unique identifier of the business connection

  • story_id – Unique identifier of the story to delete

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async delete_webhook(*, drop_pending_updates: bool | None = None) bool

Use this method to remove webhook integration if you decide to switch back to getUpdates. Returns True on success.

Parameters:

drop_pending_updates – Pass True to drop all pending updates

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

Use this method to edit a non-primary invite link created by the bot. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the edited invite link as a ChatInviteLink object.

Parameters:
  • chat_id – Unique identifier for the target chat or username of the target channel in the format @username

  • invite_link – The invite link to edit

  • name – Invite link name; 0-32 characters

  • expire_date – Point in time (Unix timestamp) when the link will expire

  • member_limit – The maximum number of users that can be members of the chat simultaneously after joining the chat via this invite link; 1-99999

  • creates_join_request – True, if users joining the chat via the link need to be approved by chat administrators. If True, member_limit can’t be specified.

Use this method to edit a subscription invite link created by the bot. The bot must have the can_invite_users administrator rights. Returns the edited invite link as a ChatInviteLink object.

Parameters:
  • chat_id – Unique identifier for the target chat or username of the target channel in the format @username

  • invite_link – The invite link to edit

  • name – Invite link name; 0-32 characters

async edit_ephemeral_message_caption(chat_id: int | str, receiver_user_id: int | None = None, ephemeral_message_id: int | None = None, *, caption: str | None = None, parse_mode: str | None = None, caption_entities: List[MessageEntity] | None = None, show_caption_above_media: bool | None = None, reply_markup: InlineKeyboardMarkup | None = None) bool

Use this method to edit the caption of an ephemeral message. Note that it is not guaranteed that the user will receive the message edit event, especially if they are offline. On success, True is returned.

Parameters:
  • chat_id – Unique identifier for the target chat or username of the target supergroup in the format @username

  • receiver_user_id – Identifier of the user who received the message

  • ephemeral_message_id – Identifier of the ephemeral message to edit

  • caption – New caption of the message, 0-1024 characters after entities parsing

  • parse_mode – Mode for parsing entities in the message caption. See formatting options for more details.

  • caption_entities – A JSON-serialized list of special entities that appear in the caption, which can be specified instead of parse_mode

  • show_caption_above_media – Value accepted by this operation.

  • reply_markup – A JSON-serialized object for an inline keyboard

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async edit_ephemeral_message_media(chat_id: int | str, receiver_user_id: int | None = None, ephemeral_message_id: int | None = None, media: InputMediaAnimation | InputMediaAudio | InputMediaDocument | InputMediaLivePhoto | InputMediaPhoto | InputMediaVideo | None = None, *, reply_markup: InlineKeyboardMarkup | None = None) bool

Use this method to edit the media of an ephemeral message. Note that it is not guaranteed that the user will receive the message edit event, especially if they are offline. On success, True is returned.

Parameters:
  • chat_id – Unique identifier for the target chat or username of the target supergroup in the format @username

  • receiver_user_id – Identifier of the user who received the message

  • ephemeral_message_id – Identifier of the ephemeral message to edit

  • media – A JSON-serialized object for the new media content of the message. A new file can’t be uploaded; use a previously uploaded file via its file_id or specify a URL.

  • reply_markup – A JSON-serialized object for an inline keyboard

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async edit_ephemeral_message_reply_markup(chat_id: int | str, receiver_user_id: int | None = None, ephemeral_message_id: int | None = None, *, reply_markup: InlineKeyboardMarkup | None = None) bool

Use this method to edit only the reply markup of an ephemeral message. Note that it is not guaranteed that the user will receive the message edit event, especially if they are offline. On success, True is returned.

Parameters:
  • chat_id – Unique identifier for the target chat or username of the target supergroup in the format @username

  • receiver_user_id – Identifier of the user who received the message

  • ephemeral_message_id – Identifier of the ephemeral message to edit

  • reply_markup – A JSON-serialized object for an inline keyboard

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async edit_ephemeral_message_text(chat_id: int | str, receiver_user_id: int | None = None, ephemeral_message_id: int | None = None, *, text: str | None = None, parse_mode: str | None = None, entities: List[MessageEntity] | None = None, rich_message: InputRichMessage | None = None, link_preview_options: LinkPreviewOptions | None = None, reply_markup: InlineKeyboardMarkup | None = None) bool

Use this method to edit an ephemeral text message. Note that it is not guaranteed that the user will receive the message edit event, especially if they are offline. On success, True is returned.

Parameters:
  • chat_id – Unique identifier for the target chat or username of the target supergroup in the format @username

  • receiver_user_id – Identifier of the user who received the message

  • ephemeral_message_id – Identifier of the ephemeral message to edit

  • text – New text of the message, 1-4096 characters after entity parsing

  • parse_mode – Mode for parsing entities in the message text. See formatting options for more details.

  • entities – A JSON-serialized list of special entities that appear in message text, which can be specified instead of parse_mode

  • rich_message – Value accepted by this operation.

  • link_preview_options – Link preview generation options for the message

  • reply_markup – A JSON-serialized object for an inline keyboard

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async edit_forum_topic(chat_id: int | str, message_thread_id: int, *, name: str | None = None, icon_color: int | None = None, icon_custom_emoji_id: str | None = None) bool

Use this method to edit name and icon of a topic in a forum supergroup chat or a private chat with a user. In the case of a supergroup chat the bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic. Returns True on success.

Parameters:
  • chat_id – Unique identifier for the target chat or username of the target supergroup in the format @username

  • message_thread_id – Unique identifier for the target message thread of the forum topic

  • name – New topic name, 0-128 characters. If not specified or empty, the current name of the topic will be kept.

  • icon_color – Value accepted by this operation.

  • icon_custom_emoji_id – New unique identifier of the custom emoji shown as the topic icon. Use getForumTopicIconStickers to get all allowed custom emoji identifiers. Pass an empty string to remove the icon. If not specified, the current icon will be kept.

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async edit_general_forum_topic(chat_id: int | str, name: str) bool

Use this method to edit the name of the ‘General’ topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. Returns True on success.

Parameters:
  • chat_id – Unique identifier for the target chat or username of the target supergroup in the format @username

  • name – New topic name, 1-128 characters

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async edit_message_caption(*, chat_id: int | str | None = None, message_id: int | None = None, inline_message_id: str | None = None, caption: str | None = None, parse_mode: str | None = None, caption_entities: Sequence[MessageEntity | Mapping[str, object]] | None = None, show_caption_above_media: bool | None = None, reply_markup: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply | Mapping[str, object] | None = None) Message | bool

Use this method to edit captions of messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent.

Parameters:
  • chat_id – Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target bot, supergroup or channel in the format @username.

  • message_id – Required if inline_message_id is not specified. Identifier of the message to edit.

  • inline_message_id – Required if chat_id and message_id are not specified. Identifier of the inline message.

  • caption – New caption of the message, 0-1024 characters after entities parsing

  • parse_mode – Mode for parsing entities in the message caption. See formatting options for more details.

  • caption_entities – A JSON-serialized list of special entities that appear in the caption, which can be specified instead of parse_mode

  • show_caption_above_media – Pass True if the caption must be shown above the message media. Supported only for animation, photo and video messages.

  • reply_markup – A JSON-serialized object for an inline keyboard

Returns:

Result returned by Telegram on successful execution.

Return type:

Union[Message, bool]

async edit_message_checklist(business_connection_id: str, chat_id: int | str, message_id: int, checklist: InputChecklist, *, reply_markup: InlineKeyboardMarkup | None = None) Message

Use this method to edit a checklist on behalf of a connected business account. On success, the edited Message is returned.

Parameters:
  • business_connection_id – Unique identifier of the business connection on behalf of which the message will be sent

  • chat_id – Unique identifier for the target chat or username of the target bot in the format @username

  • message_id – Unique identifier for the target message

  • checklist – A JSON-serialized object for the new checklist

  • reply_markup – A JSON-serialized object for the new inline keyboard for the message

Returns:

Result returned by Telegram on successful execution.

Return type:

Message

async edit_message_live_location(latitude: float, longitude: float, *, chat_id: int | str | None = None, message_id: int | None = None, inline_message_id: str | None = None, live_period: int | None = None, horizontal_accuracy: float | None = None, heading: int | None = None, proximity_alert_radius: int | None = None, reply_markup: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply | Mapping[str, object] | None = None) Message | bool

Use this method to edit live location messages. A location can be edited until its live_period expires or editing is explicitly disabled by a call to stopMessageLiveLocation. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned.

Parameters:
  • latitude – Latitude of new location

  • longitude – Longitude of new location

  • chat_id – Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target bot, supergroup or channel in the format @username.

  • message_id – Required if inline_message_id is not specified. Identifier of the message to edit.

  • inline_message_id – Required if chat_id and message_id are not specified. Identifier of the inline message.

  • live_period – New period in seconds during which the location can be updated, starting from the message send date. If 0x7FFFFFFF is specified, then the location can be updated forever. Otherwise, the new value must not exceed the current live_period by more than a day, and the live location expiration date must remain within the next 90 days. If not specified, then live_period remains unchanged.

  • horizontal_accuracy – The radius of uncertainty for the location, measured in meters; 0-1500

  • heading – Direction in which the user is moving, in degrees. Must be between 1 and 360 if specified.

  • proximity_alert_radius – The maximum distance for proximity alerts about approaching another chat member, in meters. Must be between 1 and 100000 if specified.

  • reply_markup – A JSON-serialized object for a new inline keyboard

Returns:

Result returned by Telegram on successful execution.

Return type:

Union[Message, bool]

async edit_message_media(media: InputMediaPhoto | InputMediaVideo | InputMediaAnimation | InputMediaAudio | InputMediaDocument | InputMediaLivePhoto, *, chat_id: int | str | None = None, message_id: int | None = None, inline_message_id: str | None = None, reply_markup: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply | Mapping[str, object] | None = None) Message | bool

Use this method to edit animation, audio, document, live photo, photo, or video messages, or to replace a text or a rich message with a media. If a message is part of a message album, then it can be edited only to an audio for audio albums, only to a document for document albums and to a photo, a live photo, or a video otherwise. When an inline message is edited, a new file can’t be uploaded; use a previously uploaded file via its file_id or specify a URL. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent.

Parameters:
  • media – A JSON-serialized object for the new media content of the message

  • chat_id – Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target bot, supergroup or channel in the format @username.

  • message_id – Required if inline_message_id is not specified. Identifier of the message to edit.

  • inline_message_id – Required if chat_id and message_id are not specified. Identifier of the inline message.

  • reply_markup – A JSON-serialized object for a new inline keyboard

Returns:

Result returned by Telegram on successful execution.

Return type:

Union[Message, bool]

async edit_message_reply_markup(*, chat_id: int | str | None = None, message_id: int | None = None, inline_message_id: str | None = None, reply_markup: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply | Mapping[str, object] | None = None) Message | bool

Use this method to edit only the reply markup of messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent.

Parameters:
  • chat_id – Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target bot, supergroup or channel in the format @username.

  • message_id – Required if inline_message_id is not specified. Identifier of the message to edit.

  • inline_message_id – Required if chat_id and message_id are not specified. Identifier of the inline message.

  • reply_markup – A JSON-serialized object for an inline keyboard

Returns:

Result returned by Telegram on successful execution.

Return type:

Union[Message, bool]

async edit_message_text(text: str, *, chat_id: int | str | None = None, message_id: int | None = None, inline_message_id: str | None = None, parse_mode: str | None = None, entities: Sequence[MessageEntity | Mapping[str, object]] | None = None, link_preview_options: LinkPreviewOptions | Mapping[str, object] | None = None, reply_markup: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply | Mapping[str, object] | None = None) Message | bool

Use this method to edit text, rich and game messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent.

Parameters:
  • text – New text of the message, 1-4096 characters after entity parsing; required if rich_message isn’t specified

  • chat_id – Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target bot, supergroup or channel in the format @username.

  • message_id – Required if inline_message_id is not specified. Identifier of the message to edit.

  • inline_message_id – Required if chat_id and message_id are not specified. Identifier of the inline message.

  • parse_mode – Mode for parsing entities in the message text. See formatting options for more details.

  • entities – A JSON-serialized list of special entities that appear in message text, which can be specified instead of parse_mode

  • link_preview_options – Link preview generation options for the message

  • reply_markup – A JSON-serialized object for an inline keyboard

Returns:

Result returned by Telegram on successful execution.

Return type:

Union[Message, bool]

async edit_story(business_connection_id: str, story_id: int, content: InputStoryContentPhoto | InputStoryContentVideo, *, caption: str | None = None, parse_mode: str | None = None, caption_entities: List[MessageEntity] | None = None, areas: List[StoryArea] | None = None) Story

Edits a story previously posted by the bot on behalf of a managed business account. Requires the can_manage_stories business bot right. Returns Story on success.

Parameters:
  • business_connection_id – Unique identifier of the business connection

  • story_id – Unique identifier of the story to edit

  • content – Content of the story

  • caption – Caption of the story, 0-2048 characters after entities parsing

  • parse_mode – Mode for parsing entities in the story caption. See formatting options for more details.

  • caption_entities – A JSON-serialized list of special entities that appear in the caption, which can be specified instead of parse_mode

  • areas – A JSON-serialized list of clickable areas to be shown on the story

async edit_user_star_subscription(user_id: int, telegram_payment_charge_id: str, is_canceled: bool) bool

Allows the bot to cancel or re-enable extension of a subscription paid in Telegram Stars. Returns True on success.

Parameters:
  • user_id – Identifier of the user whose subscription will be edited

  • telegram_payment_charge_id – Telegram payment identifier for the subscription

  • is_canceled – Pass True to cancel extension of the user subscription; the subscription must be active up to the end of the current subscription period. Pass False to allow the user to re-enable a subscription that was previously canceled by the bot.

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

Use this method to generate a new primary invite link for a chat; any previously generated primary link is revoked. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the new invite link as String on success. Note: Each administrator in a chat generates their own invite links. Bots can’t use invite links generated by other administrators. If you want your bot to work with invite links, it will need to generate its own link using exportChatInviteLink or by calling the getChat method. If your bot needs to generate a new primary invite link replacing its previous one, use exportChatInviteLink again.

Parameters:

chat_id – Unique identifier for the target chat or username of the target channel in the format @username

Returns:

Result returned by Telegram on successful execution.

Return type:

str

file_model

alias of File

async forward_message(chat_id: int | str, from_chat_id: int | str, message_id: int, *, message_thread_id: int | None = None, disable_notification: bool | None = None, protect_content: bool | None = None) Message

Use this method to forward messages of any kind. Service messages and messages with protected content can’t be forwarded. On success, the sent Message is returned.

Parameters:
  • chat_id – Unique identifier for the target chat or username of the target bot, supergroup or channel in the format @username

  • from_chat_id – Unique identifier for the chat where the original message was sent (or username of the target bot, supergroup or channel in the format @username)

  • message_id – Message identifier in the chat specified in from_chat_id

  • message_thread_id – Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only

  • disable_notification – Sends the message silently. Users will receive a notification with no sound.

  • protect_content – Protects the contents of the forwarded message from forwarding and saving

Returns:

Result returned by Telegram on successful execution.

Return type:

Message

async forward_messages(chat_id: int | str, from_chat_id: int | str, message_ids: Sequence[int], *, message_thread_id: int | None = None, disable_notification: bool | None = None, protect_content: bool | None = None) List[MessageId]

Use this method to forward multiple messages of any kind. If some of the specified messages can’t be found or forwarded, they are skipped. Service messages and messages with protected content can’t be forwarded. Album grouping is kept for forwarded messages. On success, an Array of MessageId of the sent messages is returned.

Parameters:
  • chat_id – Unique identifier for the target chat or username of the target bot, supergroup or channel in the format @username

  • from_chat_id – Unique identifier for the chat where the original messages were sent (or username of the target bot, supergroup or channel in the format @username)

  • message_ids – A JSON-serialized list of 1-100 identifiers of messages in the chat from_chat_id to forward. The identifiers must be specified in a strictly increasing order.

  • message_thread_id – Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only

  • disable_notification – Sends the messages silently. Users will receive a notification with no sound.

  • protect_content – Protects the contents of the forwarded messages from forwarding and saving

Returns:

Result returned by Telegram on successful execution.

Return type:

List[MessageId]

async get_available_gifts() object

Returns the list of gifts that can be sent by the bot to users and channel chats. Requires no parameters. Returns a Gifts object.

async get_business_account_gifts(business_connection_id: str, *, exclude_unsaved: bool | None = None, exclude_saved: bool | None = None, exclude_unlimited: bool | None = None, exclude_limited_upgradable: bool | None = None, exclude_limited_non_upgradable: bool | None = None, exclude_unique: bool | None = None, exclude_from_blockchain: bool | None = None, sort_by_price: bool | None = None, offset: str | None = None, limit: int | None = None) OwnedGifts

Returns the gifts received and owned by a managed business account. Requires the can_view_gifts_and_stars business bot right. Returns OwnedGifts on success.

Parameters:
  • business_connection_id – Unique identifier of the business connection

  • exclude_unsaved – Pass True to exclude gifts that aren’t saved to the account’s profile page

  • exclude_saved – Pass True to exclude gifts that are saved to the account’s profile page

  • exclude_unlimited – Pass True to exclude gifts that can be purchased an unlimited number of times

  • exclude_limited_upgradable – Pass True to exclude gifts that can be purchased a limited number of times and can be upgraded to unique

  • exclude_limited_non_upgradable – Pass True to exclude gifts that can be purchased a limited number of times and can’t be upgraded to unique

  • exclude_unique – Pass True to exclude unique gifts

  • exclude_from_blockchain – Pass True to exclude gifts that were assigned from the TON blockchain and can’t be resold or transferred in Telegram

  • sort_by_price – Pass True to sort results by gift price instead of send date. Sorting is applied before pagination.

  • offset – Offset of the first entry to return as received from the previous request; use empty string to get the first chunk of results

  • limit – The maximum number of gifts to be returned; 1-100. Defaults to 100.

async get_business_account_star_balance(business_connection_id: str) StarAmount

Returns the amount of Telegram Stars owned by a managed business account. Requires the can_view_gifts_and_stars business bot right. Returns StarAmount on success.

Parameters:

business_connection_id – Unique identifier of the business connection

async get_business_connection(business_connection_id: str) BusinessConnection

Use this method to get information about the connection of the bot with a business account. Returns a BusinessConnection object on success.

Parameters:

business_connection_id – Unique identifier of the business connection

Returns:

Result returned by Telegram on successful execution.

Return type:

BusinessConnection

async get_chat_administrators(chat_id: int | str, *, return_bots: bool | None = None) List[ChatMemberOwner | ChatMemberAdministrator | ChatMemberMember | ChatMemberRestricted | ChatMemberLeft | ChatMemberBanned]

Use this method to get a list of administrators in a chat. Returns an Array of ChatMember objects.

Parameters:
  • chat_id – Unique identifier for the target chat or username of the target supergroup or channel in the format @username

  • return_bots – Pass True to additionally receive all bots that are administrators of the chat. By default, bots other than the current bot are omitted.

Returns:

Result returned by Telegram on successful execution.

Return type:

List[ChatMember]

async get_chat_gifts(chat_id: int | str, *, exclude_unsaved: bool | None = None, exclude_saved: bool | None = None, exclude_unlimited: bool | None = None, exclude_limited_upgradable: bool | None = None, exclude_limited_non_upgradable: bool | None = None, exclude_from_blockchain: bool | None = None, exclude_unique: bool | None = None, sort_by_price: bool | None = None, offset: str | None = None, limit: int | None = None) OwnedGifts

Returns the gifts owned by a chat. Returns OwnedGifts on success.

Parameters:
  • chat_id – Unique identifier for the target chat or username of the target channel in the format @username

  • exclude_unsaved – Pass True to exclude gifts that aren’t saved to the chat’s profile page. Always True, unless the bot has the can_post_messages administrator right in the channel.

  • exclude_saved – Pass True to exclude gifts that are saved to the chat’s profile page. Always False, unless the bot has the can_post_messages administrator right in the channel.

  • exclude_unlimited – Pass True to exclude gifts that can be purchased an unlimited number of times

  • exclude_limited_upgradable – Pass True to exclude gifts that can be purchased a limited number of times and can be upgraded to unique

  • exclude_limited_non_upgradable – Pass True to exclude gifts that can be purchased a limited number of times and can’t be upgraded to unique

  • exclude_from_blockchain – Pass True to exclude gifts that were assigned from the TON blockchain and can’t be resold or transferred in Telegram

  • exclude_unique – Pass True to exclude unique gifts

  • sort_by_price – Pass True to sort results by gift price instead of send date. Sorting is applied before pagination.

  • offset – Offset of the first entry to return as received from the previous request; use an empty string to get the first chunk of results

  • limit – The maximum number of gifts to be returned; 1-100. Defaults to 100.

async get_chat_member_count(chat_id: int | str) int

Use this method to get the number of members in a chat. Returns Integer on success.

Parameters:

chat_id – Unique identifier for the target chat or username of the target supergroup or channel in the format @username

Returns:

Result returned by Telegram on successful execution.

Return type:

int

async get_chat_menu_button(*, chat_id: int | str | None = None) MenuButtonCommands | MenuButtonWebApp | MenuButtonDefault

Use this method to get the current value of the bot’s menu button in a private chat, or the default menu button. Returns MenuButton on success.

Parameters:

chat_id – Unique identifier for the target private chat. If not specified, the bot’s default menu button will be returned.

async get_custom_emoji_stickers(custom_emoji_ids: Sequence[str]) List[Sticker]

Use this method to get information about custom emoji stickers by their identifiers. Returns an Array of Sticker objects.

Parameters:

custom_emoji_ids – A JSON-serialized list of custom emoji identifiers. At most 200 custom emoji identifiers can be specified.

Returns:

Result returned by Telegram on successful execution.

Return type:

List[Sticker]

async get_forum_topic_icon_stickers() List[Sticker]

Use this method to get custom emoji stickers, which can be used as a forum topic icon by any user. Requires no parameters. Returns an Array of Sticker objects.

Returns:

Result returned by Telegram on successful execution.

Return type:

List[Sticker]

async get_game_high_scores(user_id: int, *, chat_id: int | None = None, message_id: int | None = None, inline_message_id: str | None = None) List[GameHighScore]

Use this method to get data for high score tables. Will return the score of the specified user and several of their neighbors in a game. Returns an Array of GameHighScore objects. This method will currently return scores for the target user, plus two of their closest neighbors on each side. Will also return the top three users if the user and their neighbors are not among them. Please note that this behavior is subject to change.

Parameters:
  • user_id – Target user id

  • chat_id – Required if inline_message_id is not specified. Unique identifier for the target chat.

  • message_id – Required if inline_message_id is not specified. Identifier of the sent message.

  • inline_message_id – Required if chat_id and message_id are not specified. Identifier of the inline message.

Returns:

Result returned by Telegram on successful execution.

Return type:

List[GameHighScore]

async get_managed_bot_access_settings(user_id: int | None = None, *, chat_id: int | None = None) BotAccessSettings

Use this method to get the access settings of a managed bot. Returns a BotAccessSettings object on success.

Parameters:
  • user_id – User identifier of the managed bot whose access settings will be returned

  • chat_id – Value accepted by this operation.

Returns:

Result returned by Telegram on successful execution.

Return type:

BotAccessSettings

async get_managed_bot_token(user_id: int) str

Use this method to get the token of a managed bot. Returns the token as String on success.

Parameters:

user_id – User identifier of the managed bot whose token will be returned

Returns:

Result returned by Telegram on successful execution.

Return type:

str

async get_my_commands(*, scope: BotCommandScopeDefault | BotCommandScopeAllPrivateChats | BotCommandScopeAllGroupChats | BotCommandScopeAllChatAdministrators | BotCommandScopeChat | BotCommandScopeChatAdministrators | BotCommandScopeChatMember | Mapping[str, object] | None = None, language_code: str | None = None) List[BotCommand]

Use this method to get the current list of the bot’s commands for the given scope and user language. Returns an Array of BotCommand objects. If commands aren’t set, an empty list is returned.

Parameters:
  • scope – A JSON-serialized object, describing scope of users. Defaults to BotCommandScopeDefault.

  • language_code – A two-letter ISO 639-1 language code or an empty string

Returns:

Result returned by Telegram on successful execution.

Return type:

List[BotCommand]

async get_my_default_administrator_rights(*, for_channels: bool | None = None) ChatAdministratorRights

Use this method to get the current default administrator rights of the bot. Returns ChatAdministratorRights on success.

Parameters:

for_channels – Pass True to get default administrator rights of the bot in channels. Otherwise, default administrator rights of the bot for groups and supergroups will be returned.

async get_my_description(*, language_code: str | None = None) BotDescription

Use this method to get the current bot description for the given user language. Returns BotDescription on success.

Parameters:

language_code – A two-letter ISO 639-1 language code or an empty string

async get_my_name(*, language_code: str | None = None) BotName

Use this method to get the current bot name for the given user language. Returns BotName on success.

Parameters:

language_code – A two-letter ISO 639-1 language code or an empty string

async get_my_short_description(*, language_code: str | None = None) BotShortDescription

Use this method to get the current bot short description for the given user language. Returns BotShortDescription on success.

Parameters:

language_code – A two-letter ISO 639-1 language code or an empty string

async get_my_star_balance() object

A method to get the current Telegram Stars balance of the bot. Requires no parameters. On success, returns a StarAmount object.

async get_star_transactions(*, offset: int | None = None, limit: int | None = None) object

Returns the bot’s Telegram Star transactions in chronological order. On success, returns a StarTransactions object.

Parameters:
  • offset – Number of transactions to skip in the response

  • limit – The maximum number of transactions to be retrieved. Values between 1-100 are accepted. Defaults to 100.

async get_sticker_set(name: str) StickerSet

Use this method to get a sticker set. On success, a StickerSet object is returned.

Parameters:

name – Name of the sticker set

Returns:

Result returned by Telegram on successful execution.

Return type:

StickerSet

async get_updates(*, offset: int | None = None, limit: int | None = None, timeout: int | None = None, allowed_updates: List[str] | None = None) List[Update]

Use this method to receive incoming updates using long polling (wiki). Returns an Array of Update objects. Notes 1. This method will not work if an outgoing webhook is set up. 2. In order to avoid getting duplicate updates, recalculate offset after each server response.

Parameters:
  • offset – Identifier of the first update to be returned. Must be greater by one than the highest among the identifiers of previously received updates. By default, updates starting with the earliest unconfirmed update are returned. An update is considered confirmed as soon as getUpdates is called with an offset higher than its update_id. The negative offset can be specified to retrieve updates starting from -offset update from the end of the updates queue. All previous updates will be forgotten.

  • limit – Limits the number of updates to be retrieved. Values between 1-100 are accepted. Defaults to 100.

  • timeout – Timeout in seconds for long polling. Defaults to 0, i.e. usual short polling. Should be positive, short polling should be used for testing purposes only.

  • allowed_updates – A JSON-serialized list of the update types you want your bot to receive. For example, specify [“message”, “edited_channel_post”, “callback_query”] to only receive updates of these types. See Update for a complete list of available update types. Specify an empty list to receive all update types except chat_member, message_reaction, and message_reaction_count (default). If not specified, the previous setting will be used.

Please note that this parameter doesn’t affect updates created before the call to getUpdates, so unwanted updates may be received for a short period of time.

Returns:

Result returned by Telegram on successful execution.

Return type:

List[Update]

async get_user_chat_boosts(chat_id: int | str, user_id: int) object

Use this method to get the list of boosts added to a chat by a user. Requires administrator rights in the chat. Returns a UserChatBoosts object.

Parameters:
  • chat_id – Unique identifier for the chat or username of the channel in the format @username

  • user_id – Unique identifier of the target user

async get_user_gifts(user_id: int, *, exclude_unlimited: bool | None = None, exclude_limited_upgradable: bool | None = None, exclude_limited_non_upgradable: bool | None = None, exclude_from_blockchain: bool | None = None, exclude_unique: bool | None = None, sort_by_price: bool | None = None, offset: str | None = None, limit: int | None = None) OwnedGifts

Returns the gifts owned and hosted by a user. Returns OwnedGifts on success.

Parameters:
  • user_id – Unique identifier of the user

  • exclude_unlimited – Pass True to exclude gifts that can be purchased an unlimited number of times

  • exclude_limited_upgradable – Pass True to exclude gifts that can be purchased a limited number of times and can be upgraded to unique

  • exclude_limited_non_upgradable – Pass True to exclude gifts that can be purchased a limited number of times and can’t be upgraded to unique

  • exclude_from_blockchain – Pass True to exclude gifts that were assigned from the TON blockchain and can’t be resold or transferred in Telegram

  • exclude_unique – Pass True to exclude unique gifts

  • sort_by_price – Pass True to sort results by gift price instead of send date. Sorting is applied before pagination.

  • offset – Offset of the first entry to return as received from the previous request; use an empty string to get the first chunk of results

  • limit – The maximum number of gifts to be returned; 1-100. Defaults to 100.

async get_user_personal_chat_messages(user_id: int, limit: int | None = None) List[Message]

Use this method to get the last messages from the personal chat (i.e., the chat currently added to their profile) of a given user. On success, an Array of Message objects is returned.

Parameters:
  • user_id – Unique identifier for the target user

  • limit – The maximum number of messages to return; 1-20

Returns:

Result returned by Telegram on successful execution.

Return type:

List[Message]

async get_user_profile_audios(user_id: int, *, offset: int | None = None, limit: int | None = None) object

Use this method to get a list of profile audios for a user. Returns a UserProfileAudios object.

Parameters:
  • user_id – Unique identifier of the target user

  • offset – Sequential number of the first audio to be returned. By default, all audios are returned.

  • limit – Limits the number of audios to be retrieved. Values between 1-100 are accepted. Defaults to 100.

async get_user_profile_photos(user_id: int, *, offset: int | None = None, limit: int | None = None) object

Use this method to get a list of profile pictures for a user. Returns a UserProfilePhotos object.

Parameters:
  • user_id – Unique identifier of the target user

  • offset – Sequential number of the first photo to be returned. By default, all photos are returned.

  • limit – Limits the number of photos to be retrieved. Values between 1-100 are accepted. Defaults to 100.

async gift_premium_subscription(user_id: int, month_count: int, star_count: int | None = None, *, text: str | None = None, text_parse_mode: str | None = None, text_entities: List[MessageEntity] | None = None) bool

Gifts a Telegram Premium subscription to the given user. Returns True on success.

Parameters:
  • user_id – Unique identifier of the target user who will receive a Telegram Premium subscription

  • month_count – Number of months the Telegram Premium subscription will be active for the user; must be one of 3, 6, or 12

  • star_count – Number of Telegram Stars to pay for the Telegram Premium subscription; must be 1000 for 3 months, 1500 for 6 months, and 2500 for 12 months

  • text – Text that will be shown along with the service message about the subscription; 0-128 characters

  • text_parse_mode – Mode for parsing entities in the text. See formatting options for more details. Entities other than ‘bold’, ‘italic’, ‘underline’, ‘strikethrough’, ‘spoiler’, ‘custom_emoji’, and ‘date_time’ are ignored.

  • text_entities – A JSON-serialized list of special entities that appear in the gift text. It can be specified instead of text_parse_mode. Entities other than ‘bold’, ‘italic’, ‘underline’, ‘strikethrough’, ‘spoiler’, ‘custom_emoji’, and ‘date_time’ are ignored.

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async hide_general_forum_topic(chat_id: int | str) bool

Use this method to hide the ‘General’ topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. The topic will be automatically closed if it was open. Returns True on success.

Parameters:

chat_id – Unique identifier for the target chat or username of the target supergroup in the format @username

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async log_out() bool

Use this method to log out from the cloud Bot API server before launching the bot locally. You must log out the bot before running it locally, otherwise there is no guarantee that the bot will receive updates. After a successful call, you can immediately log in on a local server, but will not be able to log in back to the cloud Bot API server for 10 minutes. Returns True on success. Requires no parameters.

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async pin_chat_message(chat_id: int | str, message_id: int, *, disable_notification: bool | None = None) bool

Use this method to add a message to the list of pinned messages in a chat. In private chats and channel direct messages chats, all non-service messages can be pinned. Conversely, the bot must be an administrator with the ‘can_pin_messages’ right or the ‘can_edit_messages’ right to pin messages in groups and channels respectively. Returns True on success.

Parameters:
  • chat_id – Unique identifier for the target chat or username of the target channel in the format @username

  • message_id – Identifier of a message to pin

  • disable_notification – Pass True if it is not necessary to send a notification to all chat members about the new pinned message. Notifications are always disabled in channels and private chats.

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async post_story(business_connection_id: str, content: InputStoryContentPhoto | InputStoryContentVideo, active_period: int, *, caption: str | None = None, parse_mode: str | None = None, caption_entities: List[MessageEntity] | None = None, areas: List[StoryArea] | None = None, post_to_chat_page: bool | None = None, protect_content: bool | None = None) Story

Posts a story on behalf of a managed business account. Requires the can_manage_stories business bot right. Returns Story on success.

Parameters:
  • business_connection_id – Unique identifier of the business connection

  • content – Content of the story

  • active_period – Period after which the story is moved to the archive, in seconds; must be one of 6 3600, 12 3600, 86400, or 2 * 86400

  • caption – Caption of the story, 0-2048 characters after entities parsing

  • parse_mode – Mode for parsing entities in the story caption. See formatting options for more details.

  • caption_entities – A JSON-serialized list of special entities that appear in the caption, which can be specified instead of parse_mode

  • areas – A JSON-serialized list of clickable areas to be shown on the story

  • post_to_chat_page – Pass True to keep the story accessible after it expires

  • protect_content – Pass True if the content of the story must be protected from forwarding and screenshotting

async promote_chat_member(chat_id: int | str, user_id: int, *, is_anonymous: bool | None = None, can_manage_chat: bool | None = None, can_delete_messages: bool | None = None, can_manage_video_chats: bool | None = None, can_restrict_members: bool | None = None, can_promote_members: bool | None = None, can_change_info: bool | None = None, can_invite_users: bool | None = None, can_post_stories: bool | None = None, can_edit_stories: bool | None = None, can_delete_stories: bool | None = None, can_post_messages: bool | None = None, can_edit_messages: bool | None = None, can_pin_messages: bool | None = None, can_manage_topics: bool | None = None, can_manage_direct_messages: bool | None = None, can_manage_tags: bool | None = None, can_send_welcome_messages: bool | None = None) bool

Use this method to promote or demote a user in a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Pass False for all boolean parameters to demote a user. Returns True on success.

Parameters:
  • chat_id – Unique identifier for the target chat or username of the target channel in the format @username

  • user_id – Unique identifier of the target user

  • is_anonymous – Pass True if the administrator’s presence in the chat is hidden

  • can_manage_chat – Pass True if the administrator can access the chat event log, get boost list, see hidden supergroup and channel members, report spam messages, ignore slow mode, and send messages to the chat without paying Telegram Stars. Implied by any other administrator privilege.

  • can_delete_messages – Pass True if the administrator can delete messages of other users

  • can_manage_video_chats – Pass True if the administrator can manage video chats

  • can_restrict_members – Pass True if the administrator can restrict, ban or unban chat members, or access supergroup statistics. For backward compatibility, defaults to True for promotions of channel administrators.

  • can_promote_members – Pass True if the administrator can add new administrators with a subset of their own privileges or demote administrators that they have promoted, directly or indirectly (promoted by administrators that were appointed by him)

  • can_change_info – Pass True if the administrator can change chat title, photo and other settings

  • can_invite_users – Pass True if the administrator can invite new users to the chat

  • can_post_stories – Pass True if the administrator can post stories to the chat

  • can_edit_stories – Pass True if the administrator can edit stories posted by other users, post stories to the chat page, pin chat stories, and access the chat’s story archive

  • can_delete_stories – Pass True if the administrator can delete stories posted by other users

  • can_post_messages – Pass True if the administrator can post messages in the channel, approve suggested posts, or access channel statistics; for channels only

  • can_edit_messages – Pass True if the administrator can edit messages of other users and can pin messages; for channels only

  • can_pin_messages – Pass True if the administrator can pin messages; for supergroups only

  • can_manage_topics – Pass True if the user is allowed to create, rename, close, and reopen forum topics; for supergroups only

  • can_manage_direct_messages – Pass True if the administrator can manage direct messages within the channel and decline suggested posts; for channels only

  • can_manage_tags – Pass True if the administrator can edit the tags of regular members; for groups and supergroups only

  • can_send_welcome_messages – Value accepted by this operation.

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async read_business_message(business_connection_id: str, chat_id: int, message_id: int) bool

Marks incoming message as read on behalf of a business account. Requires the can_read_messages business bot right. Returns True on success.

Parameters:
  • business_connection_id – Unique identifier of the business connection on behalf of which to read the message

  • chat_id – Unique identifier of the chat in which the message was received. The chat must have been active in the last 24 hours.

  • message_id – Unique identifier of the message to mark as read

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async refund_star_payment(user_id: int, telegram_payment_charge_id: str) bool

Refunds a successful payment in Telegram Stars. Returns True on success.

Parameters:
  • user_id – Identifier of the user whose payment will be refunded

  • telegram_payment_charge_id – Telegram payment identifier

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async remove_business_account_profile_photo(business_connection_id: str, *, is_public: bool | None = None) bool

Removes the current profile photo of a managed business account. Requires the can_edit_profile_photo business bot right. Returns True on success.

Parameters:
  • business_connection_id – Unique identifier of the business connection

  • is_public – Pass True to remove the public photo, which is visible even if the main photo is hidden by the business account’s privacy settings. After the main photo is removed, the previous profile photo (if present) becomes the main photo.

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async remove_chat_verification(chat_id: int | str) bool

Removes verification from a chat that is currently verified on behalf of the organization represented by the bot. Returns True on success.

Parameters:

chat_id – Unique identifier for the target chat or username of the target bot or channel in the format @username

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async remove_my_profile_photo() bool

Removes the profile photo of the bot. Requires no parameters. Returns True on success.

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async remove_user_verification(user_id: int) bool

Removes verification from a user who is currently verified on behalf of the organization represented by the bot. Returns True on success.

Parameters:

user_id – Unique identifier of the target user

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async reopen_forum_topic(chat_id: int | str, message_thread_id: int) bool

Use this method to reopen a closed topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic. Returns True on success.

Parameters:
  • chat_id – Unique identifier for the target chat or username of the target supergroup in the format @username

  • message_thread_id – Unique identifier for the target message thread of the forum topic

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async reopen_general_forum_topic(chat_id: int | str) bool

Use this method to reopen a closed ‘General’ topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. The topic will be automatically unhidden if it was hidden. Returns True on success.

Parameters:

chat_id – Unique identifier for the target chat or username of the target supergroup in the format @username

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async replace_managed_bot_token(user_id: int) str

Use this method to revoke the current token of a managed bot and generate a new one. Returns the new token as String on success.

Parameters:

user_id – User identifier of the managed bot whose token will be replaced

Returns:

Result returned by Telegram on successful execution.

Return type:

str

async replace_sticker_in_set(user_id: int, name: str, old_sticker: str, sticker: InputSticker) bool

Use this method to replace an existing sticker in a sticker set with a new one. The method is equivalent to calling deleteStickerFromSet, then addStickerToSet, then setStickerPositionInSet. Returns True on success.

Parameters:
  • user_id – User identifier of the sticker set owner

  • name – Sticker set name

  • old_sticker – File identifier of the replaced sticker

  • sticker – A JSON-serialized object with information about the added sticker. If exactly the same sticker had already been added to the set, then the set remains unchanged.

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async repost_story(business_connection_id: str, from_chat_id: int, from_story_id: int, active_period: int, *, post_to_chat_page: bool | None = None, protect_content: bool | None = None) Story

Reposts a story on behalf of a business account from another business account. Both business accounts must be managed by the same bot, and the story on the source account must have been posted (or reposted) by the bot. Requires the can_manage_stories business bot right for both business accounts. Returns Story on success.

Parameters:
  • business_connection_id – Unique identifier of the business connection

  • from_chat_id – Unique identifier of the chat which posted the story that should be reposted

  • from_story_id – Unique identifier of the story that should be reposted

  • active_period – Period after which the story is moved to the archive, in seconds; must be one of 6 3600, 12 3600, 86400, or 2 * 86400

  • post_to_chat_page – Pass True to keep the story accessible after it expires

  • protect_content – Pass True if the content of the story must be protected from forwarding and screenshotting

async restrict_chat_member(chat_id: int | str, user_id: int, permissions: ChatPermissions | Mapping[str, object], *, use_independent_chat_permissions: bool | None = None, until_date: int | None = None) bool

Use this method to restrict a user in a supergroup. The bot must be an administrator in the supergroup for this to work and must have the appropriate administrator rights. Pass True for all permissions to lift restrictions from a user. Returns True on success.

Parameters:
  • chat_id – Unique identifier for the target chat or username of the target supergroup in the format @username

  • user_id – Unique identifier of the target user

  • permissions – A JSON-serialized object for new user permissions

  • use_independent_chat_permissions – Pass True if chat permissions are set independently. Otherwise, the can_send_other_messages and can_add_web_page_previews permissions will imply the can_send_messages, can_send_audios, can_send_documents, can_send_photos, can_send_videos, can_send_video_notes, and can_send_voice_notes permissions; the can_send_polls permission will imply the can_send_messages permission.

  • until_date – Date when restrictions will be lifted for the user; Unix time. If user is restricted for more than 366 days or less than 30 seconds from the current time, they are considered to be restricted forever.

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

Use this method to revoke an invite link created by the bot. If the primary link is revoked, a new link is automatically generated. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the revoked invite link as ChatInviteLink object.

Parameters:
  • chat_id – Unique identifier of the target chat or username of the target channel in the format @username

  • invite_link – The invite link to revoke

async save_prepared_inline_message(user_id: int, result: InlineQueryResultArticle | InlineQueryResultPhoto | InlineQueryResultGif | InlineQueryResultMpeg4Gif | InlineQueryResultVideo | InlineQueryResultAudio | InlineQueryResultVoice | InlineQueryResultDocument | InlineQueryResultLocation | InlineQueryResultVenue | InlineQueryResultContact | InlineQueryResultGame | InlineQueryResultCachedPhoto | InlineQueryResultCachedGif | InlineQueryResultCachedMpeg4Gif | InlineQueryResultCachedSticker | InlineQueryResultCachedDocument | InlineQueryResultCachedVideo | InlineQueryResultCachedVoice | InlineQueryResultCachedAudio | Mapping[str, object], *, allow_user_chats: bool | None = None, allow_bot_chats: bool | None = None, allow_group_chats: bool | None = None, allow_channel_chats: bool | None = None) PreparedInlineMessage

Stores a message that can be sent by a user of a Mini App. Returns a PreparedInlineMessage object.

Parameters:
  • user_id – Unique identifier of the target user that can use the prepared message

  • result – A JSON-serialized object describing the message to be sent

  • allow_user_chats – Pass True if the message can be sent to private chats with users

  • allow_bot_chats – Pass True if the message can be sent to private chats with bots

  • allow_group_chats – Pass True if the message can be sent to group and supergroup chats

  • allow_channel_chats – Pass True if the message can be sent to channel chats

async save_prepared_keyboard_button(user_id: int, button: KeyboardButton) object

Stores a keyboard button that can be used by a user within a Mini App. Returns a PreparedKeyboardButton object.

Parameters:
  • user_id – Unique identifier of the target user that can use the button

  • button – A JSON-serialized object describing the button to be saved. The button must be of the type request_users, request_chat, or request_managed_bot.

async send_animation(chat_id: int | str, animation: str | bytes | FilePayload, *, caption: str | None = None, parse_mode: str | None = None, caption_entities: Sequence[MessageEntity | Mapping[str, object]] | None = None, show_caption_above_media: bool | None = None, has_spoiler: bool | None = None, duration: int | None = None, width: int | None = None, height: int | None = None, thumbnail: str | bytes | FilePayload | None = None, message_thread_id: int | None = None, disable_notification: bool | None = None, protect_content: bool | None = None, reply_parameters: ReplyParameters | Mapping[str, object] | None = None, reply_markup: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply | Mapping[str, object] | None = None) Message

Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without sound). On success, the sent Message is returned. Bots can currently send animation files of up to 50 MB in size, this limit may be changed in the future.

Parameters:
  • chat_id – Unique identifier for the target chat or username of the target bot, supergroup or channel in the format @username

  • animation – Animation to send. Pass a file_id as String to send an animation that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get an animation from the Internet, or upload a new animation using multipart/form-data. More information on Sending Files

  • caption – Animation caption (may also be used when resending animation by file_id), 0-1024 characters after entities parsing

  • parse_mode – Mode for parsing entities in the animation caption. See formatting options for more details.

  • caption_entities – A JSON-serialized list of special entities that appear in the caption, which can be specified instead of parse_mode

  • show_caption_above_media – Pass True if the caption must be shown above the message media

  • has_spoiler – Pass True if the animation needs to be covered with a spoiler animation

  • duration – Duration of sent animation in seconds

  • width – Animation width

  • height – Animation height

  • thumbnail – Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail’s width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass ‘attach://’ if the thumbnail was uploaded using multipart/form-data under . More information on Sending Files

  • message_thread_id – Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only

  • disable_notification – Sends the message silently. Users will receive a notification with no sound.

  • protect_content – Protects the contents of the sent message from forwarding and saving

  • reply_parameters – Description of the message to reply to

  • reply_markup – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove a reply keyboard or to force a reply from the user.

Returns:

Result returned by Telegram on successful execution.

Return type:

Message

async send_audio(chat_id: int | str, audio: str | bytes | FilePayload, *, caption: str | None = None, parse_mode: str | None = None, caption_entities: Sequence[MessageEntity | Mapping[str, object]] | None = None, duration: int | None = None, performer: str | None = None, title: str | None = None, thumbnail: str | bytes | FilePayload | None = None, message_thread_id: int | None = None, disable_notification: bool | None = None, protect_content: bool | None = None, reply_parameters: ReplyParameters | Mapping[str, object] | None = None, reply_markup: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply | Mapping[str, object] | None = None) Message

Use this method to send audio files, if you want Telegram clients to display them in the music player. Your audio must be in the .MP3 or .M4A format. On success, the sent Message is returned. Bots can currently send audio files of up to 50 MB in size, this limit may be changed in the future. For sending voice messages, use the sendVoice method instead.

Parameters:
  • chat_id – Unique identifier for the target chat or username of the target bot, supergroup or channel in the format @username

  • audio – Audio file to send. Pass a file_id as String to send an audio file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get an audio file from the Internet, or upload a new one using multipart/form-data. More information on Sending Files

  • caption – Audio caption, 0-1024 characters after entities parsing

  • parse_mode – Mode for parsing entities in the audio caption. See formatting options for more details.

  • caption_entities – A JSON-serialized list of special entities that appear in the caption, which can be specified instead of parse_mode

  • duration – Duration of the audio in seconds

  • performer – Performer

  • title – Track name

  • thumbnail – Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail’s width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass ‘attach://’ if the thumbnail was uploaded using multipart/form-data under . More information on Sending Files

  • message_thread_id – Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only

  • disable_notification – Sends the message silently. Users will receive a notification with no sound.

  • protect_content – Protects the contents of the sent message from forwarding and saving

  • reply_parameters – Description of the message to reply to

  • reply_markup – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove a reply keyboard or to force a reply from the user.

Returns:

Result returned by Telegram on successful execution.

Return type:

Message

async send_chat_action(chat_id: int | str, action: str, *, business_connection_id: str | None = None, message_thread_id: int | None = None) bool

Use this method when you need to tell the user that something is happening on the bot’s side. The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status). Returns True on success. Example: The ImageBot needs some time to process a request and upload the image. Instead of sending a text message along the lines of ‘Retrieving image, please wait…’, the bot may use sendChatAction with action = upload_photo. The user will see a ‘sending photo’ status for the bot. We only recommend using this method when a response from the bot will take a noticeable amount of time to arrive.

Parameters:
  • chat_id – Unique identifier for the target chat or username of the target bot or supergroup in the format @username. Channel chats and channel direct messages chats aren’t supported.

  • action – Type of action to broadcast. Choose one, depending on what the user is about to receive: typing for text messages, upload_photo for photos, record_video or upload_video for videos, record_voice or upload_voice for voice notes, upload_document for general files, choose_sticker for stickers, find_location for location data, record_video_note or upload_video_note for video notes.

  • business_connection_id – Unique identifier of the business connection on behalf of which the action will be sent

  • message_thread_id – Unique identifier for the target message thread or topic of a forum; for supergroups and private chats of bots with forum topic mode enabled only

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async send_chat_join_request_web_app(chat_join_request_query_id: str | None = None, web_app_url: str | None = None, *, chat_id: int | None = None, user_id: int | None = None, query_id: str | None = None) bool

Use this method to process a received chat join request query by showing a Mini App to the user before deciding the outcome. Call answerChatJoinRequestQuery to resolve the join request query based on the user interaction with the Mini App. Returns True on success.

Parameters:
  • chat_join_request_query_id – Unique identifier of the join request query

  • web_app_url – An HTTPS URL of a Web App to be opened with additional data as specified in Initializing Web Apps

  • chat_id – Value accepted by this operation.

  • user_id – Value accepted by this operation.

  • query_id – Value accepted by this operation.

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async send_checklist(business_connection_id: str, chat_id: int | str, checklist: InputChecklist, *, disable_notification: bool | None = None, protect_content: bool | None = None, message_effect_id: str | None = None, reply_parameters: ReplyParameters | None = None, reply_markup: InlineKeyboardMarkup | None = None) Message

Use this method to send a checklist on behalf of a connected business account. On success, the sent Message is returned.

Parameters:
  • business_connection_id – Unique identifier of the business connection on behalf of which the message will be sent

  • chat_id – Unique identifier for the target chat or username of the target bot in the format @username

  • checklist – A JSON-serialized object for the checklist to send

  • disable_notification – Sends the message silently. Users will receive a notification with no sound.

  • protect_content – Protects the contents of the sent message from forwarding and saving

  • message_effect_id – Unique identifier of the message effect to be added to the message

  • reply_parameters – A JSON-serialized object for description of the message to reply to

  • reply_markup – A JSON-serialized object for an inline keyboard

Returns:

Result returned by Telegram on successful execution.

Return type:

Message

async send_contact(chat_id: int | str, phone_number: str, first_name: str, *, message_thread_id: int | None = None, last_name: str | None = None, vcard: str | None = None, disable_notification: bool | None = None, protect_content: bool | None = None, reply_parameters: ReplyParameters | Mapping[str, object] | None = None, reply_markup: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply | Mapping[str, object] | None = None) Message

Use this method to send phone contacts. On success, the sent Message is returned.

Parameters:
  • chat_id – Unique identifier for the target chat or username of the target bot, supergroup or channel in the format @username

  • phone_number – Contact’s phone number

  • first_name – Contact’s first name

  • message_thread_id – Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only

  • last_name – Contact’s last name

  • vcard – Additional data about the contact in the form of a vCard, 0-2048 bytes

  • disable_notification – Sends the message silently. Users will receive a notification with no sound.

  • protect_content – Protects the contents of the sent message from forwarding and saving

  • reply_parameters – Description of the message to reply to

  • reply_markup – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove a reply keyboard or to force a reply from the user.

Returns:

Result returned by Telegram on successful execution.

Return type:

Message

async send_dice(chat_id: int | str, *, message_thread_id: int | None = None, emoji: str | None = None, disable_notification: bool | None = None, protect_content: bool | None = None, reply_parameters: ReplyParameters | Mapping[str, object] | None = None, reply_markup: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply | Mapping[str, object] | None = None) Message

Use this method to send an animated emoji that will display a random value. On success, the sent Message is returned.

Parameters:
  • chat_id – Unique identifier for the target chat or username of the target bot, supergroup or channel in the format @username

  • message_thread_id – Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only

  • emoji – Emoji on which the dice throw animation is based. Currently, must be one of ‘’, ‘’, ‘’, ‘’, ‘’, or ‘’. Dice can have values 1-6 for ‘’, ‘’ and ‘’, values 1-5 for ‘’ and ‘’, and values 1-64 for ‘’. Defaults to ‘’.

  • disable_notification – Sends the message silently. Users will receive a notification with no sound.

  • protect_content – Protects the contents of the sent message from forwarding

  • reply_parameters – Description of the message to reply to

  • reply_markup – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove a reply keyboard or to force a reply from the user.

Returns:

Result returned by Telegram on successful execution.

Return type:

Message

async send_document(chat_id: int | str, document: str | bytes | FilePayload, *, caption: str | None = None, parse_mode: str | None = None, caption_entities: Sequence[MessageEntity | Mapping[str, object]] | None = None, thumbnail: str | bytes | FilePayload | None = None, disable_content_type_detection: bool | None = None, message_thread_id: int | None = None, disable_notification: bool | None = None, protect_content: bool | None = None, reply_parameters: ReplyParameters | Mapping[str, object] | None = None, reply_markup: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply | Mapping[str, object] | None = None) Message

Use this method to send general files. On success, the sent Message is returned. Bots can currently send files of any type of up to 50 MB in size, this limit may be changed in the future.

Parameters:
  • chat_id – Unique identifier for the target chat or username of the target bot, supergroup or channel in the format @username

  • document – File to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. More information on Sending Files

  • caption – Document caption (may also be used when resending documents by file_id), 0-1024 characters after entities parsing

  • parse_mode – Mode for parsing entities in the document caption. See formatting options for more details.

  • caption_entities – A JSON-serialized list of special entities that appear in the caption, which can be specified instead of parse_mode

  • thumbnail – Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail’s width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass ‘attach://’ if the thumbnail was uploaded using multipart/form-data under . More information on Sending Files

  • disable_content_type_detection – Disables automatic server-side content type detection for files uploaded using multipart/form-data

  • message_thread_id – Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only

  • disable_notification – Sends the message silently. Users will receive a notification with no sound.

  • protect_content – Protects the contents of the sent message from forwarding and saving

  • reply_parameters – Description of the message to reply to

  • reply_markup – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove a reply keyboard or to force a reply from the user.

Returns:

Result returned by Telegram on successful execution.

Return type:

Message

async send_game(chat_id: int | str, game_short_name: str, *, business_connection_id: str | None = None, message_thread_id: int | None = None, disable_notification: bool | None = None, protect_content: bool | None = None, allow_paid_broadcast: bool | None = None, message_effect_id: str | None = None, reply_parameters: ReplyParameters | None = None, reply_markup: InlineKeyboardMarkup | None = None) Message

Use this method to send a game. On success, the sent Message is returned.

Parameters:
  • chat_id – Unique identifier for the target chat or username of the target bot in the format @username. Games can’t be sent to channel direct messages chats and channel chats.

  • game_short_name – Short name of the game, serves as the unique identifier for the game. Set up your games via @BotFather.

  • business_connection_id – Unique identifier of the business connection on behalf of which the message will be sent

  • message_thread_id – Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only

  • disable_notification – Sends the message silently. Users will receive a notification with no sound.

  • protect_content – Protects the contents of the sent message from forwarding and saving

  • allow_paid_broadcast – Pass True to allow up to 1000 messages per second, ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot’s balance.

  • message_effect_id – Unique identifier of the message effect to be added to the message; for private chats only

  • reply_parameters – Description of the message to reply to

  • reply_markup – A JSON-serialized object for an inline keyboard. If empty, one ‘Play game_title’ button will be shown. If not empty, the first button must launch the game.

Returns:

Result returned by Telegram on successful execution.

Return type:

Message

async send_gift(gift_id: str, *, user_id: int | None = None, chat_id: int | str | None = None, pay_for_upgrade: bool | None = None, text: str | None = None, text_parse_mode: str | None = None, text_entities: List[MessageEntity] | None = None) bool

Sends a gift to the given user or channel chat. The gift can’t be converted to Telegram Stars by the receiver. Returns True on success.

Parameters:
  • gift_id – Identifier of the gift; limited gifts can’t be sent to channel chats

  • user_id – Required if chat_id is not specified. Unique identifier of the target user who will receive the gift.

  • chat_id – Required if user_id is not specified. Unique identifier for the chat or username of the channel (in the format @username) that will receive the gift.

  • pay_for_upgrade – Pass True to pay for the gift upgrade from the bot’s balance, thereby making the upgrade free for the receiver

  • text – Text that will be shown along with the gift; 0-128 characters

  • text_parse_mode – Mode for parsing entities in the text. See formatting options for more details. Entities other than ‘bold’, ‘italic’, ‘underline’, ‘strikethrough’, ‘spoiler’, ‘custom_emoji’, and ‘date_time’ are ignored.

  • text_entities – A JSON-serialized list of special entities that appear in the gift text. It can be specified instead of text_parse_mode. Entities other than ‘bold’, ‘italic’, ‘underline’, ‘strikethrough’, ‘spoiler’, ‘custom_emoji’, and ‘date_time’ are ignored.

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async send_invoice(chat_id: int | str, title: str, description: str, payload: str, currency: str, prices: List[LabeledPrice], *, message_thread_id: int | None = None, direct_messages_topic_id: int | None = None, provider_token: str | None = None, max_tip_amount: int | None = None, suggested_tip_amounts: List[int] | None = None, start_parameter: str | None = None, provider_data: str | None = None, photo_url: str | None = None, photo_size: int | None = None, photo_width: int | None = None, photo_height: int | None = None, need_name: bool | None = None, need_phone_number: bool | None = None, need_email: bool | None = None, need_shipping_address: bool | None = None, send_phone_number_to_provider: bool | None = None, send_email_to_provider: bool | None = None, is_flexible: bool | None = None, disable_notification: bool | None = None, protect_content: bool | None = None, allow_paid_broadcast: bool | None = None, message_effect_id: str | None = None, suggested_post_parameters: SuggestedPostParameters | None = None, reply_parameters: ReplyParameters | None = None, reply_markup: InlineKeyboardMarkup | None = None) Message

Use this method to send invoices. On success, the sent Message is returned.

Parameters:
  • chat_id – Unique identifier for the target chat or username of the target bot, supergroup or channel in the format @username

  • title – Product name, 1-32 characters

  • description – Product description, 1-255 characters

  • payload – Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use it for your internal processes.

  • currency – Three-letter ISO 4217 currency code, see more on currencies. Pass ‘XTR’ for payments in Telegram Stars.

  • prices – Price breakdown, a JSON-serialized list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.). Must contain exactly one item for payments in Telegram Stars.

  • message_thread_id – Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only

  • direct_messages_topic_id – Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat

  • provider_token – Payment provider token, obtained via @BotFather. Pass an empty string for payments in Telegram Stars.

  • max_tip_amount – The maximum accepted amount for tips in the smallest units of the currency (integer, not float/double). For example, for a maximum tip of US$ 1.45 pass max_tip_amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). Defaults to 0. Not supported for payments in Telegram Stars.

  • suggested_tip_amounts – A JSON-serialized Array of suggested amounts of tips in the smallest units of the currency (integer, not float/double). At most 4 suggested tip amounts can be specified. The suggested tip amounts must be positive, passed in a strictly increased order and must not exceed max_tip_amount.

  • start_parameter – Unique deep-linking parameter. If left empty, forwarded copies of the sent message will have a Pay button, allowing multiple users to pay directly from the forwarded message, using the same invoice. If non-empty, forwarded copies of the sent message will have a URL button with a deep link to the bot (instead of a Pay button), with the value used as the start parameter.

  • provider_data – JSON-serialized data about the invoice, which will be shared with the payment provider. A detailed description of required fields should be provided by the payment provider.

  • photo_url – URL of the product photo for the invoice. Can be a photo of the goods or a marketing image for a service. People like it better when they see what they are paying for.

  • photo_size – Photo size in bytes

  • photo_width – Photo width

  • photo_height – Photo height

  • need_name – Pass True if you require the user’s full name to complete the order. Ignored for payments in Telegram Stars.

  • need_phone_number – Pass True if you require the user’s phone number to complete the order. Ignored for payments in Telegram Stars.

  • need_email – Pass True if you require the user’s email address to complete the order. Ignored for payments in Telegram Stars.

  • need_shipping_address – Pass True if you require the user’s shipping address to complete the order. Ignored for payments in Telegram Stars.

  • send_phone_number_to_provider – Pass True if the user’s phone number should be sent to the provider. Ignored for payments in Telegram Stars.

  • send_email_to_provider – Pass True if the user’s email address should be sent to the provider. Ignored for payments in Telegram Stars.

  • is_flexible – Pass True if the final price depends on the shipping method. Ignored for payments in Telegram Stars.

  • disable_notification – Sends the message silently. Users will receive a notification with no sound.

  • protect_content – Protects the contents of the sent message from forwarding and saving

  • allow_paid_broadcast – Pass True to allow up to 1000 messages per second, ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot’s balance.

  • message_effect_id – Unique identifier of the message effect to be added to the message; for private chats only

  • suggested_post_parameters – A JSON-serialized object containing the parameters of the suggested post to send; for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post is automatically declined.

  • reply_parameters – Description of the message to reply to

  • reply_markup – A JSON-serialized object for an inline keyboard. If empty, one ‘Pay total price’ button will be shown. If not empty, the first button must be a Pay button.

Returns:

Result returned by Telegram on successful execution.

Return type:

Message

async send_live_photo(chat_id: int | str, live_photo: str | bytes | FilePayload, photo: str | bytes | FilePayload, *, caption: str | None = None, parse_mode: str | None = None, caption_entities: Sequence[MessageEntity | Mapping[str, object]] | None = None, show_caption_above_media: bool | None = None, has_spoiler: bool | None = None, message_thread_id: int | None = None, disable_notification: bool | None = None, protect_content: bool | None = None, reply_parameters: ReplyParameters | Mapping[str, object] | None = None, reply_markup: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply | Mapping[str, object] | None = None) Message

Use this method to send live photos. On success, the sent Message is returned.

Parameters:
  • chat_id – Unique identifier for the target chat or username of the target channel (in the format @channelusername)

  • live_photo – Live photo video to send. The video must be no longer than 10 seconds and must not exceed 10 MB in size. Pass a file_id as String to send a video that exists on the Telegram servers (recommended) or upload a new video using multipart/form-data. More information on Sending Files. Sending live photos by a URL is currently unsupported.

  • photo – The static photo to send. Pass a file_id as String to send a photo that exists on the Telegram servers (recommended) or upload a new video using multipart/form-data. More information on Sending Files. Sending live photos by a URL is currently unsupported.

  • caption – Video caption (may also be used when resending videos by file_id), 0-1024 characters after entities parsing

  • parse_mode – Mode for parsing entities in the video caption. See formatting options for more details.

  • caption_entities – A JSON-serialized list of special entities that appear in the caption, which can be specified instead of parse_mode

  • show_caption_above_media – Pass True if the caption must be shown above the message media

  • has_spoiler – Pass True if the video needs to be covered with a spoiler animation

  • message_thread_id – Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only

  • disable_notification – Sends the message silently. Users will receive a notification with no sound.

  • protect_content – Protects the contents of the sent message from forwarding and saving

  • reply_parameters – Description of the message to reply to

  • reply_markup – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove a reply keyboard or to force a reply from the user.

Returns:

Result returned by Telegram on successful execution.

Return type:

Message

async send_location(chat_id: int | str, latitude: float, longitude: float, *, message_thread_id: int | None = None, horizontal_accuracy: float | None = None, live_period: int | None = None, heading: int | None = None, proximity_alert_radius: int | None = None, disable_notification: bool | None = None, protect_content: bool | None = None, reply_parameters: ReplyParameters | Mapping[str, object] | None = None, reply_markup: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply | Mapping[str, object] | None = None) Message

Use this method to send point on the map. On success, the sent Message is returned.

Parameters:
  • chat_id – Unique identifier for the target chat or username of the target bot, supergroup or channel in the format @username

  • latitude – Latitude of the location

  • longitude – Longitude of the location

  • message_thread_id – Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only

  • horizontal_accuracy – The radius of uncertainty for the location, measured in meters; 0-1500

  • live_period – Period in seconds during which the location will be updated (see Live Locations), must be between 60 and 86400, or 0x7FFFFFFF for live locations that can be edited indefinitely. Must be 0 for ephemeral messages.

  • heading – For live locations, a direction in which the user is moving, in degrees. Must be between 1 and 360 if specified.

  • proximity_alert_radius – For live locations, a maximum distance for proximity alerts about approaching another chat member, in meters. Must be between 1 and 100000 if specified.

  • disable_notification – Sends the message silently. Users will receive a notification with no sound.

  • protect_content – Protects the contents of the sent message from forwarding and saving

  • reply_parameters – Description of the message to reply to

  • reply_markup – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove a reply keyboard or to force a reply from the user.

Returns:

Result returned by Telegram on successful execution.

Return type:

Message

async send_media_group(chat_id: int | str, media: Sequence[InputMediaPhoto | InputMediaVideo | InputMediaAnimation | InputMediaAudio | InputMediaDocument | InputMediaLivePhoto], *, message_thread_id: int | None = None, disable_notification: bool | None = None, protect_content: bool | None = None, reply_parameters: ReplyParameters | Mapping[str, object] | None = None) List[Message]

Use this method to send a group of photos, live photos, videos, documents or audios as an album. Documents and audio files can be only grouped in an album with messages of the same type. On success, an Array of Message objects that were sent is returned.

Parameters:
  • chat_id – Unique identifier for the target chat or username of the target bot, supergroup or channel in the format @username

  • media – A JSON-serialized Array describing messages to be sent, must include 2-10 items

  • message_thread_id – Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only

  • disable_notification – Sends messages silently. Users will receive a notification with no sound.

  • protect_content – Protects the contents of the sent messages from forwarding and saving

  • reply_parameters – Description of the message to reply to

Returns:

Result returned by Telegram on successful execution.

Return type:

List[Message]

async send_message(chat_id: int | str, text: str, *, business_connection_id: str | None = None, message_thread_id: int | None = None, parse_mode: str | None = None, entities: Sequence[MessageEntity | Mapping[str, object]] | None = None, link_preview_options: LinkPreviewOptions | Mapping[str, object] | None = None, disable_notification: bool | None = None, protect_content: bool | None = None, reply_parameters: ReplyParameters | Mapping[str, object] | None = None, reply_markup: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply | Mapping[str, object] | None = None) Message

Use this method to send text messages. On success, the sent Message is returned.

Parameters:
  • chat_id – Unique identifier for the target chat or username of the target bot, supergroup or channel in the format @username

  • text – Text of the message to be sent, 1-4096 characters after entities parsing

  • business_connection_id – Unique identifier of the business connection on behalf of which the message will be sent

  • message_thread_id – Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only

  • parse_mode – Mode for parsing entities in the message text. See formatting options for more details.

  • entities – A JSON-serialized list of special entities that appear in message text, which can be specified instead of parse_mode

  • link_preview_options – Link preview generation options for the message

  • disable_notification – Sends the message silently. Users will receive a notification with no sound.

  • protect_content – Protects the contents of the sent message from forwarding and saving

  • reply_parameters – Description of the message to reply to

  • reply_markup – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove a reply keyboard or to force a reply from the user.

Returns:

Result returned by Telegram on successful execution.

Return type:

Message

async send_message_draft(chat_id: int, draft_id: int | None = None, *, message_thread_id: int | None = None, text: str | None = None, parse_mode: str | None = None, entities: List[MessageEntity] | None = None, can_stop: bool | None = None, keep_on_stop: bool | None = None) bool

Use this method to stream a partial message to a user while the message is being generated. Note that the streamed draft is ephemeral and acts as a temporary 30-second preview - once the output is finalized, you must call sendMessage with the complete message to persist it in the user’s chat. Returns True on success.

Parameters:
  • chat_id – Unique identifier for the target private chat

  • draft_id – Unique identifier of the message draft; must be non-zero. Changes to drafts with the same identifier are animated.

  • message_thread_id – Unique identifier for the target message thread

  • text – Text of the message to be sent, 0-4096 characters after entities parsing. Pass an empty text to show a ‘Thinking…’ placeholder.

  • parse_mode – Mode for parsing entities in the message text. See formatting options for more details.

  • entities – A JSON-serialized list of special entities that appear in message text, which can be specified instead of parse_mode

  • can_stop – Value accepted by this operation.

  • keep_on_stop – Value accepted by this operation.

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async send_paid_media(chat_id: int | str, star_count: int, media: List[object], *, business_connection_id: str | None = None, message_thread_id: int | None = None, direct_messages_topic_id: int | None = None, payload: str | None = None, caption: str | None = None, parse_mode: str | None = None, caption_entities: List[MessageEntity] | None = None, show_caption_above_media: bool | None = None, disable_notification: bool | None = None, protect_content: bool | None = None, allow_paid_broadcast: bool | None = None, suggested_post_parameters: object | None = None, reply_parameters: ReplyParameters | None = None, reply_markup: object | None = None) Message

Use this method to send paid media. On success, the sent Message is returned.

Parameters:
  • chat_id – Unique identifier for the target chat or username of the target bot, supergroup or channel in the format @username. If the chat is a channel, all Telegram Star proceeds from this media will be credited to the chat’s balance. Otherwise, they will be credited to the bot’s balance.

  • star_count – The number of Telegram Stars that must be paid to buy access to the media; 1-25000

  • media – A JSON-serialized Array describing the media to be sent; up to 10 items

  • business_connection_id – Unique identifier of the business connection on behalf of which the message will be sent

  • message_thread_id – Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only

  • direct_messages_topic_id – Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat

  • payload – Bot-defined paid media payload, 0-128 bytes. This will not be displayed to the user, use it for your internal processes.

  • caption – Media caption, 0-1024 characters after entities parsing

  • parse_mode – Mode for parsing entities in the media caption. See formatting options for more details.

  • caption_entities – A JSON-serialized list of special entities that appear in the caption, which can be specified instead of parse_mode

  • show_caption_above_media – Pass True if the caption must be shown above the message media

  • disable_notification – Sends the message silently. Users will receive a notification with no sound.

  • protect_content – Protects the contents of the sent message from forwarding and saving

  • allow_paid_broadcast – Pass True to allow up to 1000 messages per second, ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot’s balance.

  • suggested_post_parameters – A JSON-serialized object containing the parameters of the suggested post to send; for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post is automatically declined.

  • reply_parameters – Description of the message to reply to

  • reply_markup – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove a reply keyboard or to force a reply from the user.

Returns:

Result returned by Telegram on successful execution.

Return type:

Message

async send_photo(chat_id: int | str, photo: str | bytes | FilePayload, *, caption: str | None = None, parse_mode: str | None = None, caption_entities: Sequence[MessageEntity | Mapping[str, object]] | None = None, show_caption_above_media: bool | None = None, has_spoiler: bool | None = None, message_thread_id: int | None = None, disable_notification: bool | None = None, protect_content: bool | None = None, reply_parameters: ReplyParameters | Mapping[str, object] | None = None, reply_markup: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply | Mapping[str, object] | None = None) Message

Use this method to send photos. On success, the sent Message is returned.

Parameters:
  • chat_id – Unique identifier for the target chat or username of the target bot, supergroup or channel in the format @username

  • photo – Photo to send. Pass a file_id as String to send a photo that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a photo from the Internet, or upload a new photo using multipart/form-data. The photo must be at most 10 MB in size. The photo’s width and height must not exceed 10000 in total. Width and height ratio must be at most 20. More information on Sending Files

  • caption – Photo caption (may also be used when resending photos by file_id), 0-1024 characters after entities parsing

  • parse_mode – Mode for parsing entities in the photo caption. See formatting options for more details.

  • caption_entities – A JSON-serialized list of special entities that appear in the caption, which can be specified instead of parse_mode

  • show_caption_above_media – Pass True if the caption must be shown above the message media

  • has_spoiler – Pass True if the photo needs to be covered with a spoiler animation

  • message_thread_id – Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only

  • disable_notification – Sends the message silently. Users will receive a notification with no sound.

  • protect_content – Protects the contents of the sent message from forwarding and saving

  • reply_parameters – Description of the message to reply to

  • reply_markup – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove a reply keyboard or to force a reply from the user.

Returns:

Result returned by Telegram on successful execution.

Return type:

Message

async send_poll(chat_id: int | str, question: str, options: Sequence[str | InputPollOption], *, message_thread_id: int | None = None, question_parse_mode: str | None = None, question_entities: Sequence[MessageEntity | Mapping[str, object]] | None = None, is_anonymous: bool | None = None, type: str | None = None, allows_multiple_answers: bool | None = None, allows_revoting: bool | None = None, shuffle_options: bool | None = None, allow_adding_options: bool | None = None, hide_results_until_closes: bool | None = None, members_only: bool | None = None, country_codes: Sequence[str] | None = None, correct_option_ids: Sequence[int] | None = None, explanation: str | None = None, explanation_parse_mode: str | None = None, explanation_entities: Sequence[MessageEntity | Mapping[str, object]] | None = None, explanation_media: InputMediaPhoto | InputMediaVideo | InputMediaAnimation | InputMediaAudio | InputMediaDocument | InputMediaLivePhoto | InputMediaLocation | InputMediaVenue | Mapping[str, object] | None = None, open_period: int | None = None, close_date: int | None = None, is_closed: bool | None = None, description: str | None = None, description_parse_mode: str | None = None, description_entities: Sequence[MessageEntity | Mapping[str, object]] | None = None, media: InputMediaPhoto | InputMediaVideo | InputMediaAnimation | InputMediaAudio | InputMediaDocument | InputMediaLivePhoto | InputMediaLocation | InputMediaVenue | Mapping[str, object] | None = None, disable_notification: bool | None = None, protect_content: bool | None = None, reply_parameters: ReplyParameters | Mapping[str, object] | None = None, reply_markup: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply | Mapping[str, object] | None = None) Message

Use this method to send a native poll. On success, the sent Message is returned.

Parameters:
  • chat_id – Unique identifier for the target chat or username of the target bot, supergroup or channel in the format @username. Polls can’t be sent to channel direct messages chats.

  • question – Poll question, 1-300 characters

  • options – A JSON-serialized list of 1-12 answer options

  • message_thread_id – Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only

  • question_parse_mode – Mode for parsing entities in the question. See formatting options for more details. Currently, only custom emoji entities are allowed.

  • question_entities – A JSON-serialized list of special entities that appear in the poll question. It can be specified instead of question_parse_mode.

  • is_anonymous – True, if the poll needs to be anonymous, defaults to True

  • type – Poll type, ‘quiz’ or ‘regular’, defaults to ‘regular’

  • allows_multiple_answers – Pass True if the poll allows multiple answers, defaults to False

  • allows_revoting – Pass True if the poll allows to change chosen answer options, defaults to False for quizzes and to True for regular polls

  • shuffle_options – Pass True if the poll options must be shown in random order

  • allow_adding_options – Pass True if answer options can be added to the poll after creation; not supported for anonymous polls and quizzes

  • hide_results_until_closes – Pass True if poll results must be shown only after the poll closes

  • members_only – Pass True if voting is limited to users who have been members of the chat where the poll is being sent for more than 24 hours; for channel chats only

  • country_codes – A JSON-serialized list of 0-12 two-letter ISO 3166-1 alpha-2 country codes indicating the countries from which users can vote in the poll; for channel chats only. Use ‘FT’ as a country code to allow users with anonymous numbers to vote. If omitted or empty, then users from any country can participate in the poll.

  • correct_option_ids – A JSON-serialized list of monotonically increasing 0-based identifiers of the correct answer options, required for polls in quiz mode

  • explanation – Text that is shown when a user chooses an incorrect answer or taps on the lamp icon in a quiz-style poll, 0-200 characters with at most 2 line feeds after entities parsing

  • explanation_parse_mode – Mode for parsing entities in the explanation. See formatting options for more details.

  • explanation_entities – A JSON-serialized list of special entities that appear in the poll explanation. It can be specified instead of explanation_parse_mode.

  • explanation_media – Media added to the quiz explanation

  • open_period – Amount of time in seconds the poll will be active after creation, 5-2628000. Can’t be used together with close_date.

  • close_date – Point in time (Unix timestamp) when the poll will be automatically closed. Must be at least 5 and no more than 2628000 seconds in the future. Can’t be used together with open_period.

  • is_closed – Pass True if the poll needs to be immediately closed. This can be useful for poll preview.

  • description – Description of the poll to be sent, 0-1024 characters after entities parsing

  • description_parse_mode – Mode for parsing entities in the poll description. See formatting options for more details.

  • description_entities – A JSON-serialized list of special entities that appear in the poll description, which can be specified instead of description_parse_mode

  • media – Media added to the poll description

  • disable_notification – Sends the message silently. Users will receive a notification with no sound.

  • protect_content – Protects the contents of the sent message from forwarding and saving

  • reply_parameters – Description of the message to reply to

  • reply_markup – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove a reply keyboard or to force a reply from the user.

Returns:

Result returned by Telegram on successful execution.

Return type:

Message

async send_rich_message(chat_id: int | str, rich_message: InputRichMessage | None = None, *, text: str | None = None, parse_mode: str | None = None, blocks: object | None = None, media: object | None = None, business_connection_id: str | None = None, message_thread_id: int | None = None, direct_messages_topic_id: int | None = None, ephemeral_message_parameters: EphemeralMessageParameters | None = None, disable_notification: bool | None = None, protect_content: bool | None = None, allow_paid_broadcast: bool | None = None, message_effect_id: str | None = None, suggested_post_parameters: SuggestedPostParameters | None = None, reply_parameters: ReplyParameters | None = None, reply_markup: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply | None = None) Message

Use this method to send rich messages. If the message contains a block with a media element, then the bot must have the right to send the media to the chat. On success, the sent Message is returned.

Parameters:
  • chat_id – Unique identifier for the target chat or username of the target bot, supergroup or channel in the format @username

  • rich_message – The message to be sent

  • text – Value accepted by this operation.

  • parse_mode – Value accepted by this operation.

  • blocks – Value accepted by this operation.

  • media – Value accepted by this operation.

  • business_connection_id – Unique identifier of the business connection on behalf of which the message will be sent. Bot can send rich messages on behalf of a business account only if the corresponding user can send rich messages.

  • message_thread_id – Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only

  • direct_messages_topic_id – Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat

  • ephemeral_message_parameters – Value accepted by this operation.

  • disable_notification – Sends the message silently. Users will receive a notification with no sound.

  • protect_content – Protects the contents of the sent message from forwarding and saving

  • allow_paid_broadcast – Pass True to allow up to 1000 messages per second, ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot’s balance.

  • message_effect_id – Unique identifier of the message effect to be added to the message; for private chats only

  • suggested_post_parameters – A JSON-serialized object containing the parameters of the suggested post to send; for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post is automatically declined.

  • reply_parameters – Description of the message to reply to

  • reply_markup – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove a reply keyboard or to force a reply from the user.

Returns:

Result returned by Telegram on successful execution.

Return type:

Message

async send_rich_message_draft(chat_id: int, draft_id: int | None = None, rich_message: InputRichMessage | None = None, *, text: str | None = None, message_thread_id: int | None = None, can_stop: bool | None = None, keep_on_stop: bool | None = None) bool

Use this method to stream a partial rich message to a user while the message is being generated. Note that the streamed draft is ephemeral and acts as a temporary 30-second preview - once the output is finalized, you must call sendRichMessage with the complete message to persist it in the user’s chat. Returns True on success.

Parameters:
  • chat_id – Unique identifier for the target private chat

  • draft_id – Unique identifier of the message draft; must be non-zero. Changes to drafts with the same identifier are animated.

  • rich_message – The partial message to be streamed. Direct upload of new files isn’t supported.

  • text – Value accepted by this operation.

  • message_thread_id – Unique identifier for the target message thread

  • can_stop – Value accepted by this operation.

  • keep_on_stop – Value accepted by this operation.

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async send_sticker(chat_id: int | str, sticker: str | bytes | FilePayload, *, message_thread_id: int | None = None, emoji: str | None = None, disable_notification: bool | None = None, protect_content: bool | None = None, reply_parameters: ReplyParameters | Mapping[str, object] | None = None, reply_markup: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply | Mapping[str, object] | None = None) Message

Use this method to send static .WEBP, animated .TGS, or video .WEBM stickers. On success, the sent Message is returned.

Parameters:
  • chat_id – Unique identifier for the target chat or username of the target bot, supergroup or channel in the format @username

  • sticker – Sticker to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a .WEBP sticker from the Internet, or upload a new .WEBP, .TGS, or .WEBM sticker using multipart/form-data. More information on Sending Files. Video and animated stickers can’t be sent via an HTTP URL.

  • message_thread_id – Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only

  • emoji – Emoji associated with the sticker; only for just uploaded stickers

  • disable_notification – Sends the message silently. Users will receive a notification with no sound.

  • protect_content – Protects the contents of the sent message from forwarding and saving

  • reply_parameters – Description of the message to reply to

  • reply_markup – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove a reply keyboard or to force a reply from the user.

Returns:

Result returned by Telegram on successful execution.

Return type:

Message

async send_venue(chat_id: int | str, latitude: float, longitude: float, title: str, address: str, *, message_thread_id: int | None = None, foursquare_id: str | None = None, foursquare_type: str | None = None, google_place_id: str | None = None, google_place_type: str | None = None, disable_notification: bool | None = None, protect_content: bool | None = None, reply_parameters: ReplyParameters | Mapping[str, object] | None = None, reply_markup: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply | Mapping[str, object] | None = None) Message

Use this method to send information about a venue. On success, the sent Message is returned.

Parameters:
  • chat_id – Unique identifier for the target chat or username of the target bot, supergroup or channel in the format @username

  • latitude – Latitude of the venue

  • longitude – Longitude of the venue

  • title – Name of the venue

  • address – Address of the venue

  • message_thread_id – Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only

  • foursquare_id – Foursquare identifier of the venue

  • foursquare_type – Foursquare type of the venue, if known. (For example, ‘arts_entertainment/default’, ‘arts_entertainment/aquarium’ or ‘food/icecream’.)

  • google_place_id – Google Places identifier of the venue

  • google_place_type – Google Places type of the venue. (See supported types.)

  • disable_notification – Sends the message silently. Users will receive a notification with no sound.

  • protect_content – Protects the contents of the sent message from forwarding and saving

  • reply_parameters – Description of the message to reply to

  • reply_markup – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove a reply keyboard or to force a reply from the user.

Returns:

Result returned by Telegram on successful execution.

Return type:

Message

async send_video(chat_id: int | str, video: str | bytes | FilePayload, *, caption: str | None = None, parse_mode: str | None = None, caption_entities: Sequence[MessageEntity | Mapping[str, object]] | None = None, show_caption_above_media: bool | None = None, has_spoiler: bool | None = None, duration: int | None = None, width: int | None = None, height: int | None = None, thumbnail: str | bytes | FilePayload | None = None, cover: str | bytes | FilePayload | None = None, start_timestamp: int | None = None, supports_streaming: bool | None = None, message_thread_id: int | None = None, disable_notification: bool | None = None, protect_content: bool | None = None, reply_parameters: ReplyParameters | Mapping[str, object] | None = None, reply_markup: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply | Mapping[str, object] | None = None) Message

Use this method to send video files, Telegram clients support MPEG4 videos (other formats may be sent as Document). On success, the sent Message is returned. Bots can currently send video files of up to 50 MB in size, this limit may be changed in the future.

Parameters:
  • chat_id – Unique identifier for the target chat or username of the target bot, supergroup or channel in the format @username

  • video – Video to send. Pass a file_id as String to send a video that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a video from the Internet, or upload a new video using multipart/form-data. More information on Sending Files

  • caption – Video caption (may also be used when resending videos by file_id), 0-1024 characters after entities parsing

  • parse_mode – Mode for parsing entities in the video caption. See formatting options for more details.

  • caption_entities – A JSON-serialized list of special entities that appear in the caption, which can be specified instead of parse_mode

  • show_caption_above_media – Pass True if the caption must be shown above the message media

  • has_spoiler – Pass True if the video needs to be covered with a spoiler animation

  • duration – Duration of sent video in seconds

  • width – Video width

  • height – Video height

  • thumbnail – Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail’s width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass ‘attach://’ if the thumbnail was uploaded using multipart/form-data under . More information on Sending Files

  • cover – Cover for the video in the message. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass ‘attach://’ to upload a new one using multipart/form-data under name. More information on Sending Files

  • start_timestamp – Start timestamp for the video in the message

  • supports_streaming – Pass True if the uploaded video is suitable for streaming

  • message_thread_id – Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only

  • disable_notification – Sends the message silently. Users will receive a notification with no sound.

  • protect_content – Protects the contents of the sent message from forwarding and saving

  • reply_parameters – Description of the message to reply to

  • reply_markup – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove a reply keyboard or to force a reply from the user.

Returns:

Result returned by Telegram on successful execution.

Return type:

Message

async send_video_note(chat_id: int | str, video_note: str | bytes | FilePayload, *, duration: int | None = None, length: int | None = None, thumbnail: str | bytes | FilePayload | None = None, message_thread_id: int | None = None, disable_notification: bool | None = None, protect_content: bool | None = None, reply_parameters: ReplyParameters | Mapping[str, object] | None = None, reply_markup: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply | Mapping[str, object] | None = None) Message

As of v.4.0, Telegram clients support rounded square MPEG4 videos of up to 1 minute long. Use this method to send video messages. On success, the sent Message is returned.

Parameters:
  • chat_id – Unique identifier for the target chat or username of the target bot, supergroup or channel in the format @username

  • video_note – Video note to send. Pass a file_id as String to send a video note that exists on the Telegram servers (recommended) or upload a new video using multipart/form-data. More information on Sending Files. Sending video notes by a URL is currently unsupported.

  • duration – Duration of sent video in seconds

  • length – Video width and height, i.e. diameter of the video message

  • thumbnail – Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail’s width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass ‘attach://’ if the thumbnail was uploaded using multipart/form-data under . More information on Sending Files

  • message_thread_id – Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only

  • disable_notification – Sends the message silently. Users will receive a notification with no sound.

  • protect_content – Protects the contents of the sent message from forwarding and saving

  • reply_parameters – Description of the message to reply to

  • reply_markup – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove a reply keyboard or to force a reply from the user.

Returns:

Result returned by Telegram on successful execution.

Return type:

Message

async send_voice(chat_id: int | str, voice: str | bytes | FilePayload, *, caption: str | None = None, parse_mode: str | None = None, caption_entities: Sequence[MessageEntity | Mapping[str, object]] | None = None, duration: int | None = None, message_thread_id: int | None = None, disable_notification: bool | None = None, protect_content: bool | None = None, reply_parameters: ReplyParameters | Mapping[str, object] | None = None, reply_markup: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply | Mapping[str, object] | None = None) Message

Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message. For this to work, your audio must be in an .OGG file encoded with OPUS, or in .MP3 format, or in .M4A format (other formats may be sent as Audio or Document). On success, the sent Message is returned. Bots can currently send voice messages of up to 50 MB in size, this limit may be changed in the future.

Parameters:
  • chat_id – Unique identifier for the target chat or username of the target bot, supergroup or channel in the format @username

  • voice – Audio file to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. More information on Sending Files

  • caption – Voice message caption, 0-1024 characters after entities parsing

  • parse_mode – Mode for parsing entities in the voice message caption. See formatting options for more details.

  • caption_entities – A JSON-serialized list of special entities that appear in the caption, which can be specified instead of parse_mode

  • duration – Duration of the voice message in seconds

  • message_thread_id – Unique identifier for the target message thread (topic) of a forum; for forum supergroups and private chats of bots with forum topic mode enabled only

  • disable_notification – Sends the message silently. Users will receive a notification with no sound.

  • protect_content – Protects the contents of the sent message from forwarding and saving

  • reply_parameters – Description of the message to reply to

  • reply_markup – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove a reply keyboard or to force a reply from the user.

Returns:

Result returned by Telegram on successful execution.

Return type:

Message

async set_business_account_bio(business_connection_id: str, *, bio: str | None = None) bool

Changes the bio of a managed business account. Requires the can_change_bio business bot right. Returns True on success.

Parameters:
  • business_connection_id – Unique identifier of the business connection

  • bio – The new value of the bio for the business account; 0-140 characters

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async set_business_account_gift_settings(business_connection_id: str, show_gift_button: bool, accepted_gift_types: AcceptedGiftTypes) bool

Changes the privacy settings pertaining to incoming gifts in a managed business account. Requires the can_change_gift_settings business bot right. Returns True on success.

Parameters:
  • business_connection_id – Unique identifier of the business connection

  • show_gift_button – Pass True if a button for sending a gift to the user or by the business account must always be shown in the input field

  • accepted_gift_types – Types of gifts accepted by the business account

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async set_business_account_name(business_connection_id: str, first_name: str, *, last_name: str | None = None) bool

Changes the first and last name of a managed business account. Requires the can_change_name business bot right. Returns True on success.

Parameters:
  • business_connection_id – Unique identifier of the business connection

  • first_name – The new value of the first name for the business account; 1-64 characters

  • last_name – The new value of the last name for the business account; 0-64 characters

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async set_business_account_profile_photo(business_connection_id: str, photo: InputProfilePhotoStatic | InputProfilePhotoAnimated, *, is_public: bool | None = None) bool

Changes the profile photo of a managed business account. Requires the can_edit_profile_photo business bot right. Returns True on success.

Parameters:
  • business_connection_id – Unique identifier of the business connection

  • photo – The new profile photo to set

  • is_public – Pass True to set the public photo, which will be visible even if the main photo is hidden by the business account’s privacy settings. An account can have only one public photo.

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async set_business_account_username(business_connection_id: str, *, username: str | None = None) bool

Changes the username of a managed business account. Requires the can_change_username business bot right. Returns True on success.

Parameters:
  • business_connection_id – Unique identifier of the business connection

  • username – The new value of the username for the business account; 0-32 characters

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async set_chat_administrator_custom_title(chat_id: int | str, user_id: int, custom_title: str) bool

Use this method to set a custom title for an administrator in a supergroup promoted by the bot. Returns True on success.

Parameters:
  • chat_id – Unique identifier for the target chat or username of the target supergroup in the format @username

  • user_id – Unique identifier of the target user

  • custom_title – New custom title for the administrator; 0-16 characters, emoji are not allowed

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async set_chat_description(chat_id: int | str, description: str | None = None) bool

Use this method to change the description of a group, a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success.

Parameters:
  • chat_id – Unique identifier for the target chat or username of the target channel in the format @username

  • description – New chat description, 0-255 characters

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async set_chat_member_tag(chat_id: int | str, user_id: int, *, tag: str | None = None) bool

Use this method to set a tag for a regular member in a group or a supergroup. The bot must be an administrator in the chat for this to work and must have the can_manage_tags administrator right. Returns True on success.

Parameters:
  • chat_id – Unique identifier for the target chat or username of the target supergroup in the format @username

  • user_id – Unique identifier of the target user

  • tag – New tag for the member; 0-16 characters, emoji are not allowed

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async set_chat_menu_button(*, chat_id: int | str | None = None, menu_button: MenuButtonCommands | MenuButtonWebApp | MenuButtonDefault | Mapping[str, object] | None = None) bool

Use this method to change the bot’s menu button in a private chat, or the default menu button. Returns True on success.

Parameters:
  • chat_id – Unique identifier for the target private chat. If not specified, the bot’s default menu button will be changed.

  • menu_button – A JSON-serialized object for the bot’s new menu button. Defaults to MenuButtonDefault.

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async set_chat_permissions(chat_id: int | str, permissions: ChatPermissions | Mapping[str, object], *, use_independent_chat_permissions: bool | None = None) bool

Use this method to set default chat permissions for all members. The bot must be an administrator in the group or a supergroup for this to work and must have the can_restrict_members administrator rights. Returns True on success.

Parameters:
  • chat_id – Unique identifier for the target chat or username of the target supergroup in the format @username

  • permissions – A JSON-serialized object for new default chat permissions

  • use_independent_chat_permissions – Pass True if chat permissions are set independently. Otherwise, the can_send_other_messages and can_add_web_page_previews permissions will imply the can_send_messages, can_send_audios, can_send_documents, can_send_photos, can_send_videos, can_send_video_notes, and can_send_voice_notes permissions; the can_send_polls permission will imply the can_send_messages permission.

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async set_chat_photo(chat_id: int | str, photo: str | bytes | FilePayload) bool

Use this method to set a new profile photo for the chat. Photos can’t be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success.

Parameters:
  • chat_id – Unique identifier for the target chat or username of the target channel in the format @username

  • photo – New chat photo, uploaded using multipart/form-data

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async set_chat_sticker_set(chat_id: int | str, sticker_set_name: str) bool

Use this method to set a new group sticker set for a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Use the field can_set_sticker_set optionally returned in getChat requests to check if the bot can use this method. Returns True on success.

Parameters:
  • chat_id – Unique identifier for the target chat or username of the target supergroup in the format @username

  • sticker_set_name – Name of the sticker set to be set as the group sticker set

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async set_custom_emoji_sticker_set_thumbnail(name: str, custom_emoji_id: str | None = None) bool

Use this method to set the thumbnail of a custom emoji sticker set. Returns True on success.

Parameters:
  • name – Sticker set name

  • custom_emoji_id – Custom emoji identifier of a sticker from the sticker set; pass an empty string to drop the thumbnail and use the first sticker as the thumbnail

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async set_game_score(user_id: int, score: int, *, force: bool | None = None, disable_edit_message: bool | None = None, chat_id: int | None = None, message_id: int | None = None, inline_message_id: str | None = None) Message | bool

Use this method to set the score of the specified user in a game message. On success, if the message is not an inline message, the Message is returned, otherwise True is returned. Returns an error, if the new score is not greater than the user’s current score in the chat and force is False.

Parameters:
  • user_id – User identifier

  • score – New score, must be non-negative

  • force – Pass True if the high score is allowed to decrease. This can be useful when fixing mistakes or banning cheaters.

  • disable_edit_message – Pass True if the game message should not be automatically edited to include the current scoreboard

  • chat_id – Required if inline_message_id is not specified. Unique identifier for the target chat.

  • message_id – Required if inline_message_id is not specified. Identifier of the sent message.

  • inline_message_id – Required if chat_id and message_id are not specified. Identifier of the inline message.

Returns:

Result returned by Telegram on successful execution.

Return type:

Union[Message, bool]

async set_managed_bot_access_settings(user_id: int | None = None, is_access_restricted: bool | None = None, *, added_user_ids: List[int] | None = None, chat_id: int | None = None) bool

Use this method to change the access settings of a managed bot. Returns True on success.

Parameters:
  • user_id – User identifier of the managed bot whose access settings will be changed

  • is_access_restricted – Pass True if only selected users can access the bot. The bot’s owner can always access it.

  • added_user_ids – A JSON-serialized list of up to 10 identifiers of users who will have access to the bot in addition to its owner. Ignored if is_access_restricted is False.

  • chat_id – Value accepted by this operation.

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async set_message_reaction(chat_id: int | str, message_id: int, *, reaction: List[ReactionTypeEmoji | ReactionTypeCustomEmoji | ReactionTypePaid] | None = None, is_big: bool | None = None) bool

Use this method to change the chosen reactions on a message. Service messages of some types can’t be reacted to. Automatically forwarded messages from a channel to its discussion group have the same available reactions as messages in the channel. Bots can’t use paid reactions. Returns True on success.

Parameters:
  • chat_id – Unique identifier for the target chat or username of the target bot, supergroup or channel in the format @username

  • message_id – Identifier of the target message. If the message belongs to a media group, the reaction is set to the first non-deleted message in the group instead.

  • reaction – A JSON-serialized list of reaction types to set on the message. Currently, as non-premium users, bots can set up to one reaction per message. A custom emoji reaction can be used if it is either already present on the message or explicitly allowed by chat administrators. Paid reactions can’t be used by bots.

  • is_big – Pass True to set the reaction with a big animation

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async set_my_commands(commands: Sequence[BotCommand | Mapping[str, object]], *, scope: BotCommandScopeDefault | BotCommandScopeAllPrivateChats | BotCommandScopeAllGroupChats | BotCommandScopeAllChatAdministrators | BotCommandScopeChat | BotCommandScopeChatAdministrators | BotCommandScopeChatMember | Mapping[str, object] | None = None, language_code: str | None = None) bool

Use this method to change the list of the bot’s commands. See this manual for more details about bot commands. Returns True on success.

Parameters:
  • commands – A JSON-serialized list of bot commands to be set as the list of the bot’s commands. At most 100 commands can be specified.

  • scope – A JSON-serialized object, describing scope of users for which the commands are relevant. Defaults to BotCommandScopeDefault.

  • language_code – A two-letter ISO 639-1 language code. If empty, commands will be applied to all users from the given scope, for whose language there are no dedicated commands.

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async set_my_default_administrator_rights(*, rights: ChatAdministratorRights | None = None, for_channels: bool | None = None) bool

Use this method to change the default administrator rights requested by the bot when it’s added as an administrator to groups or channels. These rights will be suggested to users, but they are free to modify the list before adding the bot. Returns True on success.

Parameters:
  • rights – A JSON-serialized object describing new default administrator rights. If not specified, the default administrator rights will be cleared.

  • for_channels – Pass True to change the default administrator rights of the bot in channels. Otherwise, the default administrator rights of the bot for groups and supergroups will be changed.

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async set_my_description(*, description: str | None = None, language_code: str | None = None) bool

Use this method to change the bot’s description, which is shown in the chat with the bot if the chat is empty. Returns True on success.

Parameters:
  • description – New bot description; 0-512 characters. Pass an empty string to remove the dedicated description for the given language.

  • language_code – A two-letter ISO 639-1 language code. If empty, the description will be applied to all users for whose language there is no dedicated description.

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async set_my_name(*, name: str | None = None, language_code: str | None = None) bool

Use this method to change the bot’s name. Returns True on success.

Parameters:
  • name – New bot name; 0-64 characters. Pass an empty string to remove the dedicated name for the given language.

  • language_code – A two-letter ISO 639-1 language code. If empty, the name will be shown to all users for whose language there is no dedicated name.

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async set_my_profile_photo(photo: InputProfilePhotoStatic | InputProfilePhotoAnimated) bool

Changes the profile photo of the bot. Returns True on success.

Parameters:

photo – The new profile photo to set

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async set_my_short_description(*, short_description: str | None = None, language_code: str | None = None) bool

Use this method to change the bot’s short description, which is shown on the bot’s profile page and is sent together with the link when users share the bot. Returns True on success.

Parameters:
  • short_description – New short description for the bot; 0-120 characters. Pass an empty string to remove the dedicated short description for the given language.

  • language_code – A two-letter ISO 639-1 language code. If empty, the short description will be applied to all users for whose language there is no dedicated short description.

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async set_passport_data_errors(user_id: int, errors: List[PassportElementErrorDataField | PassportElementErrorFrontSide | PassportElementErrorReverseSide | PassportElementErrorSelfie | PassportElementErrorFile | PassportElementErrorFiles | PassportElementErrorTranslationFile | PassportElementErrorTranslationFiles | PassportElementErrorUnspecified]) bool

Informs a user that some of the Telegram Passport elements they provided contains errors. The user will not be able to re-submit their Passport to you until the errors are fixed (the contents of the field for which you returned the error must change). Returns True on success. Use this if the data submitted by the user doesn’t satisfy the standards your service requires for any reason. For example, if a birthday date seems invalid, a submitted document is blurry, a scan shows evidence of tampering, etc. Supply some details in the error message to make sure the user knows how to correct the issues.

Parameters:
  • user_id – User identifier

  • errors – A JSON-serialized Array describing the errors

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async set_sticker_emoji_list(sticker: str, emoji_list: List[str]) bool

Use this method to change the list of emoji assigned to a regular or custom emoji sticker. The sticker must belong to a sticker set created by the bot. Returns True on success.

Parameters:
  • sticker – File identifier of the sticker

  • emoji_list – A JSON-serialized list of 1-20 emoji associated with the sticker

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async set_sticker_keywords(sticker: str, keywords: List[str] | None = None) bool

Use this method to change search keywords assigned to a regular or custom emoji sticker. The sticker must belong to a sticker set created by the bot. Returns True on success.

Parameters:
  • sticker – File identifier of the sticker

  • keywords – A JSON-serialized list of 0-20 search keywords for the sticker with total length of up to 64 characters

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async set_sticker_mask_position(sticker: str, mask_position: MaskPosition | None = None) bool

Use this method to change the mask position of a mask sticker. The sticker must belong to a sticker set that was created by the bot. Returns True on success.

Parameters:
  • sticker – File identifier of the sticker

  • mask_position – A JSON-serialized object with the position where the mask should be placed on faces. Omit the parameter to remove the mask position.

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async set_sticker_position_in_set(sticker: str, position: int) bool

Use this method to move a sticker in a set created by the bot to a specific position. Returns True on success.

Parameters:
  • sticker – File identifier of the sticker

  • position – New sticker position in the set, zero-based

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async set_sticker_set_thumbnail(name: str, user_id: int, *, thumbnail: str | bytes | FilePayload | None = None, format: str | None = None) bool

Use this method to set the thumbnail of a regular or mask sticker set. The format of the thumbnail file must match the format of the stickers in the set. Returns True on success.

Parameters:
  • name – Sticker set name

  • user_id – User identifier of the sticker set owner

  • thumbnail – A .WEBP or .PNG image with the thumbnail, must be up to 128 kilobytes in size and have a width and height of exactly 100px, or a .TGS animation with a thumbnail up to 32 kilobytes in size (see https://core.telegram.org/stickers#animation-requirements for animated sticker technical requirements), or a .WEBM video with the thumbnail up to 32 kilobytes in size; see https://core.telegram.org/stickers#video-requirements for video sticker technical requirements. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. More information on Sending Files. Animated and video sticker set thumbnails can’t be uploaded via HTTP URL. If omitted, then the thumbnail is dropped and the first sticker is used as the thumbnail.

  • format – Format of the thumbnail, must be one of ‘static’ for a .WEBP or .PNG image, ‘animated’ for a .TGS animation, or ‘video’ for a .WEBM video

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async set_sticker_set_title(name: str, title: str) bool

Use this method to set the title of a created sticker set. Returns True on success.

Parameters:
  • name – Sticker set name

  • title – Sticker set title, 1-64 characters

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async set_user_emoji_status(user_id: int, *, emoji_status_custom_emoji_id: str | None = None, emoji_status_expiration_date: int | None = None) bool

Changes the emoji status for a given user that previously allowed the bot to manage their emoji status via the Mini App method requestEmojiStatusAccess. Returns True on success.

Parameters:
  • user_id – Unique identifier of the target user

  • emoji_status_custom_emoji_id – Custom emoji identifier of the emoji status to set. Pass an empty string to remove the status.

  • emoji_status_expiration_date – Expiration date of the emoji status, if any

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async set_webhook(url: str, *, max_connections: int | None = None, allowed_updates: List[str] | None = None, drop_pending_updates: bool | None = None, secret_token: str | None = None) bool

Use this method to specify a URL and receive incoming updates via an outgoing webhook. Whenever there is an update for the bot, we will send an HTTPS POST request to the specified URL, containing a JSON-serialized Update. In case of an unsuccessful request (a request with response HTTP status code different from 2XY), we will repeat the request and give up after a reasonable amount of attempts. Returns True on success. If you’d like to make sure that the webhook was set by you, you can specify secret data in the parameter secret_token. If specified, the request will contain a header ‘X-Telegram-Bot-Api-Secret-Token’ with the secret token as content. Notes 1. You will not be able to receive updates using getUpdates for as long as an outgoing webhook is set up. 2. To use a self-signed certificate, you need to upload your public key certificate using certificate parameter. Please upload as InputFile, sending a String will not work. 3. Ports currently supported for webhooks: 443, 80, 88, 8443. If you’re having any trouble setting up webhooks, please check out this amazing guide to webhooks.

Parameters:
  • url – HTTPS URL to send updates to. Use an empty string to remove webhook integration.

  • max_connections – The maximum allowed number of simultaneous HTTPS connections to the webhook for update delivery, 1-100. Defaults to 40. Use lower values to limit the load on your bot’s server, and higher values to increase your bot’s throughput.

  • allowed_updates – A JSON-serialized list of the update types you want your bot to receive. For example, specify [“message”, “edited_channel_post”, “callback_query”] to only receive updates of these types. See Update for a complete list of available update types. Specify an empty list to receive all update types except chat_member, message_reaction, and message_reaction_count (default). If not specified, the previous setting will be used.

Please note that this parameter doesn’t affect updates created before the call to the setWebhook, so unwanted updates may be received for a short period of time.

drop_pending_updates: Pass True to drop all pending updates secret_token: A secret token to be sent in a header ‘X-Telegram-Bot-Api-Secret-Token’ in every webhook request, 1-256 characters. Only characters A-Z, a-z, 0-9, _ and - are allowed. The header is useful to ensure that the request comes from a webhook set by you.

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async stop_message_live_location(*, chat_id: int | str | None = None, message_id: int | None = None, inline_message_id: str | None = None, reply_markup: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply | Mapping[str, object] | None = None) Message | bool

Use this method to stop updating a live location message before live_period expires. On success, if the message is not an inline message, the edited Message is returned, otherwise True is returned.

Parameters:
  • chat_id – Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target bot, supergroup or channel in the format @username.

  • message_id – Required if inline_message_id is not specified. Identifier of the message with live location to stop.

  • inline_message_id – Required if chat_id and message_id are not specified. Identifier of the inline message.

  • reply_markup – A JSON-serialized object for a new inline keyboard

Returns:

Result returned by Telegram on successful execution.

Return type:

Union[Message, bool]

async stop_poll(chat_id: int | str, message_id: int, *, reply_markup: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply | Mapping[str, object] | None = None) Poll

Use this method to stop a poll which was sent by the bot. On success, the stopped Poll is returned.

Parameters:
  • chat_id – Unique identifier for the target chat or username of the target bot, supergroup or channel in the format @username

  • message_id – Identifier of the original message with the poll

  • reply_markup – A JSON-serialized object for a new message inline keyboard

Returns:

Result returned by Telegram on successful execution.

Return type:

Poll

async transfer_business_account_stars(business_connection_id: str, star_count: int) bool

Transfers Telegram Stars from the business account balance to the bot’s balance. Requires the can_transfer_stars business bot right. Returns True on success.

Parameters:
  • business_connection_id – Unique identifier of the business connection

  • star_count – Number of Telegram Stars to transfer; 1-10000

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async transfer_gift(business_connection_id: str, owned_gift_id: str, new_owner_chat_id: int, *, star_count: int | None = None) bool

Transfers an owned unique gift to another user. Requires the can_transfer_and_upgrade_gifts business bot right. Requires can_transfer_stars business bot right if the transfer is paid. Returns True on success.

Parameters:
  • business_connection_id – Unique identifier of the business connection

  • owned_gift_id – Unique identifier of the regular gift that should be transferred

  • new_owner_chat_id – Unique identifier of the chat which will own the gift. The chat must be active in the last 24 hours.

  • star_count – The amount of Telegram Stars that will be paid for the transfer from the business account balance. If positive, then the can_transfer_stars business bot right is required.

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async unban_chat_sender_chat(chat_id: int | str, sender_chat_id: int) bool

Use this method to unban a previously banned channel chat in a supergroup or channel. The bot must be an administrator for this to work and must have the appropriate administrator rights. Returns True on success.

Parameters:
  • chat_id – Unique identifier for the target chat or username of the target channel in the format @username

  • sender_chat_id – Unique identifier of the target sender chat

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async unhide_general_forum_topic(chat_id: int | str) bool

Use this method to unhide the ‘General’ topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. Returns True on success.

Parameters:

chat_id – Unique identifier for the target chat or username of the target supergroup in the format @username

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async unpin_all_forum_topic_messages(chat_id: int | str, message_thread_id: int) bool

Use this method to clear the list of pinned messages in a forum topic in a forum supergroup chat or a private chat with a user. In the case of a supergroup chat the bot must be an administrator in the chat for this to work and must have the can_pin_messages administrator right in the supergroup. Returns True on success.

Parameters:
  • chat_id – Unique identifier for the target chat or username of the target supergroup in the format @username

  • message_thread_id – Unique identifier for the target message thread of the forum topic

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async unpin_all_general_forum_topic_messages(chat_id: int | str) bool

Use this method to clear the list of pinned messages in a General forum topic. The bot must be an administrator in the chat for this to work and must have the can_pin_messages administrator right in the supergroup. Returns True on success.

Parameters:

chat_id – Unique identifier for the target chat or username of the target supergroup in the format @username

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async unpin_chat_message(chat_id: int | str, message_id: int | None = None) bool

Use this method to remove a message from the list of pinned messages in a chat. In private chats and channel direct messages chats, all messages can be unpinned. Conversely, the bot must be an administrator with the ‘can_pin_messages’ right or the ‘can_edit_messages’ right to unpin messages in groups and channels respectively. Returns True on success.

Parameters:
  • chat_id – Unique identifier for the target chat or username of the target channel in the format @username

  • message_id – Identifier of the message to unpin. Required if business_connection_id is specified. If not specified, the most recent pinned message (by sending date) will be unpinned.

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async upgrade_gift(business_connection_id: str, owned_gift_id: str, *, keep_original_details: bool | None = None, star_count: int | None = None) bool

Upgrades a given regular gift to a unique gift. Requires the can_transfer_and_upgrade_gifts business bot right. Additionally requires the can_transfer_stars business bot right if the upgrade is paid. Returns True on success.

Parameters:
  • business_connection_id – Unique identifier of the business connection

  • owned_gift_id – Unique identifier of the regular gift that should be upgraded to a unique one

  • keep_original_details – Pass True to keep the original gift text, sender and receiver in the upgraded gift

  • star_count – The amount of Telegram Stars that will be paid for the upgrade from the business account balance. If gift.prepaid_upgrade_star_count > 0, then pass 0, otherwise, the can_transfer_stars business bot right is required and gift.upgrade_star_count must be passed.

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async upload_sticker_file(user_id: int, sticker: str | bytes | FilePayload, sticker_format: str) File

Use this method to upload a file with a sticker for later use in the createNewStickerSet, addStickerToSet, or replaceStickerInSet methods (the file can be used multiple times). Returns the uploaded File on success.

Parameters:
  • user_id – User identifier of sticker file owner

  • sticker – A file with the sticker in .WEBP, .PNG, .TGS, or .WEBM format. See https://core.telegram.org/stickers for technical requirements. More information on Sending Files

  • sticker_format – Format of the sticker, must be one of ‘static’, ‘animated’, ‘video’

Returns:

Result returned by Telegram on successful execution.

Return type:

File

user_model

alias of User

async verify_chat(chat_id: int | str, *, custom_description: str | None = None) bool

Verifies a chat on behalf of the organization which is represented by the bot. Returns True on success.

Parameters:
  • chat_id – Unique identifier for the target chat or username of the target bot, supergroup or channel in the format @username. Channel direct messages chats can’t be verified.

  • custom_description – Custom description for the verification; 0-70 characters. Must be empty if the organization isn’t allowed to provide a custom verification description.

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

async verify_user(user_id: int, *, custom_description: str | None = None) bool

Verifies a user on behalf of the organization which is represented by the bot. Returns True on success.

Parameters:
  • user_id – Unique identifier of the target user

  • custom_description – Custom description for the verification; 0-70 characters. Must be empty if the organization isn’t allowed to provide a custom verification description.

Returns:

Result returned by Telegram on successful execution.

Return type:

bool

webhook_info_model

alias of WebhookInfo

class peyk.platforms.telegram.TextQuote(text: str, entities: List[MessageEntity] | None = None, position: int | None = None, is_manual: bool | None = None)[source]

Bases: object

This object contains information about the quoted part of a message that is replied to by the given message.

Variables:
  • text (str) – Text of the quoted part of a message that is replied to by the given message

  • position (int | None) – Approximate quote position in the original message in UTF-16 code units as specified by the sender

  • entities (List[peyk.platforms.telegram.types.message_entity.MessageEntity] | None) – Special entities that appear in the quote. Currently, only bold, italic, underline, strikethrough, spoiler, custom_emoji, and date_time entities are kept in quotes.

  • is_manual (bool | None) – True, if the quote was chosen manually by the message sender. Otherwise, the quote was added automatically by the server.

entities: List[MessageEntity] | None = None
classmethod from_dict(data: dict | None) TextQuote | None[source]

Parse a Telegram API mapping into this type.

Parameters:

data – Raw Telegram API mapping, or None.

Returns:

Parsed type instance, or None when data is None.

is_manual: bool | None = None
position: int | None = None
text: str
class peyk.platforms.telegram.TopicIconColor(*values)[source]

Bases: str, Enum

TopicIconColor defines a public API type for peyk.

BLUE = '0x6FB9F0'
YELLOW = '0xFFD67E'
PURPLE = '0xCB86DB'
GREEN = '0x8EEE98'
PINK = '0xFF93B2'
RED = '0xFF6F61'
class peyk.platforms.telegram.TransactionPartnerAffiliateProgram(type: str = 'affiliate_program', commission_per_mille: int = 0)[source]

Bases: object

Describes the affiliate program that issued the affiliate commission received via this transaction.

Variables:
  • type (str) – Type of the transaction partner, always ‘affiliate_program’

  • commission_per_mille (int) – The number of Telegram Stars received by the bot for each 1000 Telegram Stars received by the affiliate program sponsor from referred users

  • sponsor_user – Information about the bot that sponsored the affiliate program

commission_per_mille: int = 0
classmethod from_dict(data: dict | None) TransactionPartnerAffiliateProgram | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

type: str = 'affiliate_program'
class peyk.platforms.telegram.TransactionPartnerChat(type: str = 'chat', chat: Chat | None = None)[source]

Bases: object

Describes a transaction with a chat.

Variables:
  • type (str) – Type of the transaction partner, always ‘chat’

  • chat (peyk.platforms.telegram.types.chat.Chat | None) – Information about the chat

  • gift – The gift sent to the chat by the bot

chat: Chat | None = None
classmethod from_dict(data: dict | None) TransactionPartnerChat | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

type: str = 'chat'
class peyk.platforms.telegram.TransactionPartnerFragment(type: str = 'fragment', withdrawal_state: RevenueWithdrawalStatePending | RevenueWithdrawalStateSucceeded | RevenueWithdrawalStateFailed | None = None)[source]

Bases: object

Describes a withdrawal transaction with Fragment.

Variables:
classmethod from_dict(data: dict | None) TransactionPartnerFragment | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

type: str = 'fragment'
withdrawal_state: RevenueWithdrawalStatePending | RevenueWithdrawalStateSucceeded | RevenueWithdrawalStateFailed | None = None
class peyk.platforms.telegram.TransactionPartnerOther(type: str = 'other')[source]

Bases: object

Describes a transaction with an unknown source or recipient.

Variables:

type (str) – Type of the transaction partner, always ‘other’

classmethod from_dict(data: dict | None) TransactionPartnerOther | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

type: str = 'other'
class peyk.platforms.telegram.TransactionPartnerTelegramAds(type: str = 'telegram_ads')[source]

Bases: object

Describes a withdrawal transaction to the Telegram Ads platform.

Variables:

type (str) – Type of the transaction partner, always ‘telegram_ads’

classmethod from_dict(data: dict | None) TransactionPartnerTelegramAds | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

type: str = 'telegram_ads'
class peyk.platforms.telegram.TransactionPartnerTelegramApi(type: str = 'telegram_api', request_count: int = 0)[source]

Bases: object

Describes a transaction with payment for paid broadcasting.

Variables:
  • type (str) – Type of the transaction partner, always ‘telegram_api’

  • request_count (int) – The number of successful requests that exceeded regular limits and were therefore billed

classmethod from_dict(data: dict | None) TransactionPartnerTelegramApi | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

request_count: int = 0
type: str = 'telegram_api'
class peyk.platforms.telegram.TransactionPartnerType(*values)[source]

Bases: StrEnum

Telegram transaction-partner discriminator values.

USER = 'user'
FRAGMENT = 'fragment'
TELEGRAM_ADS = 'telegram_ads'
OTHER = 'other'
AFFILIATE_PROGRAM = 'affiliate_program'
CHAT = 'chat'
TELEGRAM_API = 'telegram_api'
class peyk.platforms.telegram.TransactionPartnerUser(transaction_type: str, user: User, type: str = 'user', affiliate: AffiliateInfo | None = None, invoice_payload: str | None = None, subscription_period: int | None = None, paid_media: List[PaidMediaLivePhoto | PaidMediaPhoto | PaidMediaPreview | PaidMediaVideo] | None = None, paid_media_payload: str | None = None, gift: Gift | None = None, premium_subscription_duration: int | None = None)[source]

Bases: object

Describes a transaction with a user.

Variables:
affiliate: AffiliateInfo | None = None
classmethod from_dict(data: dict | None) TransactionPartnerUser | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

gift: Gift | None = None
invoice_payload: str | None = None
paid_media: List[PaidMediaLivePhoto | PaidMediaPhoto | PaidMediaPreview | PaidMediaVideo] | None = None
paid_media_payload: str | None = None
premium_subscription_duration: int | None = None
subscription_period: int | None = None
type: str = 'user'
transaction_type: str
user: User
class peyk.platforms.telegram.TransactionPartnerUserTransactionType(*values)[source]

Bases: str, Enum

TransactionPartnerUserTransactionType defines a public API type for peyk.

DEPOSIT = 'deposit'
WITHDRAWAL = 'withdrawal'
class peyk.platforms.telegram.UniqueGift(gift_id: str, base_name: str, name: str, number: int, model: UniqueGiftModel, symbol: UniqueGiftSymbol, backdrop: UniqueGiftBackdrop, is_premium: bool | None = None, is_burned: bool | None = None, is_from_blockchain: bool | None = None, colors: UniqueGiftColors | None = None, publisher_chat: Chat | None = None)[source]

Bases: object

This object describes a unique gift that was upgraded from a regular gift.

Variables:
colors: UniqueGiftColors | None = None
classmethod from_dict(data)
id = None
is_burned: bool | None = None
is_from_blockchain: bool | None = None
is_premium: bool | None = None
publisher_chat: Chat | None = None
title = None
gift_id: str
base_name: str
name: str
number: int
model: UniqueGiftModel
symbol: UniqueGiftSymbol
backdrop: UniqueGiftBackdrop
class peyk.platforms.telegram.UniqueGiftBackdrop(name: str = '', colors: UniqueGiftBackdropColors | None = None, rarity_per_milles: int = 0)[source]

Bases: object

This object describes the backdrop of a unique gift.

Variables:
colors: UniqueGiftBackdropColors | None = None
classmethod from_dict(data: dict | None) UniqueGiftBackdrop | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

name: str = ''
rarity_per_milles: int = 0
class peyk.platforms.telegram.UniqueGiftBackdropColors(center_color: int = 0, edge_color: int = 0, symbol_color: int = 0, text_color: int = 0)[source]

Bases: object

This object describes the colors of the backdrop of a unique gift.

Variables:
  • center_color (int) – The color in the center of the backdrop in RGB format

  • edge_color (int) – The color on the edges of the backdrop in RGB format

  • symbol_color (int) – The color to be applied to the symbol in RGB format

  • text_color (int) – The color for the text on the backdrop in RGB format

center_color: int = 0
edge_color: int = 0
classmethod from_dict(data: dict | None) UniqueGiftBackdropColors | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

symbol_color: int = 0
text_color: int = 0
class peyk.platforms.telegram.UniqueGiftColors(center_color: int = 0, edge_color: int = 0, symbol_color: int = 0, text_color: int = 0)[source]

Bases: object

This object contains information about the color scheme for a user’s name, message replies and link previews based on a unique gift.

Variables:
  • model_custom_emoji_id – Custom emoji identifier of the unique gift’s model

  • symbol_custom_emoji_id – Custom emoji identifier of the unique gift’s symbol

  • light_theme_main_color – Main color used in light themes; RGB format

  • light_theme_other_colors – List of 1-3 additional colors used in light themes; RGB format

  • dark_theme_main_color – Main color used in dark themes; RGB format

  • dark_theme_other_colors – List of 1-3 additional colors used in dark themes; RGB format

center_color: int = 0
edge_color: int = 0
classmethod from_dict(data: dict | None) UniqueGiftColors | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

symbol_color: int = 0
text_color: int = 0
class peyk.platforms.telegram.UniqueGiftInfo(gift: UniqueGift, origin: str, text: str | None = None, entities: List[MessageEntity] | None = None, is_private: bool | None = None, last_resale_currency: str | None = None, last_resale_amount: int | None = None, owned_gift_id: str | None = None, transfer_star_count: int | None = None, next_transfer_date: int | None = None)[source]

Bases: object

Describes a service message about a unique gift that was sent or received.

Variables:
  • gift (peyk.platforms.telegram.types.unique_gift.UniqueGift) – Information about the gift

  • origin (str) – Origin of the gift. Currently, either ‘upgrade’ for gifts upgraded from regular gifts, ‘transfer’ for gifts transferred from other users or channels, ‘resale’ for gifts bought from other users, ‘gifted_upgrade’ for upgrades purchased after the gift was sent, or ‘offer’ for gifts bought or sold through gift purchase offers.

  • last_resale_currency (str | None) – For gifts bought from other users, the currency in which the payment for the gift was done. Currently, one of ‘XTR’ for Telegram Stars or ‘TON’ for TON grams.

  • last_resale_amount (int | None) – For gifts bought from other users, the price paid for the gift in either Telegram Stars or nanograms

  • owned_gift_id (str | None) – Unique identifier of the received gift for the bot; only present for gifts received on behalf of business accounts

  • transfer_star_count (int | None) – Number of Telegram Stars that must be paid to transfer the gift; omitted if the bot cannot transfer the gift

  • next_transfer_date (int | None) – Point in time (Unix timestamp) when the gift can be transferred. If it is in the past, then the gift can be transferred now.

  • last_resale_star_count – For gifts bought from other users, the price paid for the gift

entities: List[MessageEntity] | None = None
classmethod from_dict(data: dict | None) UniqueGiftInfo | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

is_private: bool | None = None
last_resale_amount: int | None = None
last_resale_currency: str | None = None
next_transfer_date: int | None = None
owned_gift_id: str | None = None
text: str | None = None
transfer_star_count: int | None = None
gift: UniqueGift
origin: str
class peyk.platforms.telegram.UniqueGiftModel(name: str = '', rarity_per_milles: int = 0, star_count: int = 0)[source]

Bases: object

This object describes the model of a unique gift.

Variables:
  • name (str) – Name of the model

  • sticker – The sticker that represents the unique gift

  • rarity_per_mille – The number of unique gifts that receive this model for every 1000 gift upgrades. Always 0 for crafted gifts.

  • rarity – Rarity of the model if it is a crafted model. Currently, can be ‘uncommon’, ‘rare’, ‘epic’, or ‘legendary’.

classmethod from_dict(data: dict | None) UniqueGiftModel | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

name: str = ''
rarity_per_milles: int = 0
star_count: int = 0
class peyk.platforms.telegram.UniqueGiftSymbol(name: str = '', rarity_per_milles: int = 0, star_count: int = 0)[source]

Bases: object

This object describes the symbol shown on the pattern of a unique gift.

Variables:
  • name (str) – Name of the symbol

  • sticker – The sticker that represents the unique gift

  • rarity_per_mille – The number of unique gifts that receive this model for every 1000 gifts upgraded

classmethod from_dict(data: dict | None) UniqueGiftSymbol | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

name: str = ''
rarity_per_milles: int = 0
star_count: int = 0
class peyk.platforms.telegram.Update(update_id: int, message: Message | None = None, edited_message: Message | None = None, channel_post: Message | None = None, edited_channel_post: Message | None = None, business_connection: object | None = None, business_message: Message | None = None, edited_business_message: Message | None = None, deleted_business_messages: object | None = None, message_reaction: object | None = None, message_reaction_count: object | None = None, inline_query: InlineQuery | None = None, chosen_inline_result: ChosenInlineResult | None = None, callback_query: CallbackQuery | None = None, shipping_query: object | None = None, pre_checkout_query: object | None = None, purchased_paid_media: object | None = None, poll: object | None = None, poll_answer: object | None = None, my_chat_member: ChatMemberUpdated | None = None, chat_member: ChatMemberUpdated | None = None, chat_join_request: ChatJoinRequest | None = None, chat_boost: object | None = None, removed_chat_boost: object | None = None)[source]

Bases: object

This object represents an incoming update. At most one of the optional fields can be present in any given update.

Variables:
  • update_id (int) – The update’s unique identifier. Update identifiers start from a certain positive number and increase sequentially. This identifier becomes especially handy if you’re using webhooks, since it allows you to ignore repeated updates or to restore the correct update sequence, should they get out of order. If there are no new updates for at least a week, then identifier of the next update will be chosen randomly instead of sequentially.

  • message (peyk.platforms.telegram.types.message.Message | None) – New incoming message of any kind - text, photo, sticker, etc.

  • edited_message (peyk.platforms.telegram.types.message.Message | None) – New version of a message that is known to the bot and was edited. This update may at times be triggered by changes to message fields that are either unavailable or not actively used by your bot.

  • channel_post (peyk.platforms.telegram.types.message.Message | None) – New incoming channel post of any kind - text, photo, sticker, etc.

  • edited_channel_post (peyk.platforms.telegram.types.message.Message | None) – New version of a channel post that is known to the bot and was edited. This update may at times be triggered by changes to message fields that are either unavailable or not actively used by your bot.

  • business_connection (object | None) – The bot was connected to or disconnected from a business account, or a user edited an existing connection with the bot

  • business_message (peyk.platforms.telegram.types.message.Message | None) – New message from a connected business account

  • edited_business_message (peyk.platforms.telegram.types.message.Message | None) – New version of a message from a connected business account

  • deleted_business_messages (object | None) – Messages were deleted from a connected business account

  • guest_message – New guest message. The bot can use the field Message.guest_query_id and the method answerGuestQuery to send a message in response.

  • message_reaction (object | None) – A reaction to a message was changed by a user. The bot must be an administrator in the chat and must explicitly specify “message_reaction” in the list of allowed_updates to receive these updates. The update isn’t received for reactions set by bots.

  • message_reaction_count (object | None) – Reactions to a message with anonymous reactions were changed. The bot must be an administrator in the chat and must explicitly specify “message_reaction_count” in the list of allowed_updates to receive these updates. The updates are grouped and can be sent with delay up to a few minutes.

  • inline_query (peyk.platforms.telegram.types.inline_query.InlineQuery | None) – New incoming inline query

  • chosen_inline_result (peyk.platforms.telegram.types.chosen_inline_result.ChosenInlineResult | None) – The result of an inline query that was chosen by a user and sent to their chat partner. Please see our documentation on the feedback collecting for details on how to enable these updates for your bot.

  • callback_query (peyk.platforms.telegram.types.callback_query.CallbackQuery | None) – New incoming callback query

  • shipping_query (object | None) – New incoming shipping query. Only for invoices with flexible price.

  • pre_checkout_query (object | None) – New incoming pre-checkout query. Contains full information about checkout.

  • purchased_paid_media (object | None) – A user purchased paid media with a non-empty payload sent by the bot in a non-channel chat

  • poll (object | None) – New poll state. Bots receive only updates about manually stopped polls and polls, which are sent by the bot.

  • poll_answer (object | None) – A user changed their answer in a non-anonymous poll. Bots receive new votes only in polls that were sent by the bot itself.

  • my_chat_member (peyk.platforms.telegram.types.chat_member_updated.ChatMemberUpdated | None) – The bot’s chat member status was updated in a chat. For private chats, this update is received only when the bot is blocked or unblocked by the user.

  • chat_member (peyk.platforms.telegram.types.chat_member_updated.ChatMemberUpdated | None) – A chat member’s status was updated in a chat. The bot must be an administrator in the chat and must explicitly specify “chat_member” in the list of allowed_updates to receive these updates.

  • chat_join_request (peyk.platforms.telegram.types.chat_join_request.ChatJoinRequest | None) – A request to join the chat has been sent. The bot must have the can_invite_users administrator right in the chat to receive these updates.

  • chat_boost (object | None) – A chat boost was added or changed. The bot must be an administrator in the chat to receive these updates.

  • removed_chat_boost (object | None) – A boost was removed from a chat. The bot must be an administrator in the chat to receive these updates.

  • managed_bot – A new bot was created to be managed by the bot, or token or owner of a managed bot was changed

  • subscription – User payment subscription has changed

business_connection: object | None = None
business_message: Message | None = None
callback_query: CallbackQuery | None = None
channel_post: Message | None = None
chat_boost: object | None = None
chat_join_request: ChatJoinRequest | None = None
chat_member: ChatMemberUpdated | None = None
chosen_inline_result: ChosenInlineResult | None = None
deleted_business_messages: object | None = None
edited_business_message: Message | None = None
edited_channel_post: Message | None = None
edited_message: Message | None = None
classmethod from_dict(data)
guest_message = None
inline_query: InlineQuery | None = None
classmethod list_from_result(data: List[dict] | None) List[Update][source]

Provides the list from result operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

managed_bot = None
message: Message | None = None
message_reaction: object | None = None
message_reaction_count: object | None = None
my_chat_member: ChatMemberUpdated | None = None
poll: object | None = None
poll_answer: object | None = None
pre_checkout_query: object | None = None
purchased_paid_media: object | None = None
removed_chat_boost: object | None = None
shipping_query: object | None = None
stopped_message_generation = None
subscription = None
update_id: int
class peyk.platforms.telegram.UpdateType(*values)[source]

Bases: str, Enum

UpdateType defines a public API type for peyk.

MESSAGE = 'message'
EDITED_MESSAGE = 'edited_message'
CHANNEL_POST = 'channel_post'
EDITED_CHANNEL_POST = 'edited_channel_post'
BUSINESS_CONNECTION = 'business_connection'
BUSINESS_MESSAGE = 'business_message'
EDITED_BUSINESS_MESSAGE = 'edited_business_message'
DELETED_BUSINESS_MESSAGES = 'deleted_business_messages'
MESSAGE_REACTION = 'message_reaction'
MESSAGE_REACTION_COUNT = 'message_reaction_count'
INLINE_QUERY = 'inline_query'
CHOSEN_INLINE_RESULT = 'chosen_inline_result'
CALLBACK_QUERY = 'callback_query'
SHIPPING_QUERY = 'shipping_query'
PRE_CHECKOUT_QUERY = 'pre_checkout_query'
PURCHASED_PAID_MEDIA = 'purchased_paid_media'
POLL = 'poll'
POLL_ANSWER = 'poll_answer'
MY_CHAT_MEMBER = 'my_chat_member'
CHAT_MEMBER = 'chat_member'
CHAT_JOIN_REQUEST = 'chat_join_request'
CHAT_BOOST = 'chat_boost'
REMOVED_CHAT_BOOST = 'removed_chat_boost'
MANAGED_BOT = 'managed_bot'
SUBSCRIPTION = 'subscription'
STOPPED_MESSAGE_GENERATION = 'stopped_message_generation'
class peyk.platforms.telegram.User(id: int, is_bot: bool, first_name: str, last_name: str | None = None, username: str | None = None, language_code: str | None = None, is_premium: bool | None = None, added_to_attachment_menu: bool | None = None, can_join_groups: bool | None = None, can_read_all_group_messages: bool | None = None, supports_inline_queries: bool | None = None, can_connect_to_business: bool | None = None, has_main_web_app: bool | None = None)[source]

Bases: object

This object represents a Telegram user or bot.

Variables:
  • id (int) – Unique identifier for this user or bot. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a 64-bit integer or double-precision float type are safe for storing this identifier.

  • is_bot (bool) – True, if this user is a bot

  • first_name (str) – User’s or bot’s first name

  • last_name (str | None) – User’s or bot’s last name

  • username (str | None) – User’s or bot’s username

  • language_code (str | None) – IETF language tag of the user’s language

  • is_premium (bool | None) – True, if this user is a Telegram Premium user

  • added_to_attachment_menu (bool | None) – True, if this user added the bot to the attachment menu

  • can_join_groups (bool | None) – True, if the bot can be invited to groups. Returned only in getMe.

  • can_read_all_group_messages (bool | None) – True, if privacy mode is disabled for the bot. Returned only in getMe.

  • supports_guest_queries – True, if the bot supports guest queries from chats it is not a member of. Returned only in getMe.

  • supports_inline_queries (bool | None) – True, if the bot supports inline queries. Returned only in getMe.

  • can_connect_to_business (bool | None) – True, if the bot can be connected to a user account to manage it. Returned only in getMe.

  • has_main_web_app (bool | None) – True, if the bot has a main Web App. Returned only in getMe.

  • has_topics_enabled – True, if the bot has forum topic mode enabled in private chats. Returned only in getMe.

  • allows_users_to_create_topics – True, if the bot allows users to create and delete topics in private chats. Returned only in getMe.

  • can_manage_bots – True, if other bots can be created to be controlled by the bot. Returned only in getMe.

  • supports_join_request_queries – True, if the bot supports join request queries and can be assigned to process them. Returned only in getMe.

added_to_attachment_menu: bool | None = None
can_connect_to_business: bool | None = None
can_join_groups: bool | None = None
can_read_all_group_messages: bool | None = None
classmethod from_dict(data)
has_main_web_app: bool | None = None
is_premium: bool | None = None
language_code: str | None = None
last_name: str | None = None
supports_guest_queries = None
supports_inline_queries: bool | None = None
supports_join_request_queries = None
username: str | None = None
id: int
is_bot: bool
first_name: str
class peyk.platforms.telegram.UserChatBoosts(boosts: List[ChatBoost])[source]

Bases: object

This object represents a list of boosts added to a chat by a user.

Variables:

boosts (List[peyk.platforms.telegram.types.chat_boost.ChatBoost]) – The list of boosts added to the chat by the user

classmethod from_dict(data: dict | None) UserChatBoosts | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

boosts: List[ChatBoost]
class peyk.platforms.telegram.UserProfileAudios(total_count: int = 0, audios: List[Audio] | None = None)[source]

Bases: object

This object represents the audios displayed on a user’s profile.

Variables:
audios: List[Audio] | None = None
classmethod from_dict(data: dict | None) UserProfileAudios | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

total_count: int = 0
class peyk.platforms.telegram.UserProfilePhotos(total_count: int = 0, photos: List[List[PhotoSize]] | None = None)[source]

Bases: object

This object represent a user’s profile pictures.

Variables:
classmethod from_dict(data: dict | None) UserProfilePhotos | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

photos: List[List[PhotoSize]] | None = None
total_count: int = 0
class peyk.platforms.telegram.UserRating(rating: int = 0)[source]

Bases: object

This object describes the rating of a user based on their Telegram Star spendings.

Variables:
  • level – Current level of the user, indicating their reliability when purchasing digital goods and services. A higher level suggests a more trustworthy customer; a negative level is likely reason for concern.

  • rating (int) – Numerical value of the user’s rating; the higher the rating, the better

  • current_level_rating – The rating value required to get the current level

  • next_level_rating – The rating value required to get to the next level; omitted if the maximum level was reached

classmethod from_dict(data: dict | None) UserRating | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

rating: int = 0
class peyk.platforms.telegram.UsersShared(request_id: int = 0, users: List[SharedUser] | None = None)[source]

Bases: object

This object contains information about the users whose identifiers were shared with the bot using a KeyboardButtonRequestUsers button.

Variables:
  • request_id (int) – Identifier of the request

  • users (List[peyk.platforms.telegram.types.shared_user.SharedUser] | None) – Information about users shared with the bot

  • user_ids – Identifiers of the shared users. These numbers may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting them. But they have at most 52 significant bits, so 64-bit integers or double-precision float types are safe for storing these identifiers. The bot may not have access to the users and could be unable to use these identifiers, unless the users are already known to the bot by some other means.

classmethod from_dict(data: dict | None) UsersShared | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

request_id: int = 0
users: List[SharedUser] | None = None
class peyk.platforms.telegram.Venue(location: Location, title: str, address: str, foursquare_id: str | None = None, foursquare_type: str | None = None, google_place_id: str | None = None, google_place_type: str | None = None)[source]

Bases: object

This object represents a venue.

Variables:
  • location (peyk.platforms.telegram.types.location.Location) – Venue location. Can’t be a live location.

  • title (str) – Name of the venue

  • address (str) – Address of the venue

  • foursquare_id (str | None) – Foursquare identifier of the venue

  • foursquare_type (str | None) – Foursquare type of the venue. (For example, ‘arts_entertainment/default’, ‘arts_entertainment/aquarium’ or ‘food/icecream’.)

  • google_place_id (str | None) – Google Places identifier of the venue

  • google_place_type (str | None) – Google Places type of the venue. (See supported types.)

foursquare_id: str | None = None
foursquare_type: str | None = None
classmethod from_dict(data: dict | None) Venue | None[source]

Parse a Telegram API mapping into this type.

Parameters:

data – Raw Telegram API mapping, or None.

Returns:

Parsed type instance, or None when data is None.

google_place_id: str | None = None
google_place_type: str | None = None
location: Location
title: str
address: str
class peyk.platforms.telegram.Video(file_id: str, file_unique_id: str, width: int, height: int, duration: int, thumbnail: PhotoSize | None = None, cover: List[PhotoSize] | None = None, start_timestamp: int | None = None, qualities: object | None = None, file_name: str | None = None, mime_type: str | None = None, file_size: int | None = None)[source]

Bases: object

This object represents a video file.

Variables:
  • file_id (str) – Identifier for this file, which can be used to download or reuse the file

  • file_unique_id (str) – Unique identifier for this file, which is supposed to be the same over time and for different bots. Can’t be used to download or reuse the file.

  • width (int) – Video width as defined by the sender

  • height (int) – Video height as defined by the sender

  • duration (int) – Duration of the video in seconds as defined by the sender

  • thumbnail (peyk.platforms.telegram.types.photo_size.PhotoSize | None) – Video thumbnail

  • cover (List[peyk.platforms.telegram.types.photo_size.PhotoSize] | None) – Available sizes of the cover of the video in the message

  • start_timestamp (int | None) – Timestamp in seconds from which the video will play in the message

  • qualities (object | None) – List of available qualities of the video

  • file_name (str | None) – Original filename as defined by the sender

  • mime_type (str | None) – MIME type of the file as defined by the sender

  • file_size (int | None) – File size in bytes. It can be bigger than 2^31 and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this value.

cover: List[PhotoSize] | None = None
file_name: str | None = None
file_size: int | None = None
classmethod from_dict(data: dict | None) Video | None[source]

Parse a Telegram API mapping into this type.

Parameters:

data – Raw Telegram API mapping, or None.

Returns:

Parsed type instance, or None when data is None.

mime_type: str | None = None
qualities: object | None = None
start_timestamp: int | None = None
thumbnail: PhotoSize | None = None
file_id: str
file_unique_id: str
width: int
height: int
duration: int
class peyk.platforms.telegram.VideoChatEnded(duration: int = 0)[source]

Bases: object

This object represents a service message about a video chat ended in the chat.

Variables:

duration (int) – Video chat duration in seconds

duration: int = 0
classmethod from_dict(data: dict | None) VideoChatEnded | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

class peyk.platforms.telegram.VideoChatParticipantsInvited(users: List[User] | None = None)[source]

Bases: object

This object represents a service message about new members invited to a video chat.

Variables:

users (List[peyk.platforms.telegram.types.user.User] | None) – New members that were invited to the video chat

classmethod from_dict(data: dict | None) VideoChatParticipantsInvited | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

users: List[User] | None = None
class peyk.platforms.telegram.VideoChatScheduled(start_date: int = 0)[source]

Bases: object

This object represents a service message about a video chat scheduled in the chat.

Variables:

start_date (int) – Point in time (Unix timestamp) when the video chat is supposed to be started by a chat administrator

classmethod from_dict(data: dict | None) VideoChatScheduled | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

start_date: int = 0
class peyk.platforms.telegram.VideoChatStarted[source]

Bases: object

Video chat started.

classmethod from_dict(data: dict | None) VideoChatStarted | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

class peyk.platforms.telegram.VideoNote(file_id: str, file_unique_id: str, length: int, duration: int, thumbnail: PhotoSize | None = None, file_size: int | None = None)[source]

Bases: object

This object represents a video message (available in Telegram apps as of v.4.0).

Variables:
  • file_id (str) – Identifier for this file, which can be used to download or reuse the file

  • file_unique_id (str) – Unique identifier for this file, which is supposed to be the same over time and for different bots. Can’t be used to download or reuse the file.

  • length (int) – Video width and height (diameter of the video message) as defined by the sender

  • duration (int) – Duration of the video in seconds as defined by the sender

  • thumbnail (peyk.platforms.telegram.types.photo_size.PhotoSize | None) – Video thumbnail

  • file_size (int | None) – File size in bytes

file_size: int | None = None
classmethod from_dict(data: dict | None) VideoNote | None[source]

Parse a Telegram API mapping into this type.

Parameters:

data – Raw Telegram API mapping, or None.

Returns:

Parsed type instance, or None when data is None.

thumbnail: PhotoSize | None = None
file_id: str
file_unique_id: str
length: int
duration: int
class peyk.platforms.telegram.VideoQuality(type: str, width: int | None = None, height: int | None = None, duration: int | None = None)[source]

Bases: object

This object represents a video file of a specific quality.

Variables:
  • file_id – Identifier for this file, which can be used to download or reuse the file

  • file_unique_id – Unique identifier for this file, which is supposed to be the same over time and for different bots. Can’t be used to download or reuse the file.

  • width (int | None) – Video width

  • height (int | None) – Video height

  • codec – Codec that was used to encode the video, for example, ‘h264’, ‘h265’, or ‘av01’

  • file_size – File size in bytes. It can be bigger than 2^31 and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this value.

duration: int | None = None
classmethod from_dict(data: dict | None) VideoQuality | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

height: int | None = None
width: int | None = None
type: str
class peyk.platforms.telegram.Voice(file_id: str, file_unique_id: str, duration: int, mime_type: str | None = None, file_size: int | None = None)[source]

Bases: object

This object represents a voice note.

Variables:
  • file_id (str) – Identifier for this file, which can be used to download or reuse the file

  • file_unique_id (str) – Unique identifier for this file, which is supposed to be the same over time and for different bots. Can’t be used to download or reuse the file.

  • duration (int) – Duration of the audio in seconds as defined by the sender

  • mime_type (str | None) – MIME type of the file as defined by the sender

  • file_size (int | None) – File size in bytes. It can be bigger than 2^31 and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this value.

file_size: int | None = None
classmethod from_dict(data: dict | None) Voice | None[source]

Parse a Telegram API mapping into this type.

Parameters:

data – Raw Telegram API mapping, or None.

Returns:

Parsed type instance, or None when data is None.

mime_type: str | None = None
file_id: str
file_unique_id: str
duration: int
class peyk.platforms.telegram.WebAppData(data: str, button_text: str)[source]

Bases: object

Describes data sent from a Web App to the bot.

Variables:
  • data (str) – The data. Be aware that a bad client can send arbitrary data in this field.

  • button_text (str) – Text of the web_app keyboard button from which the Web App was opened. Be aware that a bad client can send arbitrary data in this field.

classmethod from_dict(data)
data: str
button_text: str
class peyk.platforms.telegram.WebAppInfo(url: str = '')[source]

Bases: object

Describes a Web App.

Variables:

url (str) – An HTTPS URL of a Web App to be opened with additional data as specified in Initializing Web Apps

classmethod from_dict(data: dict | None) WebAppInfo | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

to_dict() Dict[str, object][source]

Provides the to dict operation for the Telegram integration.

Returns:

Result produced by the operation.

url: str = ''
class peyk.platforms.telegram.WebhookInfo(url: str, has_custom_certificate: bool | None = None, pending_update_count: int | None = None, ip_address: str | None = None, last_error_date: int | None = None, last_error_message: str | None = None, last_synchronization_error_date: int | None = None, max_connections: int | None = None, allowed_updates: List[str] | None = None)[source]

Bases: object

Describes the current status of a webhook.

Variables:
  • url (str) – Webhook URL, may be empty if webhook is not set up

  • has_custom_certificate (bool | None) – True, if a custom certificate was provided for webhook certificate checks

  • pending_update_count (int | None) – Number of updates awaiting delivery

  • ip_address (str | None) – Currently used webhook IP address

  • last_error_date (int | None) – Unix time for the most recent error that happened when trying to deliver an update via webhook

  • last_error_message (str | None) – Error message in human-readable format for the most recent error that happened when trying to deliver an update via webhook

  • last_synchronization_error_date (int | None) – Unix time of the most recent error that happened when trying to synchronize available updates with Telegram datacenters

  • max_connections (int | None) – The maximum allowed number of simultaneous HTTPS connections to the webhook for update delivery

  • allowed_updates (List[str] | None) – A list of update types the bot is subscribed to. Defaults to all update types except chat_member, message_reaction, and message_reaction_count.

allowed_updates: List[str] | None = None
classmethod from_dict(data: dict | None) WebhookInfo | None[source]

Parse a Telegram API mapping into this type.

Parameters:

data – Raw Telegram API mapping, or None.

Returns:

Parsed type instance, or None when data is None.

has_custom_certificate: bool | None = None
ip_address: str | None = None
last_error_date: int | None = None
last_error_message: str | None = None
last_synchronization_error_date: int | None = None
max_connections: int | None = None
pending_update_count: int | None = None
url: str
class peyk.platforms.telegram.WriteAccessAllowed(from_request: bool | None = None, web_app_name: str | None = None, from_attachment_menu: bool | None = None)[source]

Bases: object

This object represents a service message about a user allowing a bot to write messages after adding it to the attachment menu, launching a Web App from a link, or accepting an explicit request from a Web App sent by the method requestWriteAccess.

Variables:
  • from_request (bool | None) – True, if the access was granted after the user accepted an explicit request from a Web App sent by the method requestWriteAccess

  • web_app_name (str | None) – Name of the Web App, if the access was granted when the Web App was launched from a link

  • from_attachment_menu (bool | None) – True, if the access was granted when the bot was added to the attachment or side menu

from_attachment_menu: bool | None = None
classmethod from_dict(data: dict | None) WriteAccessAllowed | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

from_request: bool | None = None
web_app_name: str | None = None
peyk.platforms.telegram.build_inline_keyboard_button(text: str, callback_data: str) InlineKeyboardButton

Provides the build inline keyboard button operation for the Telegram integration.

Parameters:
  • text – Text supplied to the operation.

  • callback_data – Value used by this operation.

Returns:

Result produced by the operation.

peyk.platforms.telegram.parse_background_fill(data: dict | None) BackgroundFillSolid | BackgroundFillGradient | BackgroundFillFreeformGradient | None[source]

Provides the parse background fill operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

peyk.platforms.telegram.parse_background_type(data: dict | None) BackgroundTypeFill | BackgroundTypeWallpaper | BackgroundTypePattern | BackgroundTypeChatTheme | None[source]

Provides the parse background type operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

peyk.platforms.telegram.parse_bot_command_scope(data: dict | None) BotCommandScopeDefault | BotCommandScopeAllPrivateChats | BotCommandScopeAllGroupChats | BotCommandScopeAllChatAdministrators | BotCommandScopeChat | BotCommandScopeChatAdministrators | BotCommandScopeChatMember | None[source]

Provides the parse bot command scope operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

peyk.platforms.telegram.parse_chat_boost_source(data: dict | None) ChatBoostSource | None[source]

Provides the parse chat boost source operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

peyk.platforms.telegram.parse_chat_member(data: dict | None) ChatMemberOwner | ChatMemberAdministrator | ChatMemberMember | ChatMemberRestricted | ChatMemberLeft | ChatMemberBanned | None[source]

Provides the parse chat member operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

peyk.platforms.telegram.parse_input_media(data: dict | None) InputMediaAnimation | InputMediaAudio | InputMediaDocument | InputMediaLivePhoto | InputMediaPhoto | InputMediaVideo | None[source]

Provides the parse input media operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

peyk.platforms.telegram.parse_input_paid_media(data: dict | None) InputPaidMediaLivePhoto | InputPaidMediaPhoto | InputPaidMediaVideo | None[source]

Provides the parse input paid media operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

peyk.platforms.telegram.parse_input_story_content(data: dict | None) InputStoryContentPhoto | InputStoryContentVideo | None[source]

Provides the parse input story content operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

peyk.platforms.telegram.parse_maybe_inaccessible_message(data: dict | None)[source]

Provides the parse maybe inaccessible message operation for the Telegram integration.

Parameters:

data – Value used by this operation.

peyk.platforms.telegram.parse_menu_button(data: dict | None) MenuButtonCommands | MenuButtonWebApp | MenuButtonDefault | None[source]

Provides the parse menu button operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

peyk.platforms.telegram.parse_message_origin(data: dict | None) MessageOriginUser | MessageOriginHiddenUser | MessageOriginChat | MessageOriginChannel | None[source]

Provides the parse message origin operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

peyk.platforms.telegram.parse_owned_gift(data: dict | None) OwnedGiftRegular | OwnedGiftUnique | None[source]

Provides the parse owned gift operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

peyk.platforms.telegram.parse_paid_media(data: dict | None) PaidMediaLivePhoto | PaidMediaPhoto | PaidMediaPreview | PaidMediaVideo | None[source]

Provides the parse paid media operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

peyk.platforms.telegram.parse_passport_element_error(data: dict | None) PassportElementErrorDataField | PassportElementErrorFrontSide | PassportElementErrorReverseSide | PassportElementErrorSelfie | PassportElementErrorFile | PassportElementErrorFiles | PassportElementErrorTranslationFile | PassportElementErrorTranslationFiles | PassportElementErrorUnspecified | None[source]

Provides the parse passport element error operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

peyk.platforms.telegram.parse_reaction_type(data: dict | None) ReactionTypeEmoji | ReactionTypeCustomEmoji | ReactionTypePaid | None[source]

Provides the parse reaction type operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

peyk.platforms.telegram.parse_revenue_withdrawal_state(data: dict | None) RevenueWithdrawalStatePending | RevenueWithdrawalStateSucceeded | RevenueWithdrawalStateFailed | None[source]

Provides the parse revenue withdrawal state operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

peyk.platforms.telegram.parse_transaction_partner(data: dict | None) TransactionPartnerUser | TransactionPartnerFragment | TransactionPartnerTelegramAds | TransactionPartnerOther | TransactionPartnerAffiliateProgram | TransactionPartnerChat | TransactionPartnerTelegramApi | None[source]

Provides the parse transaction partner operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

peyk.platforms.telegram.serialize_bot_command_scope(value: BotCommandScopeDefault | BotCommandScopeAllPrivateChats | BotCommandScopeAllGroupChats | BotCommandScopeAllChatAdministrators | BotCommandScopeChat | BotCommandScopeChatAdministrators | BotCommandScopeChatMember | Mapping[str, object]) Dict[str, object][source]

Provides the serialize bot command scope operation for the Telegram integration.

Parameters:

value – Value used by this operation.

Returns:

Result produced by the operation.

peyk.platforms.telegram.serialize_inline_result(value: InlineQueryResultArticle | InlineQueryResultPhoto | InlineQueryResultGif | InlineQueryResultMpeg4Gif | InlineQueryResultVideo | InlineQueryResultAudio | InlineQueryResultVoice | InlineQueryResultDocument | InlineQueryResultLocation | InlineQueryResultVenue | InlineQueryResultContact | InlineQueryResultGame | InlineQueryResultCachedPhoto | InlineQueryResultCachedGif | InlineQueryResultCachedMpeg4Gif | InlineQueryResultCachedSticker | InlineQueryResultCachedDocument | InlineQueryResultCachedVideo | InlineQueryResultCachedVoice | InlineQueryResultCachedAudio | Mapping[str, object]) Dict[str, object][source]

Provides the serialize inline result operation for the Telegram integration.

Parameters:

value – Value used by this operation.

Returns:

Result produced by the operation.

peyk.platforms.telegram.serialize_input_message_content(value: InputTextMessageContent | InputLocationMessageContent | InputVenueMessageContent | InputContactMessageContent | InputInvoiceMessageContent | Mapping[str, object]) Dict[str, object][source]

Provides the serialize input message content operation for the Telegram integration.

Parameters:

value – Value used by this operation.

Returns:

Result produced by the operation.

peyk.platforms.telegram.serialize_menu_button(value: MenuButtonCommands | MenuButtonWebApp | MenuButtonDefault | Mapping[str, object]) Dict[str, object][source]

Provides the serialize menu button operation for the Telegram integration.

Parameters:

value – Value used by this operation.

Returns:

Result produced by the operation.

peyk.platforms.telegram.serialize_reply_markup(value: InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply | Mapping[str, object]) Dict[str, object][source]

Provides the serialize reply markup operation for the Telegram integration.

Parameters:

value – Value used by this operation.

Returns:

Result produced by the operation.

peyk.platforms.telegram.validate_callback_data(data: str) None[source]

Provides the validate callback data operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Shared client methods

Bale and Telegram inherit a small set of proven platform-neutral request methods. They are documented here as part of each platform reference so the complete public client surface is discoverable from either page.

Shared transport-facing mechanics for Telegram-shaped bot clients.

This module contains the shared request/retry/envelope mechanics plus the M1-confirmed A-level public methods migrated in M3 and M5. M1 found that most same-named public methods remain semantically different, so only identical-logic methods are promoted here.

class peyk.platforms._telegram_like.base_client.TelegramLikeClient(token: str, session: Session | None = None, *, retry_policy: RetryPolicy | None = None, logger: object = None, base_url: str | None = None)[source]

Bases: Generic[UserT, WebhookInfoT, FileT, ChatT, ChatMemberT]

Base for Bale/Telegram clients sharing request mechanics.

Only behavior proven identical by the architecture audit belongs here; platform-specific methods remain on their concrete clients.

base_url: str
max_callback_data_bytes: int = 64
user_model: type[_FromDictModel[UserT]]
webhook_info_model: type[_FromDictModel[WebhookInfoT]]
file_model: type[_FromDictModel[FileT]]
chat_model: type[_FromDictModel[ChatT]]
chat_member_parser: Callable[[dict | None], ChatMemberT | None]
chat_member_count_method: str
async close() None[source]

Close only a transport session created by this client.

Returns:

The operation result (None).

async get_me() UserT[source]

Return the authenticated bot user using the platform’s user model.

Returns:

The concrete user model configured by the subclass.

async get_webhook_info() WebhookInfoT[source]

Return webhook status using the platform’s webhook-info model.

Returns:

The concrete webhook-info model configured by the subclass.

async get_file(file_id: str) FileT[source]

Fetch the platform’s file descriptor for file_id.

Parameters:

file_id – Platform-specific file identifier.

Returns:

The concrete file model configured by the subclass.

async delete_message(chat_id: int | str, message_id: int) bool[source]

Removes message through the shared Telegram-like API.

Parameters:
  • chat_id – Identifier of the target chat.

  • message_id – Identifier of the target message.

Returns:

Result produced by the shared Telegram-like operation.

async unban_chat_member(chat_id: int | str, user_id: int, *, only_if_banned: bool | None = None) bool[source]

Performs the unban chat member operation for the shared Telegram-like client.

Parameters:
  • chat_id – Identifier of the target chat.

  • user_id – Identifier of the target user.

  • only_if_banned – Value used by this operation.

Returns:

Result produced by the shared Telegram-like operation.

async unpin_all_chat_messages(chat_id: int | str) bool[source]

Performs the unpin all chat messages operation for the shared Telegram-like client.

Parameters:

chat_id – Identifier of the target chat.

Returns:

Result produced by the shared Telegram-like operation.

async leave_chat(chat_id: int | str) bool[source]

Performs the leave chat operation for the shared Telegram-like client.

Parameters:

chat_id – Identifier of the target chat.

Returns:

Result produced by the shared Telegram-like operation.

async get_chat(chat_id: int | str) ChatT[source]

Return chat information using the platform’s chat model.

Parameters:

chat_id – Integer or string identifier accepted by the platform.

Returns:

The concrete chat model configured by the subclass.

async get_chat_member(chat_id: int | str, user_id: int) ChatMemberT[source]

Return a member record parsed by the concrete platform adapter.

Parameters:
  • chat_id – Integer or string chat identifier.

  • user_id – User identifier whose membership should be fetched.

Returns:

The concrete chat-member type configured by the subclass.

async set_chat_title(chat_id: int | str, title: str) bool[source]

Updates chat title through the shared Telegram-like API.

Parameters:
  • chat_id – Identifier of the target chat.

  • title – Title to apply to the target resource.

Returns:

Result produced by the shared Telegram-like operation.

async delete_chat_photo(chat_id: int | str) bool[source]

Removes chat photo through the shared Telegram-like API.

Parameters:

chat_id – Identifier of the target chat.

Returns:

Result produced by the shared Telegram-like operation.

classmethod validate_callback_data(data: str) None[source]

Performs the validate callback data operation for the shared Telegram-like client.

Parameters:

data – Value used by this operation.

Types and methods

peyk.platforms.telegram.types

One-file-per-type Telegram Bot API model package.

peyk.platforms.telegram.methods

One-file-per-method Telegram Bot API method package.

Supporting modules

Telegram application-level API errors.

Every Telegram Bot API response is a JSON envelope with an ok flag. On ok: false Telegram still returns a plain HTTP 200 – the failure is encoded in the JSON body (description + error_code + optional parameters), not in the HTTP status line. That makes it an application-level failure, distinct from peyk.transport’s transport-level errors (HTTPStatusError, NetworkError, TimeoutError_, RateLimitedError), which are raised from transport-level facts only (connection failures, timeouts, non-2xx status codes).

TelegramAPIError subclasses peyk.transport.errors.TransportError so it can still be caught alongside transport errors by callers that want a single “something about this Telegram call failed” catch-all – but it is deliberately not included in peyk.transport.retry.DEFAULT_RETRYABLE, and TelegramClient never passes it through run_with_retry in the first place (see client.py): a run_with_retry-wrapped call to Session.request() already returns successfully (HTTP 200, valid JSON) before TelegramClient ever looks at the ok flag, so the retry layer never even sees a TelegramAPIError to (correctly) decline to retry.

Rate-limit decision (see docs/decisions.md): when the ok: false envelope carries parameters.retry_after, that is Telegram’s rate-limit signal (Telegram does not use a generic HTTP 429 for this). In that case TelegramClient._call raises RateLimitedError (from peyk.transport) with retry_after_seconds set, instead of TelegramAPIError. The raise still happens after run_with_retry has returned, so it is not auto-retried by _call – the caller sees a retryable-typed signal and decides when to retry.

class peyk.platforms.telegram.errors.ResponseParameters(migrate_to_chat_id: int | None = None, retry_after: int | None = None)[source]

Bases: object

Telegram’s ResponseParameters error-hint object.

Only the fields Telegram documents on this object are modelled: migrate_to_chat_id (group migrated to a supergroup) and retry_after (rate-limit wait hint, seconds).

migrate_to_chat_id: int | None = None
retry_after: int | None = None
classmethod from_dict(data: dict | None) ResponseParameters | None[source]

Provides the from dict operation for the Telegram integration.

Parameters:

data – Value used by this operation.

Returns:

Result produced by the operation.

exception peyk.platforms.telegram.errors.TelegramAPIError(message: str, *, error_code: int, description: str, parameters: ResponseParameters | None = None)[source]

Bases: TransportError

Raised when a Telegram API response has ok: false (no rate hint).

Variables:
  • error_code – Telegram’s error_code integer from the response body.

  • description – Telegram’s human-readable description string.

  • parameters – The optional parameters object Telegram sometimes includes alongside an error (a ResponseParameters when the raw dict parses, else the raw value). None when absent. Note: when the parameters carry retry_after, TelegramClient raises RateLimitedError instead of this class – so a TelegramAPIError observed in practice never carries a retry hint (see module docstring).

peyk.platforms.telegram.errors.error_for_envelope(method_name: str, *, error_code: int, description: str, parameters: dict | None) TransportError[source]

Provides the error for envelope operation for the Telegram integration.

Parameters:
  • method_name – Value used by this operation.

  • error_code – Value used by this operation.

  • description – Value used by this operation.

  • parameters – Value used by this operation.

Returns:

Result produced by the operation.