Splus API

Soroush Plus (Splus) is Telegram-shaped: it reuses the Telegram models and operation strategies, but SplusClient binds only the methods that the published Splus client libraries confirm (SPLUS_METHODS).

Soroush Plus (Splus) platform public API.

Splus is Telegram-shaped, so incoming updates and outgoing objects use the Telegram models from peyk.platforms.telegram; only the client, the error type and the deliverable update kinds are Splus-specific.

exception peyk.platforms.splus.SplusAPIError(message: str, *, error_code: int, description: str, parameters: ResponseParameters | None = None)[source]

Bases: TelegramAPIError

Raised when a Splus API response has ok: false (no rate hint).

class peyk.platforms.splus.SplusClient(token: str, session: Session | None = None, *, retry_policy: RetryPolicy | None = None, logger: object = None, base_url: str | None = None, rate_limit: object = None)[source]

Bases: TelegramLikeClient[User, WebhookInfo, File, ChatFullInfo, ChatMemberOwner | ChatMemberAdministrator | ChatMemberMember | ChatMemberRestricted | ChatMemberLeft | ChatMemberBanned]

A thin, typed async wrapper around the Soroush Plus bot API.

Parameters:
  • token – The bot token issued by Soroush Plus’ bot father.

  • session – An existing peyk.transport.Session to reuse.

  • retry_policy – Transport-level retry policy for this client’s calls.

  • logger – Passed to the Session this client builds itself.

  • base_url – Override for the API base URL (tests, proxies).

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

base_url: str = 'https://api.splus.ir'
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 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 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_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

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_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]

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 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_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 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 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_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_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_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_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_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_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_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_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

user_model

alias of User

webhook_info_model

alias of WebhookInfo