pytdbot.methods.td_functions

class pytdbot.methods.td_functions.TDLibFunctions[source]

Bases: object

A class that include all TDLib functions

async acceptCall(call_id=0, protocol=None)[source]

Accepts an incoming call

Parameters:
  • call_id (int) – Call identifier

  • protocol ("types.CallProtocol") – The call protocols supported by the application

Return type:

Union[Error, Ok]

Returns:

Ok

async acceptTermsOfService(terms_of_service_id='')[source]

Accepts Telegram terms of services

Parameters:

terms_of_service_id (str) – Terms of service identifier

Return type:

Union[Error, Ok]

Returns:

Ok

async activateStoryStealthMode()[source]

Activates stealth mode for stories, which hides all views of stories from the current user in the last "story_stealth_mode_past_period" seconds and for the next "story_stealth_mode_future_period" seconds; for Telegram Premium users only

Return type:

Union[Error, Ok]

Returns:

Ok

async addBotMediaPreview(bot_user_id=0, language_code='', content=None)[source]

Adds a new media preview to the beginning of the list of media previews of a bot. Returns the added preview after addition is completed server-side. The total number of previews must not exceed getOption("bot_media_preview_count_max") for the given language

Parameters:
  • bot_user_id (int) – Identifier of the target bot. The bot must be owned and must have the main Web App

  • language_code (str) – A two-letter ISO 639-1 language code for which preview is added. If empty, then the preview will be shown to all users for whose languages there are no dedicated previews. If non-empty, then there must be an official language pack of the same name, which is returned by getLocalizationTargetInfo

  • content ("types.InputStoryContent") – Content of the added preview

Return type:

Union[Error, BotMediaPreview]

Returns:

BotMediaPreview

Adds a chat folder by an invite link

Parameters:
  • invite_link (str) – Invite link for the chat folder

  • chat_ids (List[int]) – Identifiers of the chats added to the chat folder. The chats are automatically joined if they aren’t joined yet

Return type:

Union[Error, Ok]

Returns:

Ok

async addChatMember(chat_id=0, user_id=0, forward_limit=0)[source]

Adds a new member to a chat; requires can_invite_users member right. Members can’t be added to private or secret chats. Returns information about members that weren’t added

Parameters:
  • chat_id (int) – Chat identifier

  • user_id (int) – Identifier of the user

  • forward_limit (int) – The number of earlier messages from the chat to be forwarded to the new member; up to 100. Ignored for supergroups and channels, or if the added user is a bot

Return type:

Union[Error, FailedToAddMembers]

Returns:

FailedToAddMembers

async addChatMembers(chat_id=0, user_ids=None)[source]

Adds multiple new members to a chat; requires can_invite_users member right. Currently, this method is only available for supergroups and channels. This method can’t be used to join a chat. Members can’t be added to a channel if it has more than 200 members. Returns information about members that weren’t added

Parameters:
  • chat_id (int) – Chat identifier

  • user_ids (List[int]) – Identifiers of the users to be added to the chat. The maximum number of added users is 20 for supergroups and 100 for channels

Return type:

Union[Error, FailedToAddMembers]

Returns:

FailedToAddMembers

async addChatToList(chat_id=0, chat_list=None)[source]

Adds a chat to a chat list. A chat can’t be simultaneously in Main and Archive chat lists, so it is automatically removed from another one if needed

Parameters:
  • chat_id (int) – Chat identifier

  • chat_list ("types.ChatList") – The chat list. Use getChatListsToAddChat to get suitable chat lists

Return type:

Union[Error, Ok]

Returns:

Ok

async addChecklistTasks(chat_id=0, message_id=0, tasks=None)[source]

Adds tasks to a checklist in a message

Parameters:
  • chat_id (int) – Identifier of the chat with the message

  • message_id (int) – Identifier of the message containing the checklist. Use messageProperties.can_add_tasks to check whether the tasks can be added

  • tasks (List["types.InputChecklistTask"]) – List of added tasks

Return type:

Union[Error, Ok]

Returns:

Ok

async addContact(contact=None, share_phone_number=False)[source]

Adds a user to the contact list or edits an existing contact by their user identifier

Parameters:
  • contact ("types.Contact") – The contact to add or edit; phone number may be empty and needs to be specified only if known, vCard is ignored

  • share_phone_number (bool) – Pass true to share the current user’s phone number with the new contact. A corresponding rule to userPrivacySettingShowPhoneNumber will be added if needed. Use the field userFullInfo.need_phone_number_privacy_exception to check whether the current user needs to be asked to share their phone number

Return type:

Union[Error, Ok]

Returns:

Ok

async addCustomServerLanguagePack(language_pack_id='')[source]

Adds a custom server language pack to the list of installed language packs in current localization target. Can be called before authorization

Parameters:

language_pack_id (str) – Identifier of a language pack to be added

Return type:

Union[Error, Ok]

Returns:

Ok

async addFavoriteSticker(sticker=None)[source]

Adds a new sticker to the list of favorite stickers. The new sticker is added to the top of the list. If the sticker was already in the list, it is removed from the list first. Only stickers belonging to a sticker set or in WEBP or WEBM format can be added to this list. Emoji stickers can’t be added to favorite stickers

Parameters:

sticker ("types.InputFile") – Sticker file to add

Return type:

Union[Error, Ok]

Returns:

Ok

async addFileToDownloads(file_id=0, chat_id=0, message_id=0, priority=0)[source]

Adds a file from a message to the list of file downloads. Download progress and completion of the download will be notified through updateFile updates. If message database is used, the list of file downloads is persistent across application restarts. The downloading is independent of download using downloadFile, i.e. it continues if downloadFile is canceled or is used to download a part of the file

Parameters:
  • file_id (int) – Identifier of the file to download

  • chat_id (int) – Chat identifier of the message with the file

  • message_id (int) – Message identifier

  • priority (int) – Priority of the download (1-32). The higher the priority, the earlier the file will be downloaded. If the priorities of two files are equal, then the last one for which downloadFile/addFileToDownloads was called will be downloaded first

Return type:

Union[Error, File]

Returns:

File

async addGiftCollectionGifts(owner_id=None, collection_id=0, received_gift_ids=None)[source]

Adds gifts to the beginning of a previously created collection. If the collection is owned by a channel chat, then requires can_post_messages administrator right in the channel chat. Returns the changed collection

Parameters:
  • owner_id ("types.MessageSender") – Identifier of the user or the channel chat that owns the collection

  • collection_id (int) – Identifier of the gift collection

  • received_gift_ids (List[str]) – Identifier of the gifts to add to the collection; 1-getOption("gift_collection_gift_count_max") identifiers. If after addition the collection has more than getOption("gift_collection_gift_count_max") gifts, then the last one are removed from the collection

Return type:

Union[Error, GiftCollection]

Returns:

GiftCollection

async addLocalMessage(chat_id=0, sender_id=None, reply_to=None, disable_notification=False, input_message_content=None)[source]

Adds a local message to a chat. The message is persistent across application restarts only if the message database is used. Returns the added message

Parameters:
  • chat_id (int) – Target chat; channel direct messages chats aren’t supported

  • sender_id ("types.MessageSender") – Identifier of the sender of the message

  • reply_to ("types.InputMessageReplyTo") – Information about the message or story to be replied; pass null if none

  • disable_notification (bool) – Pass true to disable notification for the message

  • input_message_content ("types.InputMessageContent") – The content of the message to be added

Return type:

Union[Error, Message]

Returns:

Message

async addLogMessage(verbosity_level=0, text='')[source]

Adds a message to TDLib internal log. Can be called synchronously

Parameters:
  • verbosity_level (int) – The minimum verbosity level needed for the message to be logged; 0-1023

  • text (str) – Text of a message to log

Return type:

Union[Error, Ok]

Returns:

Ok

async addMessageReaction(chat_id=0, message_id=0, reaction_type=None, is_big=False, update_recent_reactions=False)[source]

Adds a reaction or a tag to a message. Use getMessageAvailableReactions to receive the list of available reactions for the message

Parameters:
  • chat_id (int) – Identifier of the chat to which the message belongs

  • message_id (int) – Identifier of the message

  • reaction_type ("types.ReactionType") – Type of the reaction to add. Use addPendingPaidMessageReaction instead to add the paid reaction

  • is_big (bool) – Pass true if the reaction is added with a big animation

  • update_recent_reactions (bool) – Pass true if the reaction needs to be added to recent reactions; tags are never added to the list of recent reactions

Return type:

Union[Error, Ok]

Returns:

Ok

async addNetworkStatistics(entry=None)[source]

Adds the specified data to data usage statistics. Can be called before authorization

Parameters:

entry ("types.NetworkStatisticsEntry") – The network statistics entry with the data to be added to statistics

Return type:

Union[Error, Ok]

Returns:

Ok

async addOffer(chat_id=0, message_id=0, options=None)[source]

Sent a suggested post based on a previously sent message in a channel direct messages chat. Can be also used to suggest price or time change for an existing suggested post. Returns the sent message

Parameters:
  • chat_id (int) – Identifier of the channel direct messages chat

  • message_id (int) – Identifier of the message in the chat which will be sent as suggested post. Use messageProperties.can_add_offer to check whether an offer can be added or messageProperties.can_edit_suggested_post_info to check whether price or time of sending of the post can be changed

  • options ("types.MessageSendOptions") – Options to be used to send the message. New information about the suggested post must always be specified

Return type:

Union[Error, Message]

Returns:

Message

async addPendingPaidMessageReaction(chat_id=0, message_id=0, star_count=0, type=None)[source]

Adds the paid message reaction to a message. Use getMessageAvailableReactions to check whether the reaction is available for the message

Parameters:
  • chat_id (int) – Identifier of the chat to which the message belongs

  • message_id (int) – Identifier of the message

  • star_count (int) – Number of Telegram Stars to be used for the reaction. The total number of pending paid reactions must not exceed getOption("paid_reaction_star_count_max")

  • type ("types.PaidReactionType") – Type of the paid reaction; pass null if the user didn’t choose reaction type explicitly, for example, the reaction is set from the message bubble

Return type:

Union[Error, Ok]

Returns:

Ok

async addProfileAudio(file_id=0)[source]

Adds an audio file to the beginning of the profile audio files of the current user

Parameters:

file_id (int) – Identifier of the audio file to be added. The file must have been uploaded to the server

Return type:

Union[Error, Ok]

Returns:

Ok

async addProxy(server='', port=0, enable=False, type=None)[source]

Adds a proxy server for network requests. Can be called before authorization

Parameters:
  • server (str) – Proxy server domain or IP address

  • port (int) – Proxy server port

  • enable (bool) – Pass true to immediately enable the proxy

  • type ("types.ProxyType") – Proxy type

Return type:

Union[Error, Proxy]

Returns:

Proxy

async addQuickReplyShortcutInlineQueryResultMessage(shortcut_name='', reply_to_message_id=0, query_id=0, result_id='', hide_via_bot=False)[source]

Adds a message to a quick reply shortcut via inline bot. If shortcut doesn’t exist and there are less than getOption("quick_reply_shortcut_count_max") shortcuts, then a new shortcut is created. The shortcut must not contain more than getOption("quick_reply_shortcut_message_count_max") messages after adding the new message. Returns the added message

Parameters:
  • shortcut_name (str) – Name of the target shortcut

  • reply_to_message_id (int) – Identifier of a quick reply message in the same shortcut to be replied; pass 0 if none

  • query_id (int) – Identifier of the inline query

  • result_id (str) – Identifier of the inline query result

  • hide_via_bot (bool) – Pass true to hide the bot, via which the message is sent. Can be used only for bots getOption("animation_search_bot_username"), getOption("photo_search_bot_username"), and getOption("venue_search_bot_username")

Return type:

Union[Error, QuickReplyMessage]

Returns:

QuickReplyMessage

async addQuickReplyShortcutMessage(shortcut_name='', reply_to_message_id=0, input_message_content=None)[source]

Adds a message to a quick reply shortcut. If shortcut doesn’t exist and there are less than getOption("quick_reply_shortcut_count_max") shortcuts, then a new shortcut is created. The shortcut must not contain more than getOption("quick_reply_shortcut_message_count_max") messages after adding the new message. Returns the added message

Parameters:
  • shortcut_name (str) – Name of the target shortcut

  • reply_to_message_id (int) – Identifier of a quick reply message in the same shortcut to be replied; pass 0 if none

  • input_message_content ("types.InputMessageContent") – The content of the message to be added; inputMessagePaidMedia, inputMessageForwarded and inputMessageLocation with live_period aren’t supported

Return type:

Union[Error, QuickReplyMessage]

Returns:

QuickReplyMessage

async addQuickReplyShortcutMessageAlbum(shortcut_name='', reply_to_message_id=0, input_message_contents=None)[source]

Adds 2-10 messages grouped together into an album to a quick reply shortcut. Currently, only audio, document, photo and video messages can be grouped into an album. Documents and audio files can be only grouped in an album with messages of the same type. Returns sent messages

Parameters:
  • shortcut_name (str) – Name of the target shortcut

  • reply_to_message_id (int) – Identifier of a quick reply message in the same shortcut to be replied; pass 0 if none

  • input_message_contents (List["types.InputMessageContent"]) – Contents of messages to be sent. At most 10 messages can be added to an album. All messages must have the same value of show_caption_above_media

Return type:

Union[Error, QuickReplyMessages]

Returns:

QuickReplyMessages

async addRecentSticker(is_attached=False, sticker=None)[source]

Manually adds a new sticker to the list of recently used stickers. The new sticker is added to the top of the list. If the sticker was already in the list, it is removed from the list first. Only stickers belonging to a sticker set or in WEBP or WEBM format can be added to this list. Emoji stickers can’t be added to recent stickers

Parameters:
  • is_attached (bool) – Pass true to add the sticker to the list of stickers recently attached to photo or video files; pass false to add the sticker to the list of recently sent stickers

  • sticker ("types.InputFile") – Sticker file to add

Return type:

Union[Error, Stickers]

Returns:

Stickers

async addRecentlyFoundChat(chat_id=0)[source]

Adds a chat to the list of recently found chats. The chat is added to the beginning of the list. If the chat is already in the list, it will be removed from the list first

Parameters:

chat_id (int) – Identifier of the chat to add

Return type:

Union[Error, Ok]

Returns:

Ok

async addSavedAnimation(animation=None)[source]

Manually adds a new animation to the list of saved animations. The new animation is added to the beginning of the list. If the animation was already in the list, it is removed first. Only non-secret video animations with MIME type "video/mp4" can be added to the list

Parameters:

animation ("types.InputFile") – The animation file to be added. Only animations known to the server (i.e., successfully sent via a message) can be added to the list

Return type:

Union[Error, Ok]

Returns:

Ok

async addSavedNotificationSound(sound=None)[source]

Adds a new notification sound to the list of saved notification sounds. The new notification sound is added to the top of the list. If it is already in the list, its position isn’t changed

Parameters:

sound ("types.InputFile") – Notification sound file to add

Return type:

Union[Error, NotificationSound]

Returns:

NotificationSound

async addStickerToSet(user_id=0, name='', sticker=None)[source]

Adds a new sticker to a set

Parameters:
  • user_id (int) – Sticker set owner; ignored for regular users

  • name (str) – Sticker set name. The sticker set must be owned by the current user, and contain less than 200 stickers for custom emoji sticker sets and less than 120 otherwise

  • sticker ("types.InputSticker") – Sticker to add to the set

Return type:

Union[Error, Ok]

Returns:

Ok

async addStoryAlbumStories(chat_id=0, story_album_id=0, story_ids=None)[source]

Adds stories to the beginning of a previously created story album. If the album is owned by a supergroup or a channel chat, then requires can_edit_stories administrator right in the chat. Returns the changed album

Parameters:
  • chat_id (int) – Identifier of the chat that owns the stories

  • story_album_id (int) – Identifier of the story album

  • story_ids (List[int]) – Identifier of the stories to add to the album; 1-getOption("story_album_story_count_max") identifiers. If after addition the album has more than getOption("story_album_story_count_max") stories, then the last one are removed from the album

Return type:

Union[Error, StoryAlbum]

Returns:

StoryAlbum

async allowBotToSendMessages(bot_user_id=0)[source]

Allows the specified bot to send messages to the user

Parameters:

bot_user_id (int) – Identifier of the target bot

Return type:

Union[Error, Ok]

Returns:

Ok

async allowUnpaidMessagesFromUser(user_id=0, refund_payments=False)[source]

Allows the specified user to send unpaid private messages to the current user by adding a rule to userPrivacySettingAllowUnpaidMessages

Parameters:
  • user_id (int) – Identifier of the user

  • refund_payments (bool) – Pass true to refund the user previously paid messages

Return type:

Union[Error, Ok]

Returns:

Ok

async answerCallbackQuery(callback_query_id=0, text='', show_alert=False, url='', cache_time=0)[source]

Sets the result of a callback query; for bots only

Parameters:
  • callback_query_id (int) – Identifier of the callback query

  • text (str) – Text of the answer

  • show_alert (bool) – Pass true to show an alert to the user instead of a toast notification

  • url (str) – URL to be opened

  • cache_time (int) – Time during which the result of the query can be cached, in seconds

Return type:

Union[Error, Ok]

Returns:

Ok

async answerCustomQuery(custom_query_id=0, data='')[source]

Answers a custom query; for bots only

Parameters:
  • custom_query_id (int) – Identifier of a custom query

  • data (str) – JSON-serialized answer to the query

Return type:

Union[Error, Ok]

Returns:

Ok

async answerInlineQuery(inline_query_id=0, is_personal=False, button=None, results=None, cache_time=0, next_offset='')[source]

Sets the result of an inline query; for bots only

Parameters:
  • inline_query_id (int) – Identifier of the inline query

  • is_personal (bool) – Pass true if results may be cached and returned only for the user that sent the query. By default, results may be returned to any user who sends the same query

  • button ("types.InlineQueryResultsButton") – Button to be shown above inline query results; pass null if none

  • results (List["types.InputInlineQueryResult"]) – The results of the query

  • cache_time (int) – Allowed time to cache the results of the query, in seconds

  • next_offset (str) – Offset for the next inline query; pass an empty string if there are no more results

Return type:

Union[Error, Ok]

Returns:

Ok

async answerPreCheckoutQuery(pre_checkout_query_id=0, error_message='')[source]

Sets the result of a pre-checkout query; for bots only

Parameters:
  • pre_checkout_query_id (int) – Identifier of the pre-checkout query

  • error_message (str) – An error message, empty on success

Return type:

Union[Error, Ok]

Returns:

Ok

async answerShippingQuery(shipping_query_id=0, shipping_options=None, error_message='')[source]

Sets the result of a shipping query; for bots only

Parameters:
  • shipping_query_id (int) – Identifier of the shipping query

  • shipping_options (List["types.ShippingOption"]) – Available shipping options

  • error_message (str) – An error message, empty on success

Return type:

Union[Error, Ok]

Returns:

Ok

async answerWebAppQuery(web_app_query_id='', result=None)[source]

Sets the result of interaction with a Web App and sends corresponding message on behalf of the user to the chat from which the query originated; for bots only

Parameters:
  • web_app_query_id (str) – Identifier of the Web App query

  • result ("types.InputInlineQueryResult") – The result of the query

Return type:

Union[Error, SentWebAppMessage]

Returns:

SentWebAppMessage

async applyPremiumGiftCode(code='')[source]

Applies a Telegram Premium gift code

Parameters:

code (str) – The code to apply

Return type:

Union[Error, Ok]

Returns:

Ok

async approveSuggestedPost(chat_id=0, message_id=0, send_date=0)[source]

Approves a suggested post in a channel direct messages chat

Parameters:
  • chat_id (int) – Chat identifier of the channel direct messages chat

  • message_id (int) – Identifier of the message with the suggested post. Use messageProperties.can_be_approved to check whether the suggested post can be approved

  • send_date (int) – Point in time (Unix timestamp) when the post is expected to be published; pass 0 if the date has already been chosen. If specified, then the date must be in the future, but at most getOption("suggested_post_send_delay_max") seconds in the future

Return type:

Union[Error, Ok]

Returns:

Ok

async assignStoreTransaction(transaction=None, purpose=None)[source]

Informs server about an in-store purchase. For official applications only

Parameters:
  • transaction ("types.StoreTransaction") – Information about the transaction

  • purpose ("types.StorePaymentPurpose") – Transaction purpose

Return type:

Union[Error, Ok]

Returns:

Ok

async banChatMember(chat_id=0, member_id=None, banned_until_date=0, revoke_messages=False)[source]

Bans a member in a chat; requires can_restrict_members administrator right. Members can’t be banned in private or secret chats. In supergroups and channels, the user will not be able to return to the group on their own using invite links, etc., unless unbanned first

Parameters:
  • chat_id (int) – Chat identifier

  • member_id ("types.MessageSender") – Member identifier

  • banned_until_date (int) – Point in time (Unix timestamp) when the user will be unbanned; 0 if never. If the user is banned for more than 366 days or for less than 30 seconds from the current time, the user is considered to be banned forever. Ignored in basic groups and if a chat is banned

  • revoke_messages (bool) – Pass true to delete all messages in the chat for the user that is being removed. Always true for supergroups and channels

Return type:

Union[Error, Ok]

Returns:

Ok

async banGroupCallParticipants(group_call_id=0, user_ids=None)[source]

Bans users from a group call not bound to a chat; requires groupCall.is_owned. Only the owner of the group call can invite the banned users back

Parameters:
  • group_call_id (int) – Group call identifier

  • user_ids (List[int]) – Identifiers of group call participants to ban; identifiers of unknown users from the update updateGroupCallParticipants can be also passed to the method

Return type:

Union[Error, Ok]

Returns:

Ok

async blockMessageSenderFromReplies(message_id=0, delete_message=False, delete_all_messages=False, report_spam=False)[source]

Blocks an original sender of a message in the Replies chat

Parameters:
  • message_id (int) – The identifier of an incoming message in the Replies chat

  • delete_message (bool) – Pass true to delete the message

  • delete_all_messages (bool) – Pass true to delete all messages from the same sender

  • report_spam (bool) – Pass true to report the sender to the Telegram moderators

Return type:

Union[Error, Ok]

Returns:

Ok

async boostChat(chat_id=0, slot_ids=None)[source]

Boosts a chat and returns the list of available chat boost slots for the current user after the boost

Parameters:
  • chat_id (int) – Identifier of the chat

  • slot_ids (List[int]) – Identifiers of boost slots of the current user from which to apply boosts to the chat

Return type:

Union[Error, ChatBoostSlots]

Returns:

ChatBoostSlots

async buyGiftUpgrade(owner_id=None, prepaid_upgrade_hash='', star_count=0)[source]

Pays for upgrade of a regular gift that is owned by another user or channel chat

Parameters:
  • owner_id ("types.MessageSender") – Identifier of the user or the channel chat that owns the gift

  • prepaid_upgrade_hash (str) – Prepaid upgrade hash as received along with the gift

  • star_count (int) – The amount of Telegram Stars the user agreed to pay for the upgrade; must be equal to gift.upgrade_star_count

Return type:

Union[Error, Ok]

Returns:

Ok

async canBotSendMessages(bot_user_id=0)[source]

Checks whether the specified bot can send messages to the user. Returns a 404 error if can’t and the access can be granted by call to allowBotToSendMessages

Parameters:

bot_user_id (int) – Identifier of the target bot

Return type:

Union[Error, Ok]

Returns:

Ok

async canPostStory(chat_id=0)[source]

Checks whether the current user can post a story on behalf of a chat; requires can_post_stories administrator right for supergroup and channel chats

Parameters:

chat_id (int) – Chat identifier. Pass Saved Messages chat identifier when posting a story on behalf of the current user

Return type:

Union[Error, CanPostStoryResult]

Returns:

CanPostStoryResult

async canPurchaseFromStore(purpose=None)[source]

Checks whether an in-store purchase is possible. Must be called before any in-store purchase. For official applications only

Parameters:

purpose ("types.StorePaymentPurpose") – Transaction purpose

Return type:

Union[Error, Ok]

Returns:

Ok

async canSendGift(gift_id=0)[source]

Checks whether a gift with next_send_date in the future can be sent already

Parameters:

gift_id (int) – Identifier of the gift to send

Return type:

Union[Error, CanSendGiftResult]

Returns:

CanSendGiftResult

async canSendMessageToUser(user_id=0, only_local=False)[source]

Check whether the current user can message another user or try to create a chat with them

Parameters:
  • user_id (int) – Identifier of the other user

  • only_local (bool) – Pass true to get only locally available information without sending network requests

Return type:

Union[Error, CanSendMessageToUserResult]

Returns:

CanSendMessageToUserResult

async canTransferOwnership()[source]

Checks whether the current session can be used to transfer a chat ownership to another user

Return type:

Union[Error, CanTransferOwnershipResult]

Returns:

CanTransferOwnershipResult

async cancelDownloadFile(file_id=0, only_if_pending=False)[source]

Stops the downloading of a file. If a file has already been downloaded, does nothing

Parameters:
  • file_id (int) – Identifier of a file to stop downloading

  • only_if_pending (bool) – Pass true to stop downloading only if it hasn’t been started, i.e. request hasn’t been sent to server

Return type:

Union[Error, Ok]

Returns:

Ok

async cancelPasswordReset()[source]

Cancels reset of 2-step verification password. The method can be called if passwordState.pending_reset_date > 0

Return type:

Union[Error, Ok]

Returns:

Ok

async cancelPreliminaryUploadFile(file_id=0)[source]

Stops the preliminary uploading of a file. Supported only for files uploaded by using preliminaryUploadFile

Parameters:

file_id (int) – Identifier of the file to stop uploading

Return type:

Union[Error, Ok]

Returns:

Ok

async cancelRecoveryEmailAddressVerification()[source]

Cancels verification of the 2-step verification recovery email address

Return type:

Union[Error, PasswordState]

Returns:

PasswordState

async changeImportedContacts(contacts=None)[source]

Changes imported contacts using the list of contacts saved on the device. Imports newly added contacts and, if at least the file database is enabled, deletes recently deleted contacts. Query result depends on the result of the previous query, so only one query is possible at the same time

Parameters:

contacts (List["types.Contact"]) – The new list of contacts, contact’s vCard are ignored and are not imported

Return type:

Union[Error, ImportedContacts]

Returns:

ImportedContacts

async changeStickerSet(set_id=0, is_installed=False, is_archived=False)[source]

Installs/uninstalls or activates/archives a sticker set

Parameters:
  • set_id (int) – Identifier of the sticker set

  • is_installed (bool) – The new value of is_installed

  • is_archived (bool) – The new value of is_archived. A sticker set can’t be installed and archived simultaneously

Return type:

Union[Error, Ok]

Returns:

Ok

async checkAuthenticationBotToken(token='')[source]

Checks the authentication token of a bot; to log in as a bot. Works only when the current authorization state is authorizationStateWaitPhoneNumber. Can be used instead of setAuthenticationPhoneNumber and checkAuthenticationCode to log in

Parameters:

token (str) – The bot token

Return type:

Union[Error, Ok]

Returns:

Ok

async checkAuthenticationCode(code='')[source]

Checks the authentication code. Works only when the current authorization state is authorizationStateWaitCode

Parameters:

code (str) – Authentication code to check

Return type:

Union[Error, Ok]

Returns:

Ok

async checkAuthenticationEmailCode(code=None)[source]

Checks the authentication of an email address. Works only when the current authorization state is authorizationStateWaitEmailCode

Parameters:

code ("types.EmailAddressAuthentication") – Email address authentication to check

Return type:

Union[Error, Ok]

Returns:

Ok

async checkAuthenticationPassword(password='')[source]

Checks the 2-step verification password for correctness. Works only when the current authorization state is authorizationStateWaitPassword

Parameters:

password (str) – The 2-step verification password to check

Return type:

Union[Error, Ok]

Returns:

Ok

async checkAuthenticationPasswordRecoveryCode(recovery_code='')[source]

Checks whether a 2-step verification password recovery code sent to an email address is valid. Works only when the current authorization state is authorizationStateWaitPassword

Parameters:

recovery_code (str) – Recovery code to check

Return type:

Union[Error, Ok]

Returns:

Ok

async checkAuthenticationPremiumPurchase(currency='', amount=0)[source]

Checks whether an in-store purchase of Telegram Premium is possible before authorization. Works only when the current authorization state is authorizationStateWaitPremiumPurchase

Parameters:
  • currency (str) – ISO 4217 currency code of the payment currency

  • amount (int) – Paid amount, in the smallest units of the currency

Return type:

Union[Error, Ok]

Returns:

Ok

Checks the validity of an invite link for a chat folder and returns information about the corresponding chat folder

Parameters:

invite_link (str) – Invite link to be checked

Return type:

Union[Error, ChatFolderInviteLinkInfo]

Returns:

ChatFolderInviteLinkInfo

Checks the validity of an invite link for a chat and returns information about the corresponding chat

Parameters:

invite_link (str) – Invite link to be checked

Return type:

Union[Error, ChatInviteLinkInfo]

Returns:

ChatInviteLinkInfo

async checkChatUsername(chat_id=0, username='')[source]

Checks whether a username can be set for a chat

Parameters:
  • chat_id (int) – Chat identifier; must be identifier of a supergroup chat, or a channel chat, or a private chat with self, or 0 if the chat is being created

  • username (str) – Username to be checked

Return type:

Union[Error, CheckChatUsernameResult]

Returns:

CheckChatUsernameResult

async checkCreatedPublicChatsLimit(type=None)[source]

Checks whether the maximum number of owned public chats has been reached. Returns corresponding error if the limit was reached. The limit can be increased with Telegram Premium

Parameters:

type ("types.PublicChatType") – Type of the public chats, for which to check the limit

Return type:

Union[Error, Ok]

Returns:

Ok

async checkEmailAddressVerificationCode(code='')[source]

Checks the email address verification code for Telegram Passport

Parameters:

code (str) – Verification code to check

Return type:

Union[Error, Ok]

Returns:

Ok

async checkLoginEmailAddressCode(code=None)[source]

Checks the login email address authentication

Parameters:

code ("types.EmailAddressAuthentication") – Email address authentication to check

Return type:

Union[Error, Ok]

Returns:

Ok

async checkPasswordRecoveryCode(recovery_code='')[source]

Checks whether a 2-step verification password recovery code sent to an email address is valid

Parameters:

recovery_code (str) – Recovery code to check

Return type:

Union[Error, Ok]

Returns:

Ok

async checkPhoneNumberCode(code='')[source]

Check the authentication code and completes the request for which the code was sent if appropriate

Parameters:

code (str) – Authentication code to check

Return type:

Union[Error, Ok]

Returns:

Ok

async checkPremiumGiftCode(code='')[source]

Return information about a Telegram Premium gift code

Parameters:

code (str) – The code to check

Return type:

Union[Error, PremiumGiftCodeInfo]

Returns:

PremiumGiftCodeInfo

async checkQuickReplyShortcutName(name='')[source]

Checks validness of a name for a quick reply shortcut. Can be called synchronously

Parameters:

name (str) – The name of the shortcut; 1-32 characters

Return type:

Union[Error, Ok]

Returns:

Ok

async checkRecoveryEmailAddressCode(code='')[source]

Checks the 2-step verification recovery email address verification code

Parameters:

code (str) – Verification code to check

Return type:

Union[Error, PasswordState]

Returns:

PasswordState

async checkStickerSetName(name='')[source]

Checks whether a name can be used for a new sticker set

Parameters:

name (str) – Name to be checked

Return type:

Union[Error, CheckStickerSetNameResult]

Returns:

CheckStickerSetNameResult

async checkWebAppFileDownload(bot_user_id=0, file_name='', url='')[source]

Checks whether a file can be downloaded and saved locally by Web App request

Parameters:
  • bot_user_id (int) – Identifier of the bot, providing the Web App

  • file_name (str) – Name of the file

  • url (str) – URL of the file

Return type:

Union[Error, Ok]

Returns:

Ok

async cleanFileName(file_name='')[source]

Removes potentially dangerous characters from the name of a file. Returns an empty string on failure. Can be called synchronously

Parameters:

file_name (str) – File name or path to the file

Return type:

Union[Error, Text]

Returns:

Text

async clearAllDraftMessages(exclude_secret_chats=False)[source]

Clears message drafts in all chats

Parameters:

exclude_secret_chats (bool) – Pass true to keep local message drafts in secret chats

Return type:

Union[Error, Ok]

Returns:

Ok

async clearAutosaveSettingsExceptions()[source]

Clears the list of all autosave settings exceptions. The method is guaranteed to work only after at least one call to getAutosaveSettings

Return type:

Union[Error, Ok]

Returns:

Ok

async clearImportedContacts()[source]

Clears all imported contacts, contact list remains unchanged

Return type:

Union[Error, Ok]

Returns:

Ok

async clearRecentEmojiStatuses()[source]

Clears the list of recently used emoji statuses for self status

Return type:

Union[Error, Ok]

Returns:

Ok

async clearRecentReactions()[source]

Clears the list of recently used reactions

Return type:

Union[Error, Ok]

Returns:

Ok

async clearRecentStickers(is_attached=False)[source]

Clears the list of recently used stickers

Parameters:

is_attached (bool) – Pass true to clear the list of stickers recently attached to photo or video files; pass false to clear the list of recently sent stickers

Return type:

Union[Error, Ok]

Returns:

Ok

async clearRecentlyFoundChats()[source]

Clears the list of recently found chats

Return type:

Union[Error, Ok]

Returns:

Ok

async clearSearchedForTags(clear_cashtags=False)[source]

Clears the list of recently searched for hashtags or cashtags

Parameters:

clear_cashtags (bool) – Pass true to clear the list of recently searched for cashtags; otherwise, the list of recently searched for hashtags will be cleared

Return type:

Union[Error, Ok]

Returns:

Ok

async clickAnimatedEmojiMessage(chat_id=0, message_id=0)[source]

Informs TDLib that a message with an animated emoji was clicked by the user. Returns a big animated sticker to be played or a 404 error if usual animation needs to be played

Parameters:
  • chat_id (int) – Chat identifier of the message

  • message_id (int) – Identifier of the clicked message

Return type:

Union[Error, Sticker]

Returns:

Sticker

async clickChatSponsoredMessage(chat_id=0, message_id=0, is_media_click=False, from_fullscreen=False)[source]

Informs TDLib that the user opened the sponsored chat via the button, the name, the chat photo, a mention in the sponsored message text, or the media in the sponsored message

Parameters:
  • chat_id (int) – Chat identifier of the sponsored message

  • message_id (int) – Identifier of the sponsored message

  • is_media_click (bool) – Pass true if the media was clicked in the sponsored message

  • from_fullscreen (bool) – Pass true if the user expanded the video from the sponsored message fullscreen before the click

Return type:

Union[Error, Ok]

Returns:

Ok

async clickPremiumSubscriptionButton()[source]

Informs TDLib that the user clicked Premium subscription button on the Premium features screen

Return type:

Union[Error, Ok]

Returns:

Ok

async clickVideoMessageAdvertisement(advertisement_unique_id=0)[source]

Informs TDLib that the user clicked a video message advertisement

Parameters:

advertisement_unique_id (int) – Unique identifier of the advertisement

Return type:

Union[Error, Ok]

Returns:

Ok

async close()[source]

Closes the TDLib instance. All databases will be flushed to disk and properly closed. After the close completes, updateAuthorizationState with authorizationStateClosed will be sent. Can be called before initialization

Return type:

Union[Error, Ok]

Returns:

Ok

async closeChat(chat_id=0)[source]

Informs TDLib that the chat is closed by the user. Many useful activities depend on the chat being opened or closed

Parameters:

chat_id (int) – Chat identifier

Return type:

Union[Error, Ok]

Returns:

Ok

async closeSecretChat(secret_chat_id=0)[source]

Closes a secret chat, effectively transferring its state to secretChatStateClosed

Parameters:

secret_chat_id (int) – Secret chat identifier

Return type:

Union[Error, Ok]

Returns:

Ok

async closeStory(story_poster_chat_id=0, story_id=0)[source]

Informs TDLib that a story is closed by the user

Parameters:
  • story_poster_chat_id (int) – The identifier of the poster of the story to close

  • story_id (int) – The identifier of the story

Return type:

Union[Error, Ok]

Returns:

Ok

async closeWebApp(web_app_launch_id=0)[source]

Informs TDLib that a previously opened Web App was closed

Parameters:

web_app_launch_id (int) – Identifier of Web App launch, received from openWebApp

Return type:

Union[Error, Ok]

Returns:

Ok

async commitPendingPaidMessageReactions(chat_id=0, message_id=0)[source]

Applies all pending paid reactions on a message

Parameters:
  • chat_id (int) – Identifier of the chat to which the message belongs

  • message_id (int) – Identifier of the message

Return type:

Union[Error, Ok]

Returns:

Ok

async confirmQrCodeAuthentication(link='')[source]

Confirms QR code authentication on another device. Returns created session on success

Parameters:

link (str) – A link from a QR code. The link must be scanned by the in-app camera

Return type:

Union[Error, Session]

Returns:

Session

async confirmSession(session_id=0)[source]

Confirms an unconfirmed session of the current user from another device

Parameters:

session_id (int) – Session identifier

Return type:

Union[Error, Ok]

Returns:

Ok

async connectAffiliateProgram(affiliate=None, bot_user_id=0)[source]

Connects an affiliate program to the given affiliate. Returns information about the connected affiliate program

Parameters:
  • affiliate ("types.AffiliateType") – The affiliate to which the affiliate program will be connected

  • bot_user_id (int) – Identifier of the bot, which affiliate program is connected

Return type:

Union[Error, ConnectedAffiliateProgram]

Returns:

ConnectedAffiliateProgram

async createBasicGroupChat(basic_group_id=0, force=False)[source]

Returns an existing chat corresponding to a known basic group

Parameters:
  • basic_group_id (int) – Basic group identifier

  • force (bool) – Pass true to create the chat without a network request. In this case all information about the chat except its type, title and photo can be incorrect

Return type:

Union[Error, Chat]

Returns:

Chat

Creates a business chat link for the current account. Requires Telegram Business subscription. There can be up to getOption("business_chat_link_count_max") links created. Returns the created link

Parameters:

link_info ("types.InputBusinessChatLink") – Information about the link to create

Return type:

Union[Error, BusinessChatLink]

Returns:

BusinessChatLink

async createCall(user_id=0, protocol=None, is_video=False)[source]

Creates a new call

Parameters:
  • user_id (int) – Identifier of the user to be called

  • protocol ("types.CallProtocol") – The call protocols supported by the application

  • is_video (bool) – Pass true to create a video call

Return type:

Union[Error, CallId]

Returns:

CallId

async createChatFolder(folder=None)[source]

Creates new chat folder. Returns information about the created chat folder. There can be up to getOption("chat_folder_count_max") chat folders, but the limit can be increased with Telegram Premium

Parameters:

folder ("types.ChatFolder") – The new chat folder

Return type:

Union[Error, ChatFolderInfo]

Returns:

ChatFolderInfo

Creates a new invite link for a chat folder. A link can be created for a chat folder if it has only pinned and included chats

Parameters:
  • chat_folder_id (int) – Chat folder identifier

  • name (str) – Name of the link; 0-32 characters

  • chat_ids (List[int]) – Identifiers of chats to be accessible by the invite link. Use getChatsForChatFolderInviteLink to get suitable chats. Basic groups will be automatically converted to supergroups before link creation

Return type:

Union[Error, ChatFolderInviteLink]

Returns:

ChatFolderInviteLink

Creates a new invite link for a chat. Available for basic groups, supergroups, and channels. Requires administrator privileges and can_invite_users right in the chat

Parameters:
  • chat_id (int) – Chat identifier

  • name (str) – Invite link name; 0-32 characters

  • expiration_date (int) – Point in time (Unix timestamp) when the link will expire; pass 0 if never

  • member_limit (int) – The maximum number of chat members that can join the chat via the link simultaneously; 0-99999; pass 0 if not limited

  • creates_join_request (bool) – Pass true if users joining the chat via the link need to be approved by chat administrators. In this case, member_limit must be 0

Return type:

Union[Error, ChatInviteLink]

Returns:

ChatInviteLink

Creates a new subscription invite link for a channel chat. Requires can_invite_users right in the chat

Parameters:
  • chat_id (int) – Chat identifier

  • name (str) – Invite link name; 0-32 characters

  • subscription_pricing ("types.StarSubscriptionPricing") – Information about subscription plan that will be applied to the users joining the chat via the link. Subscription period must be 2592000 in production environment, and 60 or 300 if Telegram test environment is used

Return type:

Union[Error, ChatInviteLink]

Returns:

ChatInviteLink

async createForumTopic(chat_id=0, name='', icon=None)[source]

Creates a topic in a forum supergroup chat; requires can_manage_topics administrator or can_create_topics member right in the supergroup

Parameters:
  • chat_id (int) – Identifier of the chat

  • name (str) – Name of the topic; 1-128 characters

  • icon ("types.ForumTopicIcon") – Icon of the topic. Icon color must be one of 0x6FB9F0, 0xFFD67E, 0xCB86DB, 0x8EEE98, 0xFF93B2, or 0xFB6F5F. Telegram Premium users can use any custom emoji as topic icon, other users can use only a custom emoji returned by getForumTopicDefaultIcons

Return type:

Union[Error, ForumTopicInfo]

Returns:

ForumTopicInfo

async createGiftCollection(owner_id=None, name='', received_gift_ids=None)[source]

Creates a collection from gifts on the current user’s or a channel’s profile page; requires can_post_messages administrator right in the channel chat. An owner can have up to getOption("gift_collection_count_max") gift collections. The new collection will be added to the end of the gift collection list of the owner. Returns the created collection

Parameters:
  • owner_id ("types.MessageSender") – Identifier of the user or the channel chat that received the gifts

  • name (str) – Name of the collection; 1-12 characters

  • received_gift_ids (List[str]) – Identifier of the gifts to add to the collection; 0-getOption("gift_collection_gift_count_max") identifiers

Return type:

Union[Error, GiftCollection]

Returns:

GiftCollection

async createGroupCall(join_parameters=None)[source]

Creates a new group call that isn’t bound to a chat

Parameters:

join_parameters ("types.GroupCallJoinParameters") – Parameters to join the call; pass null to only create call link without joining the call

Return type:

Union[Error, GroupCallInfo]

Returns:

GroupCallInfo

Creates a link for the given invoice; for bots only

Parameters:
  • business_connection_id (str) – Unique identifier of business connection on behalf of which to send the request

  • invoice ("types.InputMessageContent") – Information about the invoice of the type inputMessageInvoice

Return type:

Union[Error, HttpUrl]

Returns:

HttpUrl

async createNewBasicGroupChat(user_ids=None, title='', message_auto_delete_time=0)[source]

Creates a new basic group and sends a corresponding messageBasicGroupChatCreate. Returns information about the newly created chat

Parameters:
  • user_ids (List[int]) – Identifiers of users to be added to the basic group; may be empty to create a basic group without other members

  • title (str) – Title of the new basic group; 1-128 characters

  • message_auto_delete_time (int) – Message auto-delete time value, in seconds; must be from 0 up to 365 * 86400 and be divisible by 86400. If 0, then messages aren’t deleted automatically

Return type:

Union[Error, CreatedBasicGroupChat]

Returns:

CreatedBasicGroupChat

async createNewSecretChat(user_id=0)[source]

Creates a new secret chat. Returns the newly created chat

Parameters:

user_id (int) – Identifier of the target user

Return type:

Union[Error, Chat]

Returns:

Chat

async createNewStickerSet(user_id=0, title='', name='', sticker_type=None, needs_repainting=False, stickers=None, source='')[source]

Creates a new sticker set. Returns the newly created sticker set

Parameters:
  • user_id (int) – Sticker set owner; ignored for regular users

  • title (str) – Sticker set title; 1-64 characters

  • name (str) – Sticker set name. Can contain only English letters, digits and underscores. Must end with *"_by_<bot username>"* (*<bot_username>* is case insensitive) for bots; 0-64 characters. If empty, then the name returned by getSuggestedStickerSetName will be used automatically

  • sticker_type ("types.StickerType") – Type of the stickers in the set

  • needs_repainting (bool) – Pass true if stickers in the sticker set must be repainted; for custom emoji sticker sets only

  • stickers (List["types.InputSticker"]) – List of stickers to be added to the set; 1-200 stickers for custom emoji sticker sets, and 1-120 stickers otherwise. For TGS stickers, uploadStickerFile must be used before the sticker is shown

  • source (str) – Source of the sticker set; may be empty if unknown

Return type:

Union[Error, StickerSet]

Returns:

StickerSet

async createNewSupergroupChat(title='', is_forum=False, is_channel=False, description='', location=None, message_auto_delete_time=0, for_import=False)[source]

Creates a new supergroup or channel and sends a corresponding messageSupergroupChatCreate. Returns the newly created chat

Parameters:
  • title (str) – Title of the new chat; 1-128 characters

  • is_forum (bool) – Pass true to create a forum supergroup chat

  • is_channel (bool) – Pass true to create a channel chat; ignored if a forum is created

  • description (str) – Chat description; 0-255 characters

  • location ("types.ChatLocation") – Chat location if a location-based supergroup is being created; pass null to create an ordinary supergroup chat

  • message_auto_delete_time (int) – Message auto-delete time value, in seconds; must be from 0 up to 365 * 86400 and be divisible by 86400. If 0, then messages aren’t deleted automatically

  • for_import (bool) – Pass true to create a supergroup for importing messages using importMessages

Return type:

Union[Error, Chat]

Returns:

Chat

async createPrivateChat(user_id=0, force=False)[source]

Returns an existing chat corresponding to a given user

Parameters:
  • user_id (int) – User identifier

  • force (bool) – Pass true to create the chat without a network request. In this case all information about the chat except its type, title and photo can be incorrect

Return type:

Union[Error, Chat]

Returns:

Chat

async createSecretChat(secret_chat_id=0)[source]

Returns an existing chat corresponding to a known secret chat

Parameters:

secret_chat_id (int) – Secret chat identifier

Return type:

Union[Error, Chat]

Returns:

Chat

async createStoryAlbum(story_poster_chat_id=0, name='', story_ids=None)[source]

Creates an album of stories; requires can_edit_stories administrator right for supergroup and channel chats

Parameters:
  • story_poster_chat_id (int) – Identifier of the chat that posted the stories

  • name (str) – Name of the album; 1-12 characters

  • story_ids (List[int]) – Identifiers of stories to add to the album; 0-getOption("story_album_story_count_max") identifiers

Return type:

Union[Error, StoryAlbum]

Returns:

StoryAlbum

async createSupergroupChat(supergroup_id=0, force=False)[source]

Returns an existing chat corresponding to a known supergroup or channel

Parameters:
  • supergroup_id (int) – Supergroup or channel identifier

  • force (bool) – Pass true to create the chat without a network request. In this case all information about the chat except its type, title and photo can be incorrect

Return type:

Union[Error, Chat]

Returns:

Chat

async createTemporaryPassword(password='', valid_for=0)[source]

Creates a new temporary password for processing payments

Parameters:
  • password (str) – The 2-step verification password of the current user

  • valid_for (int) – Time during which the temporary password will be valid, in seconds; must be between 60 and 86400

Return type:

Union[Error, TemporaryPasswordState]

Returns:

TemporaryPasswordState

async createVideoChat(chat_id=0, title='', start_date=0, is_rtmp_stream=False)[source]

Creates a video chat (a group call bound to a chat). Available only for basic groups, supergroups and channels; requires can_manage_video_chats administrator right

Parameters:
  • chat_id (int) – Identifier of a chat in which the video chat will be created

  • title (str) – Group call title; if empty, chat title will be used

  • start_date (int) – Point in time (Unix timestamp) when the group call is expected to be started by an administrator; 0 to start the video chat immediately. The date must be at least 10 seconds and at most 8 days in the future

  • is_rtmp_stream (bool) – Pass true to create an RTMP stream instead of an ordinary video chat

Return type:

Union[Error, GroupCallId]

Returns:

GroupCallId

async declineGroupCallInvitation(chat_id=0, message_id=0)[source]

Declines an invitation to an active group call via messageGroupCall. Can be called both by the sender and the receiver of the invitation

Parameters:
  • chat_id (int) – Identifier of the chat with the message

  • message_id (int) – Identifier of the message of the type messageGroupCall

Return type:

Union[Error, Ok]

Returns:

Ok

async declineSuggestedPost(chat_id=0, message_id=0, comment='')[source]

Declines a suggested post in a channel direct messages chat

Parameters:
  • chat_id (int) – Chat identifier of the channel direct messages chat

  • message_id (int) – Identifier of the message with the suggested post. Use messageProperties.can_be_declined to check whether the suggested post can be declined

  • comment (str) – Comment for the creator of the suggested post; 0-128 characters

Return type:

Union[Error, Ok]

Returns:

Ok

async decryptGroupCallData(group_call_id=0, participant_id=None, data_channel=None, data=b'')[source]

Decrypts group call data received by tgcalls

Parameters:
  • group_call_id (int) – Group call identifier. The call must not be a video chat

  • participant_id ("types.MessageSender") – Identifier of the group call participant, which sent the data

  • data_channel ("types.GroupCallDataChannel") – Data channel for which data was encrypted; pass null if unknown

  • data (bytes) – Data to decrypt

Return type:

Union[Error, Data]

Returns:

Data

async deleteAccount(reason='', password='')[source]

Deletes the account of the current user, deleting all information associated with the user from the server. The phone number of the account can be used to create a new account. Can be called before authorization when the current authorization state is authorizationStateWaitPassword

Parameters:
  • reason (str) – The reason why the account was deleted; optional

  • password (str) – The 2-step verification password of the current user. If the current user isn’t authorized, then an empty string can be passed and account deletion can be canceled within one week

Return type:

Union[Error, Ok]

Returns:

Ok

async deleteAllCallMessages(revoke=False)[source]

Deletes all call messages

Parameters:

revoke (bool) – Pass true to delete the messages for all users

Return type:

Union[Error, Ok]

Returns:

Ok

Deletes all revoked chat invite links created by a given chat administrator. Requires administrator privileges and can_invite_users right in the chat for own links and owner privileges for other links

Parameters:
  • chat_id (int) – Chat identifier

  • creator_user_id (int) – User identifier of a chat administrator, which links will be deleted. Must be an identifier of the current user for non-owner

Return type:

Union[Error, Ok]

Returns:

Ok

async deleteBotMediaPreviews(bot_user_id=0, language_code='', file_ids=None)[source]

Delete media previews from the list of media previews of a bot

Parameters:
  • bot_user_id (int) – Identifier of the target bot. The bot must be owned and must have the main Web App

  • language_code (str) – Language code of the media previews to delete

  • file_ids (List[int]) – File identifiers of the media to delete

Return type:

Union[Error, Ok]

Returns:

Ok

Deletes a business chat link of the current account

Parameters:

link (str) – The link to delete

Return type:

Union[Error, Ok]

Returns:

Ok

async deleteBusinessConnectedBot(bot_user_id=0)[source]

Deletes the business bot that is connected to the current user account

Parameters:

bot_user_id (int) – Unique user identifier for the bot

Return type:

Union[Error, Ok]

Returns:

Ok

async deleteBusinessMessages(business_connection_id='', message_ids=None)[source]

Deletes messages on behalf of a business account; for bots only

Parameters:
  • business_connection_id (str) – Unique identifier of business connection through which the messages were received

  • message_ids (List[int]) – Identifier of the messages

Return type:

Union[Error, Ok]

Returns:

Ok

async deleteBusinessStory(business_connection_id='', story_id=0)[source]

Deletes a story posted by the bot on behalf of a business account; for bots only

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

  • story_id (int) – Identifier of the story to delete

Return type:

Union[Error, Ok]

Returns:

Ok

async deleteChat(chat_id=0)[source]

Deletes a chat along with all messages in the corresponding chat for all chat members. For group chats this will release the usernames and remove all members. Use the field chat.can_be_deleted_for_all_users to find whether the method can be applied to the chat

Parameters:

chat_id (int) – Chat identifier

Return type:

Union[Error, Ok]

Returns:

Ok

async deleteChatBackground(chat_id=0, restore_previous=False)[source]

Deletes background in a specific chat

Parameters:
  • chat_id (int) – Chat identifier

  • restore_previous (bool) – Pass true to restore previously set background. Can be used only in private and secret chats with non-deleted users if userFullInfo.set_chat_background == true. Supposed to be used from messageChatSetBackground messages with the currently set background that was set for both sides by the other user

Return type:

Union[Error, Ok]

Returns:

Ok

async deleteChatFolder(chat_folder_id=0, leave_chat_ids=None)[source]

Deletes existing chat folder

Parameters:
  • chat_folder_id (int) – Chat folder identifier

  • leave_chat_ids (List[int]) – Identifiers of the chats to leave. The chats must be pinned or always included in the folder

Return type:

Union[Error, Ok]

Returns:

Ok

Deletes an invite link for a chat folder

Parameters:
  • chat_folder_id (int) – Chat folder identifier

  • invite_link (str) – Invite link to be deleted

Return type:

Union[Error, Ok]

Returns:

Ok

async deleteChatHistory(chat_id=0, remove_from_chat_list=False, revoke=False)[source]

Deletes all messages in the chat. Use chat.can_be_deleted_only_for_self and chat.can_be_deleted_for_all_users fields to find whether and how the method can be applied to the chat

Parameters:
  • chat_id (int) – Chat identifier

  • remove_from_chat_list (bool) – Pass true to remove the chat from all chat lists

  • revoke (bool) – Pass true to delete chat history for all users

Return type:

Union[Error, Ok]

Returns:

Ok

async deleteChatMessagesByDate(chat_id=0, min_date=0, max_date=0, revoke=False)[source]

Deletes all messages between the specified dates in a chat. Supported only for private chats and basic groups. Messages sent in the last 30 seconds will not be deleted

Parameters:
  • chat_id (int) – Chat identifier

  • min_date (int) – The minimum date of the messages to delete

  • max_date (int) – The maximum date of the messages to delete

  • revoke (bool) – Pass true to delete chat messages for all users; private chats only

Return type:

Union[Error, Ok]

Returns:

Ok

async deleteChatMessagesBySender(chat_id=0, sender_id=None)[source]

Deletes all messages sent by the specified message sender in a chat. Supported only for supergroups; requires can_delete_messages administrator right

Parameters:
  • chat_id (int) – Chat identifier

  • sender_id ("types.MessageSender") – Identifier of the sender of messages to delete

Return type:

Union[Error, Ok]

Returns:

Ok

async deleteChatReplyMarkup(chat_id=0, message_id=0)[source]

Deletes the default reply markup from a chat. Must be called after a one-time keyboard or a replyMarkupForceReply reply markup has been used. An updateChatReplyMarkup update will be sent if the reply markup is changed

Parameters:
  • chat_id (int) – Chat identifier

  • message_id (int) – The message identifier of the used keyboard

Return type:

Union[Error, Ok]

Returns:

Ok

async deleteCommands(scope=None, language_code='')[source]

Deletes commands supported by the bot for the given user scope and language; for bots only

Parameters:
  • scope ("types.BotCommandScope") – The scope to which the commands are relevant; pass null to delete commands in the default bot command scope

  • language_code (str) – A two-letter ISO 639-1 language code or an empty string

Return type:

Union[Error, Ok]

Returns:

Ok

async deleteDefaultBackground(for_dark_theme=False)[source]

Deletes default background for chats

Parameters:

for_dark_theme (bool) – Pass true if the background is deleted for a dark theme

Return type:

Union[Error, Ok]

Returns:

Ok

async deleteDirectMessagesChatTopicHistory(chat_id=0, topic_id=0)[source]

Deletes all messages in the topic in a channel direct messages chat administered by the current user

Parameters:
  • chat_id (int) – Chat identifier of the channel direct messages chat

  • topic_id (int) – Identifier of the topic which messages will be deleted

Return type:

Union[Error, Ok]

Returns:

Ok

async deleteDirectMessagesChatTopicMessagesByDate(chat_id=0, topic_id=0, min_date=0, max_date=0)[source]

Deletes all messages between the specified dates in the topic in a channel direct messages chat administered by the current user. Messages sent in the last 30 seconds will not be deleted

Parameters:
  • chat_id (int) – Chat identifier of the channel direct messages chat

  • topic_id (int) – Identifier of the topic which messages will be deleted

  • min_date (int) – The minimum date of the messages to delete

  • max_date (int) – The maximum date of the messages to delete

Return type:

Union[Error, Ok]

Returns:

Ok

async deleteFile(file_id=0)[source]

Deletes a file from the TDLib file cache

Parameters:

file_id (int) – Identifier of the file to delete

Return type:

Union[Error, Ok]

Returns:

Ok

async deleteForumTopic(chat_id=0, message_thread_id=0)[source]

Deletes all messages in a forum topic; requires can_delete_messages administrator right in the supergroup unless the user is creator of the topic, the topic has no messages from other users and has at most 11 messages

Parameters:
  • chat_id (int) – Identifier of the chat

  • message_thread_id (int) – Message thread identifier of the forum topic

Return type:

Union[Error, Ok]

Returns:

Ok

async deleteGiftCollection(owner_id=None, collection_id=0)[source]

Deletes a gift collection. If the collection is owned by a channel chat, then requires can_post_messages administrator right in the channel chat

Parameters:
  • owner_id ("types.MessageSender") – Identifier of the user or the channel chat that owns the collection

  • collection_id (int) – Identifier of the gift collection

Return type:

Union[Error, Ok]

Returns:

Ok

async deleteLanguagePack(language_pack_id='')[source]

Deletes all information about a language pack in the current localization target. The language pack which is currently in use (including base language pack) or is being synchronized can’t be deleted. Can be called before authorization

Parameters:

language_pack_id (str) – Identifier of the language pack to delete

Return type:

Union[Error, Ok]

Returns:

Ok

async deleteMessages(chat_id=0, message_ids=None, revoke=False)[source]

Deletes messages

Parameters:
  • chat_id (int) – Chat identifier

  • message_ids (List[int]) – Identifiers of the messages to be deleted. Use messageProperties.can_be_deleted_only_for_self and messageProperties.can_be_deleted_for_all_users to get suitable messages

  • revoke (bool) – Pass true to delete messages for all chat members. Always true for supergroups, channels and secret chats

Return type:

Union[Error, Ok]

Returns:

Ok

async deletePassportElement(type=None)[source]

Deletes a Telegram Passport element

Parameters:

type ("types.PassportElementType") – Element type

Return type:

Union[Error, Ok]

Returns:

Ok

async deleteProfilePhoto(profile_photo_id=0)[source]

Deletes a profile photo

Parameters:

profile_photo_id (int) – Identifier of the profile photo to delete

Return type:

Union[Error, Ok]

Returns:

Ok

async deleteQuickReplyShortcut(shortcut_id=0)[source]

Deletes a quick reply shortcut

Parameters:

shortcut_id (int) – Unique identifier of the quick reply shortcut

Return type:

Union[Error, Ok]

Returns:

Ok

async deleteQuickReplyShortcutMessages(shortcut_id=0, message_ids=None)[source]

Deletes specified quick reply messages

Parameters:
  • shortcut_id (int) – Unique identifier of the quick reply shortcut to which the messages belong

  • message_ids (List[int]) – Unique identifiers of the messages

Return type:

Union[Error, Ok]

Returns:

Ok

Deletes revoked chat invite links. Requires administrator privileges and can_invite_users right in the chat for own links and owner privileges for other links

Parameters:
  • chat_id (int) – Chat identifier

  • invite_link (str) – Invite link to revoke

Return type:

Union[Error, Ok]

Returns:

Ok

async deleteSavedCredentials()[source]

Deletes saved credentials for all payment provider bots

Return type:

Union[Error, Ok]

Returns:

Ok

async deleteSavedMessagesTopicHistory(saved_messages_topic_id=0)[source]

Deletes all messages in a Saved Messages topic

Parameters:

saved_messages_topic_id (int) – Identifier of Saved Messages topic which messages will be deleted

Return type:

Union[Error, Ok]

Returns:

Ok

async deleteSavedMessagesTopicMessagesByDate(saved_messages_topic_id=0, min_date=0, max_date=0)[source]

Deletes all messages between the specified dates in a Saved Messages topic. Messages sent in the last 30 seconds will not be deleted

Parameters:
  • saved_messages_topic_id (int) – Identifier of Saved Messages topic which messages will be deleted

  • min_date (int) – The minimum date of the messages to delete

  • max_date (int) – The maximum date of the messages to delete

Return type:

Union[Error, Ok]

Returns:

Ok

async deleteSavedOrderInfo()[source]

Deletes saved order information

Return type:

Union[Error, Ok]

Returns:

Ok

async deleteStickerSet(name='')[source]

Completely deletes a sticker set

Parameters:

name (str) – Sticker set name. The sticker set must be owned by the current user

Return type:

Union[Error, Ok]

Returns:

Ok

async deleteStory(story_poster_chat_id=0, story_id=0)[source]

Deletes a previously posted story. Can be called only if story.can_be_deleted == true

Parameters:
  • story_poster_chat_id (int) – Identifier of the chat that posted the story

  • story_id (int) – Identifier of the story to delete

Return type:

Union[Error, Ok]

Returns:

Ok

async deleteStoryAlbum(chat_id=0, story_album_id=0)[source]

Deletes a story album. If the album is owned by a supergroup or a channel chat, then requires can_edit_stories administrator right in the chat

Parameters:
  • chat_id (int) – Identifier of the chat that owns the stories

  • story_album_id (int) – Identifier of the story album

Return type:

Union[Error, Ok]

Returns:

Ok

async destroy()[source]

Closes the TDLib instance, destroying all local data without a proper logout. The current user session will remain in the list of all active sessions. All local data will be destroyed. After the destruction completes updateAuthorizationState with authorizationStateClosed will be sent. Can be called before authorization

Return type:

Union[Error, Ok]

Returns:

Ok

async disableAllSupergroupUsernames(supergroup_id=0)[source]

Disables all active non-editable usernames of a supergroup or channel, requires owner privileges in the supergroup or channel

Parameters:

supergroup_id (int) – Identifier of the supergroup or channel

Return type:

Union[Error, Ok]

Returns:

Ok

async disableProxy()[source]

Disables the currently enabled proxy. Can be called before authorization

Return type:

Union[Error, Ok]

Returns:

Ok

async discardCall(call_id=0, is_disconnected=False, invite_link='', duration=0, is_video=False, connection_id=0)[source]

Discards a call

Parameters:
  • call_id (int) – Call identifier

  • is_disconnected (bool) – Pass true if the user was disconnected

  • invite_link (str) – If the call was upgraded to a group call, pass invite link to the group call

  • duration (int) – The call duration, in seconds

  • is_video (bool) – Pass true if the call was a video call

  • connection_id (int) – Identifier of the connection used during the call

Return type:

Union[Error, Ok]

Returns:

Ok

async disconnectAffiliateProgram(affiliate=None, url='')[source]

Disconnects an affiliate program from the given affiliate and immediately deactivates its referral link. Returns updated information about the disconnected affiliate program

Parameters:
  • affiliate ("types.AffiliateType") – The affiliate to which the affiliate program is connected

  • url (str) – The referral link of the affiliate program

Return type:

Union[Error, ConnectedAffiliateProgram]

Returns:

ConnectedAffiliateProgram

async disconnectAllWebsites()[source]

Disconnects all websites from the current user’s Telegram account

Return type:

Union[Error, Ok]

Returns:

Ok

async disconnectWebsite(website_id=0)[source]

Disconnects website from the current user’s Telegram account

Parameters:

website_id (int) – Website identifier

Return type:

Union[Error, Ok]

Returns:

Ok

async downloadFile(file_id=0, priority=0, offset=0, limit=0, synchronous=False)[source]

Downloads a file from the cloud. Download progress and completion of the download will be notified through updateFile updates

Parameters:
  • file_id (int) – Identifier of the file to download

  • priority (int) – Priority of the download (1-32). The higher the priority, the earlier the file will be downloaded. If the priorities of two files are equal, then the last one for which downloadFile/addFileToDownloads was called will be downloaded first

  • offset (int) – The starting position from which the file needs to be downloaded

  • limit (int) – Number of bytes which need to be downloaded starting from the "offset" position before the download will automatically be canceled; use 0 to download without a limit

  • synchronous (bool) – Pass true to return response only after the file download has succeeded, has failed, has been canceled, or a new downloadFile request with different offset/limit parameters was sent; pass false to return file state immediately, just after the download has been started

Return type:

Union[Error, File]

Returns:

File

async editBotMediaPreview(bot_user_id=0, language_code='', file_id=0, content=None)[source]

Replaces media preview in the list of media previews of a bot. Returns the new preview after edit is completed server-side

Parameters:
  • bot_user_id (int) – Identifier of the target bot. The bot must be owned and must have the main Web App

  • language_code (str) – Language code of the media preview to edit

  • file_id (int) – File identifier of the media to replace

  • content ("types.InputStoryContent") – Content of the new preview

Return type:

Union[Error, BotMediaPreview]

Returns:

BotMediaPreview

Edits a business chat link of the current account. Requires Telegram Business subscription. Returns the edited link

Parameters:
  • link (str) – The link to edit

  • link_info ("types.InputBusinessChatLink") – New description of the link

Return type:

Union[Error, BusinessChatLink]

Returns:

BusinessChatLink

async editBusinessMessageCaption(business_connection_id='', chat_id=0, message_id=0, reply_markup=None, caption=None, show_caption_above_media=False)[source]

Edits the caption of a message sent on behalf of a business account; for bots only

Parameters:
  • business_connection_id (str) – Unique identifier of business connection on behalf of which the message was sent

  • chat_id (int) – The chat the message belongs to

  • message_id (int) – Identifier of the message

  • reply_markup ("types.ReplyMarkup") – The new message reply markup; pass null if none

  • caption ("types.FormattedText") – New message content caption; pass null to remove caption; 0-getOption("message_caption_length_max") characters

  • show_caption_above_media (bool) – Pass true to show the caption above the media; otherwise, the caption will be shown below the media. May be true only for animation, photo, and video messages

Return type:

Union[Error, BusinessMessage]

Returns:

BusinessMessage

async editBusinessMessageChecklist(business_connection_id='', chat_id=0, message_id=0, reply_markup=None, checklist=None)[source]

Edits the content of a checklist in a message sent on behalf of a business account; for bots only

Parameters:
  • business_connection_id (str) – Unique identifier of business connection on behalf of which the message was sent

  • chat_id (int) – The chat the message belongs to

  • message_id (int) – Identifier of the message

  • reply_markup ("types.ReplyMarkup") – The new message reply markup; pass null if none

  • checklist ("types.InputChecklist") – The new checklist. If some tasks were completed, this information will be kept

Return type:

Union[Error, BusinessMessage]

Returns:

BusinessMessage

async editBusinessMessageLiveLocation(business_connection_id='', chat_id=0, message_id=0, reply_markup=None, location=None, live_period=0, heading=0, proximity_alert_radius=0)[source]

Edits the content of a live location in a message sent on behalf of a business account; for bots only

Parameters:
  • business_connection_id (str) – Unique identifier of business connection on behalf of which the message was sent

  • chat_id (int) – The chat the message belongs to

  • message_id (int) – Identifier of the message

  • reply_markup ("types.ReplyMarkup") – The new message reply markup; pass null if none

  • location ("types.Location") – New location content of the message; pass null to stop sharing the live location

  • live_period (int) – New time relative to the message send date, for which the location can be updated, in seconds. If 0x7FFFFFFF specified, then the location can be updated forever. Otherwise, must not exceed the current live_period by more than a day, and the live location expiration date must remain in the next 90 days. Pass 0 to keep the current live_period

  • heading (int) – The new direction in which the location moves, in degrees; 1-360. Pass 0 if unknown

  • proximity_alert_radius (int) – The new maximum distance for proximity alerts, in meters (0-100000). Pass 0 if the notification is disabled

Return type:

Union[Error, BusinessMessage]

Returns:

BusinessMessage

async editBusinessMessageMedia(business_connection_id='', chat_id=0, message_id=0, reply_markup=None, input_message_content=None)[source]

Edits the media content of a message with a text, an animation, an audio, a document, a photo or a video in a message sent on behalf of a business account; for bots only

Parameters:
  • business_connection_id (str) – Unique identifier of business connection on behalf of which the message was sent

  • chat_id (int) – The chat the message belongs to

  • message_id (int) – Identifier of the message

  • reply_markup ("types.ReplyMarkup") – The new message reply markup; pass null if none; for bots only

  • input_message_content ("types.InputMessageContent") – New content of the message. Must be one of the following types: inputMessageAnimation, inputMessageAudio, inputMessageDocument, inputMessagePhoto or inputMessageVideo

Return type:

Union[Error, BusinessMessage]

Returns:

BusinessMessage

async editBusinessMessageReplyMarkup(business_connection_id='', chat_id=0, message_id=0, reply_markup=None)[source]

Edits the reply markup of a message sent on behalf of a business account; for bots only

Parameters:
  • business_connection_id (str) – Unique identifier of business connection on behalf of which the message was sent

  • chat_id (int) – The chat the message belongs to

  • message_id (int) – Identifier of the message

  • reply_markup ("types.ReplyMarkup") – The new message reply markup; pass null if none

Return type:

Union[Error, BusinessMessage]

Returns:

BusinessMessage

async editBusinessMessageText(business_connection_id='', chat_id=0, message_id=0, reply_markup=None, input_message_content=None)[source]

Edits the text of a text or game message sent on behalf of a business account; for bots only

Parameters:
  • business_connection_id (str) – Unique identifier of business connection on behalf of which the message was sent

  • chat_id (int) – The chat the message belongs to

  • message_id (int) – Identifier of the message

  • reply_markup ("types.ReplyMarkup") – The new message reply markup; pass null if none

  • input_message_content ("types.InputMessageContent") – New text content of the message. Must be of type inputMessageText

Return type:

Union[Error, BusinessMessage]

Returns:

BusinessMessage

async editBusinessStory(story_poster_chat_id=0, story_id=0, content=None, areas=None, caption=None, privacy_settings=None)[source]

Changes a story posted by the bot on behalf of a business account; for bots only

Parameters:
  • story_poster_chat_id (int) – Identifier of the chat that posted the story

  • story_id (int) – Identifier of the story to edit

  • content ("types.InputStoryContent") – New content of the story

  • areas ("types.InputStoryAreas") – New clickable rectangle areas to be shown on the story media

  • caption ("types.FormattedText") – New story caption

  • privacy_settings ("types.StoryPrivacySettings") – The new privacy settings for the story

Return type:

Union[Error, Story]

Returns:

Story

async editChatFolder(chat_folder_id=0, folder=None)[source]

Edits existing chat folder. Returns information about the edited chat folder

Parameters:
  • chat_folder_id (int) – Chat folder identifier

  • folder ("types.ChatFolder") – The edited chat folder

Return type:

Union[Error, ChatFolderInfo]

Returns:

ChatFolderInfo

Edits an invite link for a chat folder

Parameters:
  • chat_folder_id (int) – Chat folder identifier

  • invite_link (str) – Invite link to be edited

  • name (str) – New name of the link; 0-32 characters

  • chat_ids (List[int]) – New identifiers of chats to be accessible by the invite link. Use getChatsForChatFolderInviteLink to get suitable chats. Basic groups will be automatically converted to supergroups before link editing

Return type:

Union[Error, ChatFolderInviteLink]

Returns:

ChatFolderInviteLink

Edits a non-primary invite link for a chat. Available for basic groups, supergroups, and channels. If the link creates a subscription, then expiration_date, member_limit and creates_join_request must not be used. Requires administrator privileges and can_invite_users right in the chat for own links and owner privileges for other links

Parameters:
  • chat_id (int) – Chat identifier

  • invite_link (str) – Invite link to be edited

  • name (str) – Invite link name; 0-32 characters

  • expiration_date (int) – Point in time (Unix timestamp) when the link will expire; pass 0 if never

  • member_limit (int) – The maximum number of chat members that can join the chat via the link simultaneously; 0-99999; pass 0 if not limited

  • creates_join_request (bool) – Pass true if users joining the chat via the link need to be approved by chat administrators. In this case, member_limit must be 0

Return type:

Union[Error, ChatInviteLink]

Returns:

ChatInviteLink

Edits a subscription invite link for a channel chat. Requires can_invite_users right in the chat for own links and owner privileges for other links

Parameters:
  • chat_id (int) – Chat identifier

  • invite_link (str) – Invite link to be edited

  • name (str) – Invite link name; 0-32 characters

Return type:

Union[Error, ChatInviteLink]

Returns:

ChatInviteLink

async editCustomLanguagePackInfo(info=None)[source]

Edits information about a custom local language pack in the current localization target. Can be called before authorization

Parameters:

info ("types.LanguagePackInfo") – New information about the custom local language pack

Return type:

Union[Error, Ok]

Returns:

Ok

async editForumTopic(chat_id=0, message_thread_id=0, name='', edit_icon_custom_emoji=False, icon_custom_emoji_id=0)[source]

Edits title and icon of a topic in a forum supergroup chat; requires can_manage_topics administrator right in the supergroup unless the user is creator of the topic

Parameters:
  • chat_id (int) – Identifier of the chat

  • message_thread_id (int) – Message thread identifier of the forum topic

  • name (str) – New name of the topic; 0-128 characters. If empty, the previous topic name is kept

  • edit_icon_custom_emoji (bool) – Pass true to edit the icon of the topic. Icon of the General topic can’t be edited

  • icon_custom_emoji_id (int) – Identifier of the new custom emoji for topic icon; pass 0 to remove the custom emoji. Ignored if edit_icon_custom_emoji is false. Telegram Premium users can use any custom emoji, other users can use only a custom emoji returned by getForumTopicDefaultIcons

Return type:

Union[Error, Ok]

Returns:

Ok

async editInlineMessageCaption(inline_message_id='', reply_markup=None, caption=None, show_caption_above_media=False)[source]

Edits the caption of an inline message sent via a bot; for bots only

Parameters:
  • inline_message_id (str) – Inline message identifier

  • reply_markup ("types.ReplyMarkup") – The new message reply markup; pass null if none

  • caption ("types.FormattedText") – New message content caption; pass null to remove caption; 0-getOption("message_caption_length_max") characters

  • show_caption_above_media (bool) – Pass true to show the caption above the media; otherwise, the caption will be shown below the media. May be true only for animation, photo, and video messages

Return type:

Union[Error, Ok]

Returns:

Ok

async editInlineMessageLiveLocation(inline_message_id='', reply_markup=None, location=None, live_period=0, heading=0, proximity_alert_radius=0)[source]

Edits the content of a live location in an inline message sent via a bot; for bots only

Parameters:
  • inline_message_id (str) – Inline message identifier

  • reply_markup ("types.ReplyMarkup") – The new message reply markup; pass null if none

  • location ("types.Location") – New location content of the message; pass null to stop sharing the live location

  • live_period (int) – New time relative to the message send date, for which the location can be updated, in seconds. If 0x7FFFFFFF specified, then the location can be updated forever. Otherwise, must not exceed the current live_period by more than a day, and the live location expiration date must remain in the next 90 days. Pass 0 to keep the current live_period

  • heading (int) – The new direction in which the location moves, in degrees; 1-360. Pass 0 if unknown

  • proximity_alert_radius (int) – The new maximum distance for proximity alerts, in meters (0-100000). Pass 0 if the notification is disabled

Return type:

Union[Error, Ok]

Returns:

Ok

async editInlineMessageMedia(inline_message_id='', reply_markup=None, input_message_content=None)[source]

Edits the media content of a message with a text, an animation, an audio, a document, a photo or a video in an inline message sent via a bot; for bots only

Parameters:
  • inline_message_id (str) – Inline message identifier

  • reply_markup ("types.ReplyMarkup") – The new message reply markup; pass null if none; for bots only

  • input_message_content ("types.InputMessageContent") – New content of the message. Must be one of the following types: inputMessageAnimation, inputMessageAudio, inputMessageDocument, inputMessagePhoto or inputMessageVideo

Return type:

Union[Error, Ok]

Returns:

Ok

async editInlineMessageReplyMarkup(inline_message_id='', reply_markup=None)[source]

Edits the reply markup of an inline message sent via a bot; for bots only

Parameters:
  • inline_message_id (str) – Inline message identifier

  • reply_markup ("types.ReplyMarkup") – The new message reply markup; pass null if none

Return type:

Union[Error, Ok]

Returns:

Ok

async editInlineMessageText(inline_message_id='', reply_markup=None, input_message_content=None)[source]

Edits the text of an inline text or game message sent via a bot; for bots only

Parameters:
  • inline_message_id (str) – Inline message identifier

  • reply_markup ("types.ReplyMarkup") – The new message reply markup; pass null if none

  • input_message_content ("types.InputMessageContent") – New text content of the message. Must be of type inputMessageText

Return type:

Union[Error, Ok]

Returns:

Ok

async editMessageCaption(chat_id=0, message_id=0, reply_markup=None, caption=None, show_caption_above_media=False)[source]

Edits the message content caption. Returns the edited message after the edit is completed on the server side

Parameters:
  • chat_id (int) – The chat the message belongs to

  • message_id (int) – Identifier of the message. Use messageProperties.can_be_edited to check whether the message can be edited

  • reply_markup ("types.ReplyMarkup") – The new message reply markup; pass null if none; for bots only

  • caption ("types.FormattedText") – New message content caption; 0-getOption("message_caption_length_max") characters; pass null to remove caption

  • show_caption_above_media (bool) – Pass true to show the caption above the media; otherwise, the caption will be shown below the media. May be true only for animation, photo, and video messages

Return type:

Union[Error, Message]

Returns:

Message

async editMessageChecklist(chat_id=0, message_id=0, reply_markup=None, checklist=None)[source]

Edits the message content of a checklist. Returns the edited message after the edit is completed on the server side

Parameters:
  • chat_id (int) – The chat the message belongs to

  • message_id (int) – Identifier of the message. Use messageProperties.can_be_edited to check whether the message can be edited

  • reply_markup ("types.ReplyMarkup") – The new message reply markup; pass null if none; for bots only

  • checklist ("types.InputChecklist") – The new checklist. If some tasks were completed, this information will be kept

Return type:

Union[Error, Message]

Returns:

Message

async editMessageLiveLocation(chat_id=0, message_id=0, reply_markup=None, location=None, live_period=0, heading=0, proximity_alert_radius=0)[source]

Edits the message content of a live location. Messages can be edited for a limited period of time specified in the live location. Returns the edited message after the edit is completed on the server side

Parameters:
  • chat_id (int) – The chat the message belongs to

  • message_id (int) – Identifier of the message. Use messageProperties.can_be_edited to check whether the message can be edited

  • reply_markup ("types.ReplyMarkup") – The new message reply markup; pass null if none; for bots only

  • location ("types.Location") – New location content of the message; pass null to stop sharing the live location

  • live_period (int) – New time relative to the message send date, for which the location can be updated, in seconds. If 0x7FFFFFFF specified, then the location can be updated forever. Otherwise, must not exceed the current live_period by more than a day, and the live location expiration date must remain in the next 90 days. Pass 0 to keep the current live_period

  • heading (int) – The new direction in which the location moves, in degrees; 1-360. Pass 0 if unknown

  • proximity_alert_radius (int) – The new maximum distance for proximity alerts, in meters (0-100000). Pass 0 if the notification is disabled

Return type:

Union[Error, Message]

Returns:

Message

async editMessageMedia(chat_id=0, message_id=0, reply_markup=None, input_message_content=None)[source]

Edits the media content of a message, including message caption. If only the caption needs to be edited, use editMessageCaption instead. The type of message content in an album can’t be changed with exception of replacing a photo with a video or vice versa. Returns the edited message after the edit is completed on the server side

Parameters:
  • chat_id (int) – The chat the message belongs to

  • message_id (int) – Identifier of the message. Use messageProperties.can_edit_media to check whether the message can be edited

  • reply_markup ("types.ReplyMarkup") – The new message reply markup; pass null if none; for bots only

  • input_message_content ("types.InputMessageContent") – New content of the message. Must be one of the following types: inputMessageAnimation, inputMessageAudio, inputMessageDocument, inputMessagePhoto or inputMessageVideo

Return type:

Union[Error, Message]

Returns:

Message

async editMessageReplyMarkup(chat_id=0, message_id=0, reply_markup=None)[source]

Edits the message reply markup; for bots only. Returns the edited message after the edit is completed on the server side

Parameters:
  • chat_id (int) – The chat the message belongs to

  • message_id (int) – Identifier of the message. Use messageProperties.can_be_edited to check whether the message can be edited

  • reply_markup ("types.ReplyMarkup") – The new message reply markup; pass null if none

Return type:

Union[Error, Message]

Returns:

Message

async editMessageSchedulingState(chat_id=0, message_id=0, scheduling_state=None)[source]

Edits the time when a scheduled message will be sent. Scheduling state of all messages in the same album or forwarded together with the message will be also changed

Parameters:
  • chat_id (int) – The chat the message belongs to

  • message_id (int) – Identifier of the message. Use messageProperties.can_edit_scheduling_state to check whether the message is suitable

  • scheduling_state ("types.MessageSchedulingState") – The new message scheduling state; pass null to send the message immediately. Must be null for messages in the state messageSchedulingStateSendWhenVideoProcessed

Return type:

Union[Error, Ok]

Returns:

Ok

async editMessageText(chat_id=0, message_id=0, reply_markup=None, input_message_content=None)[source]

Edits the text of a message (or a text of a game message). Returns the edited message after the edit is completed on the server side

Parameters:
  • chat_id (int) – The chat the message belongs to

  • message_id (int) – Identifier of the message. Use messageProperties.can_be_edited to check whether the message can be edited

  • reply_markup ("types.ReplyMarkup") – The new message reply markup; pass null if none; for bots only

  • input_message_content ("types.InputMessageContent") – New text content of the message. Must be of type inputMessageText

Return type:

Union[Error, Message]

Returns:

Message

async editProxy(proxy_id=0, server='', port=0, enable=False, type=None)[source]

Edits an existing proxy server for network requests. Can be called before authorization

Parameters:
  • proxy_id (int) – Proxy identifier

  • server (str) – Proxy server domain or IP address

  • port (int) – Proxy server port

  • enable (bool) – Pass true to immediately enable the proxy

  • type ("types.ProxyType") – Proxy type

Return type:

Union[Error, Proxy]

Returns:

Proxy

async editQuickReplyMessage(shortcut_id=0, message_id=0, input_message_content=None)[source]

Asynchronously edits the text, media or caption of a quick reply message. Use quickReplyMessage.can_be_edited to check whether a message can be edited. Media message can be edited only to a media message. Checklist messages can be edited only to a checklist message. The type of message content in an album can’t be changed with exception of replacing a photo with a video or vice versa

Parameters:
  • shortcut_id (int) – Unique identifier of the quick reply shortcut with the message

  • message_id (int) – Identifier of the message

  • input_message_content ("types.InputMessageContent") – New content of the message. Must be one of the following types: inputMessageAnimation, inputMessageAudio, inputMessageChecklist, inputMessageDocument, inputMessagePhoto, inputMessageText, or inputMessageVideo

Return type:

Union[Error, Ok]

Returns:

Ok

async editStarSubscription(subscription_id='', is_canceled=False)[source]

Cancels or re-enables Telegram Star subscription

Parameters:
  • subscription_id (str) – Identifier of the subscription to change

  • is_canceled (bool) – New value of is_canceled

Return type:

Union[Error, Ok]

Returns:

Ok

async editStory(story_poster_chat_id=0, story_id=0, content=None, areas=None, caption=None)[source]

Changes content and caption of a story. Can be called only if story.can_be_edited == true

Parameters:
  • story_poster_chat_id (int) – Identifier of the chat that posted the story

  • story_id (int) – Identifier of the story to edit

  • content ("types.InputStoryContent") – New content of the story; pass null to keep the current content

  • areas ("types.InputStoryAreas") – New clickable rectangle areas to be shown on the story media; pass null to keep the current areas. Areas can’t be edited if story content isn’t changed

  • caption ("types.FormattedText") – New story caption; pass null to keep the current caption

Return type:

Union[Error, Ok]

Returns:

Ok

async editStoryCover(story_poster_chat_id=0, story_id=0, cover_frame_timestamp=0.0)[source]

Changes cover of a video story. Can be called only if story.can_be_edited == true and the story isn’t being edited now

Parameters:
  • story_poster_chat_id (int) – Identifier of the chat that posted the story

  • story_id (int) – Identifier of the story to edit

  • cover_frame_timestamp (float) – New timestamp of the frame, which will be used as video thumbnail

Return type:

Union[Error, Ok]

Returns:

Ok

async editUserStarSubscription(user_id=0, telegram_payment_charge_id='', is_canceled=False)[source]

Cancels or re-enables Telegram Star subscription for a user; for bots only

Parameters:
  • user_id (int) – User identifier

  • telegram_payment_charge_id (str) – Telegram payment identifier of the subscription

  • is_canceled (bool) – Pass true to cancel the subscription; pass false to allow the user to enable it

Return type:

Union[Error, Ok]

Returns:

Ok

async enableProxy(proxy_id=0)[source]

Enables a proxy. Only one proxy can be enabled at a time. Can be called before authorization

Parameters:

proxy_id (int) – Proxy identifier

Return type:

Union[Error, Ok]

Returns:

Ok

async encryptGroupCallData(group_call_id=0, data_channel=None, data=b'', unencrypted_prefix_size=0)[source]

Encrypts group call data before sending them over network using tgcalls

Parameters:
  • group_call_id (int) – Group call identifier. The call must not be a video chat

  • data_channel ("types.GroupCallDataChannel") – Data channel for which data is encrypted

  • data (bytes) – Data to encrypt

  • unencrypted_prefix_size (int) – Size of data prefix that must be kept unencrypted

Return type:

Union[Error, Data]

Returns:

Data

async endGroupCall(group_call_id=0)[source]

Ends a group call. Requires groupCall.can_be_managed right for video chats or groupCall.is_owned otherwise

Parameters:

group_call_id (int) – Group call identifier

Return type:

Union[Error, Ok]

Returns:

Ok

async endGroupCallRecording(group_call_id=0)[source]

Ends recording of an active group call; for video chats only. Requires groupCall.can_be_managed right

Parameters:

group_call_id (int) – Group call identifier

Return type:

Union[Error, Ok]

Returns:

Ok

async endGroupCallScreenSharing(group_call_id=0)[source]

Ends screen sharing in a joined group call

Parameters:

group_call_id (int) – Group call identifier

Return type:

Union[Error, Ok]

Returns:

Ok

async finishFileGeneration(generation_id=0, error=None)[source]

Finishes the file generation

Parameters:
  • generation_id (int) – The identifier of the generation process

  • error ("types.Error") – If passed, the file generation has failed and must be terminated; pass null if the file generation succeeded

Return type:

Union[Error, Ok]

Returns:

Ok

async forwardMessages(chat_id=0, message_thread_id=0, from_chat_id=0, message_ids=None, options=None, send_copy=False, remove_caption=False)[source]

Forwards previously sent messages. Returns the forwarded messages in the same order as the message identifiers passed in message_ids. If a message can’t be forwarded, null will be returned instead of the message

Parameters:
  • chat_id (int) – Identifier of the chat to which to forward messages

  • message_thread_id (int) – If not 0, the message thread identifier in which the message will be sent; for forum threads only

  • from_chat_id (int) – Identifier of the chat from which to forward messages

  • message_ids (List[int]) – Identifiers of the messages to forward. Message identifiers must be in a strictly increasing order. At most 100 messages can be forwarded simultaneously. A message can be forwarded only if messageProperties.can_be_forwarded

  • options ("types.MessageSendOptions") – Options to be used to send the messages; pass null to use default options

  • send_copy (bool) – Pass true to copy content of the messages without reference to the original sender. Always true if the messages are forwarded to a secret chat or are local. Use messageProperties.can_be_copied and messageProperties.can_be_copied_to_secret_chat to check whether the message is suitable

  • remove_caption (bool) – Pass true to remove media captions of message copies. Ignored if send_copy is false

Return type:

Union[Error, Messages]

Returns:

Messages

async getAccountTtl()[source]

Returns the period of inactivity after which the account of the current user will automatically be deleted

Return type:

Union[Error, AccountTtl]

Returns:

AccountTtl

async getActiveSessions()[source]

Returns all active sessions of the current user

Return type:

Union[Error, Sessions]

Returns:

Sessions

async getAllPassportElements(password='')[source]

Returns all available Telegram Passport elements

Parameters:

password (str) – The 2-step verification password of the current user

Return type:

Union[Error, PassportElements]

Returns:

PassportElements

async getAllStickerEmojis(sticker_type=None, query='', chat_id=0, return_only_main_emoji=False)[source]

Returns unique emoji that correspond to stickers to be found by the getStickers(sticker_type, query, 1000000, chat_id)

Parameters:
  • sticker_type ("types.StickerType") – Type of the stickers to search for

  • query (str) – Search query

  • chat_id (int) – Chat identifier for which to find stickers

  • return_only_main_emoji (bool) – Pass true if only main emoji for each found sticker must be included in the result

Return type:

Union[Error, Emojis]

Returns:

Emojis

async getAnimatedEmoji(emoji='')[source]

Returns an animated emoji corresponding to a given emoji. Returns a 404 error if the emoji has no animated emoji

Parameters:

emoji (str) – The emoji

Return type:

Union[Error, AnimatedEmoji]

Returns:

AnimatedEmoji

async getApplicationConfig()[source]

Returns application config, provided by the server. Can be called before authorization

Return type:

Union[Error, JsonValue]

Returns:

JsonValue

Returns the link for downloading official Telegram application to be used when the current user invites friends to Telegram

Return type:

Union[Error, HttpUrl]

Returns:

HttpUrl

async getArchiveChatListSettings()[source]

Returns settings for automatic moving of chats to and from the Archive chat lists

Return type:

Union[Error, ArchiveChatListSettings]

Returns:

ArchiveChatListSettings

async getArchivedStickerSets(sticker_type=None, offset_sticker_set_id=0, limit=0)[source]

Returns a list of archived sticker sets

Parameters:
  • sticker_type ("types.StickerType") – Type of the sticker sets to return

  • offset_sticker_set_id (int) – Identifier of the sticker set from which to return the result; use 0 to get results from the beginning

  • limit (int) – The maximum number of sticker sets to return; up to 100

Return type:

Union[Error, StickerSets]

Returns:

StickerSets

async getAttachedStickerSets(file_id=0)[source]

Returns a list of sticker sets attached to a file, including regular, mask, and emoji sticker sets. Currently, only animations, photos, and videos can have attached sticker sets

Parameters:

file_id (int) – File identifier

Return type:

Union[Error, StickerSets]

Returns:

StickerSets

async getAttachmentMenuBot(bot_user_id=0)[source]

Returns information about a bot that can be added to attachment or side menu

Parameters:

bot_user_id (int) – Bot’s user identifier

Return type:

Union[Error, AttachmentMenuBot]

Returns:

AttachmentMenuBot

async getAuthorizationState()[source]

Returns the current authorization state. This is an offline method. For informational purposes only. Use updateAuthorizationState instead to maintain the current authorization state. Can be called before initialization

Return type:

Union[Error, AuthorizationState]

Returns:

AuthorizationState

async getAutoDownloadSettingsPresets()[source]

Returns auto-download settings presets for the current user

Return type:

Union[Error, AutoDownloadSettingsPresets]

Returns:

AutoDownloadSettingsPresets

async getAutosaveSettings()[source]

Returns autosave settings for the current user

Return type:

Union[Error, AutosaveSettings]

Returns:

AutosaveSettings

async getAvailableChatBoostSlots()[source]

Returns the list of available chat boost slots for the current user

Return type:

Union[Error, ChatBoostSlots]

Returns:

ChatBoostSlots

async getAvailableGifts()[source]

Returns gifts that can be sent to other users and channel chats

Return type:

Union[Error, AvailableGifts]

Returns:

AvailableGifts

async getBackgroundUrl(name='', type=None)[source]

Constructs a persistent HTTP URL for a background

Parameters:
  • name (str) – Background name

  • type ("types.BackgroundType") – Background type; backgroundTypeChatTheme isn’t supported

Return type:

Union[Error, HttpUrl]

Returns:

HttpUrl

async getBankCardInfo(bank_card_number='')[source]

Returns information about a bank card

Parameters:

bank_card_number (str) – The bank card number

Return type:

Union[Error, BankCardInfo]

Returns:

BankCardInfo

async getBasicGroup(basic_group_id=0)[source]

Returns information about a basic group by its identifier. This is an offline method if the current user is not a bot

Parameters:

basic_group_id (int) – Basic group identifier

Return type:

Union[Error, BasicGroup]

Returns:

BasicGroup

async getBasicGroupFullInfo(basic_group_id=0)[source]

Returns full information about a basic group by its identifier

Parameters:

basic_group_id (int) – Basic group identifier

Return type:

Union[Error, BasicGroupFullInfo]

Returns:

BasicGroupFullInfo

async getBlockedMessageSenders(block_list=None, offset=0, limit=0)[source]

Returns users and chats that were blocked by the current user

Parameters:
  • block_list ("types.BlockList") – Block list from which to return users

  • offset (int) – Number of users and chats to skip in the result; must be non-negative

  • limit (int) – The maximum number of users and chats to return; up to 100

Return type:

Union[Error, MessageSenders]

Returns:

MessageSenders

async getBotInfoDescription(bot_user_id=0, language_code='')[source]

Returns the text shown in the chat with a bot if the chat is empty in the given language. Can be called only if userTypeBot.can_be_edited == true

Parameters:
  • bot_user_id (int) – Identifier of the target bot

  • language_code (str) – A two-letter ISO 639-1 language code or an empty string

Return type:

Union[Error, Text]

Returns:

Text

async getBotInfoShortDescription(bot_user_id=0, language_code='')[source]

Returns the text shown on a bot’s profile page and sent together with the link when users share the bot in the given language. Can be called only if userTypeBot.can_be_edited == true

Parameters:
  • bot_user_id (int) – Identifier of the target bot

  • language_code (str) – A two-letter ISO 639-1 language code or an empty string

Return type:

Union[Error, Text]

Returns:

Text

async getBotMediaPreviewInfo(bot_user_id=0, language_code='')[source]

Returns the list of media previews for the given language and the list of languages for which the bot has dedicated previews

Parameters:
  • bot_user_id (int) – Identifier of the target bot. The bot must be owned and must have the main Web App

  • language_code (str) – A two-letter ISO 639-1 language code for which to get previews. If empty, then default previews are returned

Return type:

Union[Error, BotMediaPreviewInfo]

Returns:

BotMediaPreviewInfo

async getBotMediaPreviews(bot_user_id=0)[source]

Returns the list of media previews of a bot

Parameters:

bot_user_id (int) – Identifier of the target bot. The bot must have the main Web App

Return type:

Union[Error, BotMediaPreviews]

Returns:

BotMediaPreviews

async getBotName(bot_user_id=0, language_code='')[source]

Returns the name of a bot in the given language. Can be called only if userTypeBot.can_be_edited == true

Parameters:
  • bot_user_id (int) – Identifier of the target bot

  • language_code (str) – A two-letter ISO 639-1 language code or an empty string

Return type:

Union[Error, Text]

Returns:

Text

async getBotSimilarBotCount(bot_user_id=0, return_local=False)[source]

Returns approximate number of bots similar to the given bot

Parameters:
  • bot_user_id (int) – User identifier of the target bot

  • return_local (bool) – Pass true to get the number of bots without sending network requests, or -1 if the number of bots is unknown locally

Return type:

Union[Error, Count]

Returns:

Count

async getBotSimilarBots(bot_user_id=0)[source]

Returns a list of bots similar to the given bot

Parameters:

bot_user_id (int) – User identifier of the target bot

Return type:

Union[Error, Users]

Returns:

Users

async getBusinessAccountStarAmount(business_connection_id='')[source]

Returns the amount of Telegram Stars owned by a business account; for bots only

Parameters:

business_connection_id (str) – Unique identifier of business connection

Return type:

Union[Error, StarAmount]

Returns:

StarAmount

async getBusinessChatLinkInfo(link_name='')[source]

Returns information about a business chat link

Parameters:

link_name (str) – Name of the link

Return type:

Union[Error, BusinessChatLinkInfo]

Returns:

BusinessChatLinkInfo

Returns business chat links created for the current account

Return type:

Union[Error, BusinessChatLinks]

Returns:

BusinessChatLinks

async getBusinessConnectedBot()[source]

Returns the business bot that is connected to the current user account. Returns a 404 error if there is no connected bot

Return type:

Union[Error, BusinessConnectedBot]

Returns:

BusinessConnectedBot

async getBusinessConnection(connection_id='')[source]

Returns information about a business connection by its identifier; for bots only

Parameters:

connection_id (str) – Identifier of the business connection to return

Return type:

Union[Error, BusinessConnection]

Returns:

BusinessConnection

async getBusinessFeatures(source=None)[source]

Returns information about features, available to Business users

Parameters:

source ("types.BusinessFeature") – Source of the request; pass null if the method is called from settings or some non-standard source

Return type:

Union[Error, BusinessFeatures]

Returns:

BusinessFeatures

async getCallbackQueryAnswer(chat_id=0, message_id=0, payload=None)[source]

Sends a callback query to a bot and returns an answer. Returns an error with code 502 if the bot fails to answer the query before the query timeout expires

Parameters:
  • chat_id (int) – Identifier of the chat with the message

  • message_id (int) – Identifier of the message from which the query originated. The message must not be scheduled

  • payload ("types.CallbackQueryPayload") – Query payload

Return type:

Union[Error, CallbackQueryAnswer]

Returns:

CallbackQueryAnswer

async getCallbackQueryMessage(chat_id=0, message_id=0, callback_query_id=0)[source]

Returns information about a message with the callback button that originated a callback query; for bots only

Parameters:
  • chat_id (int) – Identifier of the chat the message belongs to

  • message_id (int) – Message identifier

  • callback_query_id (int) – Identifier of the callback query

Return type:

Union[Error, Message]

Returns:

Message

async getChat(chat_id=0)[source]

Returns information about a chat by its identifier. This is an offline method if the current user is not a bot

Parameters:

chat_id (int) – Chat identifier

Return type:

Union[Error, Chat]

Returns:

Chat

async getChatActiveStories(chat_id=0)[source]

Returns the list of active stories posted by the given chat

Parameters:

chat_id (int) – Chat identifier

Return type:

Union[Error, ChatActiveStories]

Returns:

ChatActiveStories

async getChatAdministrators(chat_id=0)[source]

Returns a list of administrators of the chat with their custom titles

Parameters:

chat_id (int) – Chat identifier

Return type:

Union[Error, ChatAdministrators]

Returns:

ChatAdministrators

async getChatArchivedStories(chat_id=0, from_story_id=0, limit=0)[source]

Returns the list of all stories posted by the given chat; requires can_edit_stories administrator right in the chat. The stories are returned in reverse chronological order (i.e., in order of decreasing story_id). For optimal performance, the number of returned stories is chosen by TDLib

Parameters:
  • chat_id (int) – Chat identifier

  • from_story_id (int) – Identifier of the story starting from which stories must be returned; use 0 to get results from the last story

  • limit (int) – The maximum number of stories to be returned. For optimal performance, the number of returned stories is chosen by TDLib and can be smaller than the specified limit

Return type:

Union[Error, Stories]

Returns:

Stories

async getChatAvailableMessageSenders(chat_id=0)[source]

Returns the list of message sender identifiers, which can be used to send messages in a chat

Parameters:

chat_id (int) – Chat identifier

Return type:

Union[Error, ChatMessageSenders]

Returns:

ChatMessageSenders

async getChatAvailablePaidMessageReactionSenders(chat_id=0)[source]

Returns the list of message sender identifiers, which can be used to send a paid reaction in a chat

Parameters:

chat_id (int) – Chat identifier

Return type:

Union[Error, MessageSenders]

Returns:

MessageSenders

async getChatBoostFeatures(is_channel=False)[source]

Returns the list of features available for different chat boost levels. This is an offline method

Parameters:

is_channel (bool) – Pass true to get the list of features for channels; pass false to get the list of features for supergroups

Return type:

Union[Error, ChatBoostFeatures]

Returns:

ChatBoostFeatures

async getChatBoostLevelFeatures(is_channel=False, level=0)[source]

Returns the list of features available on the specific chat boost level. This is an offline method

Parameters:
  • is_channel (bool) – Pass true to get the list of features for channels; pass false to get the list of features for supergroups

  • level (int) – Chat boost level

Return type:

Union[Error, ChatBoostLevelFeatures]

Returns:

ChatBoostLevelFeatures

Returns an HTTPS link to boost the specified supergroup or channel chat

Parameters:

chat_id (int) – Identifier of the chat

Return type:

Union[Error, ChatBoostLink]

Returns:

ChatBoostLink

async getChatBoostLinkInfo(url='')[source]

Returns information about a link to boost a chat. Can be called for any internal link of the type internalLinkTypeChatBoost

Parameters:

url (str) – The link to boost a chat

Return type:

Union[Error, ChatBoostLinkInfo]

Returns:

ChatBoostLinkInfo

async getChatBoostStatus(chat_id=0)[source]

Returns the current boost status for a supergroup or a channel chat

Parameters:

chat_id (int) – Identifier of the chat

Return type:

Union[Error, ChatBoostStatus]

Returns:

ChatBoostStatus

async getChatBoosts(chat_id=0, only_gift_codes=False, offset='', limit=0)[source]

Returns the list of boosts applied to a chat; requires administrator rights in the chat

Parameters:
  • chat_id (int) – Identifier of the chat

  • only_gift_codes (bool) – Pass true to receive only boosts received from gift codes and giveaways created by the chat

  • offset (str) – Offset of the first entry to return as received from the previous request; use empty string to get the first chunk of results

  • limit (int) – The maximum number of boosts to be returned; up to 100. For optimal performance, the number of returned boosts can be smaller than the specified limit

Return type:

Union[Error, FoundChatBoosts]

Returns:

FoundChatBoosts

async getChatEventLog(chat_id=0, query='', from_event_id=0, limit=0, filters=None, user_ids=None)[source]

Returns a list of service actions taken by chat members and administrators in the last 48 hours. Available only for supergroups and channels. Requires administrator rights. Returns results in reverse chronological order (i.e., in order of decreasing event_id)

Parameters:
  • chat_id (int) – Chat identifier

  • query (str) – Search query by which to filter events

  • from_event_id (int) – Identifier of an event from which to return results. Use 0 to get results from the latest events

  • limit (int) – The maximum number of events to return; up to 100

  • filters ("types.ChatEventLogFilters") – The types of events to return; pass null to get chat events of all types

  • user_ids (List[int]) – User identifiers by which to filter events. By default, events relating to all users will be returned

Return type:

Union[Error, ChatEvents]

Returns:

ChatEvents

async getChatFolder(chat_folder_id=0)[source]

Returns information about a chat folder by its identifier

Parameters:

chat_folder_id (int) – Chat folder identifier

Return type:

Union[Error, ChatFolder]

Returns:

ChatFolder

async getChatFolderChatCount(folder=None)[source]

Returns approximate number of chats in a being created chat folder. Main and archive chat lists must be fully preloaded for this function to work correctly

Parameters:

folder ("types.ChatFolder") – The new chat folder

Return type:

Union[Error, Count]

Returns:

Count

async getChatFolderChatsToLeave(chat_folder_id=0)[source]

Returns identifiers of pinned or always included chats from a chat folder, which are suggested to be left when the chat folder is deleted

Parameters:

chat_folder_id (int) – Chat folder identifier

Return type:

Union[Error, Chats]

Returns:

Chats

async getChatFolderDefaultIconName(folder=None)[source]

Returns default icon name for a folder. Can be called synchronously

Parameters:

folder ("types.ChatFolder") – Chat folder

Return type:

Union[Error, ChatFolderIcon]

Returns:

ChatFolderIcon

Returns invite links created by the current user for a shareable chat folder

Parameters:

chat_folder_id (int) – Chat folder identifier

Return type:

Union[Error, ChatFolderInviteLinks]

Returns:

ChatFolderInviteLinks

async getChatFolderNewChats(chat_folder_id=0)[source]

Returns new chats added to a shareable chat folder by its owner. The method must be called at most once in getOption("chat_folder_new_chats_update_period") for the given chat folder

Parameters:

chat_folder_id (int) – Chat folder identifier

Return type:

Union[Error, Chats]

Returns:

Chats

async getChatHistory(chat_id=0, from_message_id=0, offset=0, limit=0, only_local=False)[source]

Returns messages in a chat. The messages are returned in reverse chronological order (i.e., in order of decreasing message_id). For optimal performance, the number of returned messages is chosen by TDLib. This is an offline method if only_local is true

Parameters:
  • chat_id (int) – Chat identifier

  • from_message_id (int) – Identifier of the message starting from which history must be fetched; use 0 to get results from the last message

  • offset (int) – Specify 0 to get results from exactly the message from_message_id or a negative number from -99 to -1 to get additionally -offset newer messages

  • limit (int) – The maximum number of messages to be returned; must be positive and can’t be greater than 100. If the offset is negative, then the limit must be greater than or equal to -offset. For optimal performance, the number of returned messages is chosen by TDLib and can be smaller than the specified limit

  • only_local (bool) – Pass true to get only messages that are available without sending network requests

Return type:

Union[Error, Messages]

Returns:

Messages

Returns information about an invite link. Requires administrator privileges and can_invite_users right in the chat to get own links and owner privileges to get other links

Parameters:
  • chat_id (int) – Chat identifier

  • invite_link (str) – Invite link to get

Return type:

Union[Error, ChatInviteLink]

Returns:

ChatInviteLink

async getChatInviteLinkCounts(chat_id=0)[source]

Returns the list of chat administrators with number of their invite links. Requires owner privileges in the chat

Parameters:

chat_id (int) – Chat identifier

Return type:

Union[Error, ChatInviteLinkCounts]

Returns:

ChatInviteLinkCounts

async getChatInviteLinkMembers(chat_id=0, invite_link='', only_with_expired_subscription=False, offset_member=None, limit=0)[source]

Returns chat members joined a chat via an invite link. Requires administrator privileges and can_invite_users right in the chat for own links and owner privileges for other links

Parameters:
  • chat_id (int) – Chat identifier

  • invite_link (str) – Invite link for which to return chat members

  • only_with_expired_subscription (bool) – Pass true if the link is a subscription link and only members with expired subscription must be returned

  • offset_member ("types.ChatInviteLinkMember") – A chat member from which to return next chat members; pass null to get results from the beginning

  • limit (int) – The maximum number of chat members to return; up to 100

Return type:

Union[Error, ChatInviteLinkMembers]

Returns:

ChatInviteLinkMembers

Returns invite links for a chat created by specified administrator. Requires administrator privileges and can_invite_users right in the chat to get own links and owner privileges to get other links

Parameters:
  • chat_id (int) – Chat identifier

  • creator_user_id (int) – User identifier of a chat administrator. Must be an identifier of the current user for non-owner

  • is_revoked (bool) – Pass true if revoked links needs to be returned instead of active or expired

  • offset_date (int) – Creation date of an invite link starting after which to return invite links; use 0 to get results from the beginning

  • offset_invite_link (str) – Invite link starting after which to return invite links; use empty string to get results from the beginning

  • limit (int) – The maximum number of invite links to return; up to 100

Return type:

Union[Error, ChatInviteLinks]

Returns:

ChatInviteLinks

async getChatJoinRequests(chat_id=0, invite_link='', query='', offset_request=None, limit=0)[source]

Returns pending join requests in a chat

Parameters:
  • chat_id (int) – Chat identifier

  • invite_link (str) – Invite link for which to return join requests. If empty, all join requests will be returned. Requires administrator privileges and can_invite_users right in the chat for own links and owner privileges for other links

  • query (str) – A query to search for in the first names, last names and usernames of the users to return

  • offset_request ("types.ChatJoinRequest") – A chat join request from which to return next requests; pass null to get results from the beginning

  • limit (int) – The maximum number of requests to join the chat to return

Return type:

Union[Error, ChatJoinRequests]

Returns:

ChatJoinRequests

async getChatListsToAddChat(chat_id=0)[source]

Returns chat lists to which the chat can be added. This is an offline method

Parameters:

chat_id (int) – Chat identifier

Return type:

Union[Error, ChatLists]

Returns:

ChatLists

async getChatMember(chat_id=0, member_id=None)[source]

Returns information about a single member of a chat

Parameters:
  • chat_id (int) – Chat identifier

  • member_id ("types.MessageSender") – Member identifier

Return type:

Union[Error, ChatMember]

Returns:

ChatMember

async getChatMessageByDate(chat_id=0, date=0)[source]

Returns the last message sent in a chat no later than the specified date. Returns a 404 error if such message doesn’t exist

Parameters:
  • chat_id (int) – Chat identifier

  • date (int) – Point in time (Unix timestamp) relative to which to search for messages

Return type:

Union[Error, Message]

Returns:

Message

async getChatMessageCalendar(chat_id=0, topic_id=None, filter=None, from_message_id=0)[source]

Returns information about the next messages of the specified type in the chat split by days. Returns the results in reverse chronological order. Can return partial result for the last returned day. Behavior of this method depends on the value of the option "utc_time_offset"

Parameters:
  • chat_id (int) – Identifier of the chat in which to return information about messages

  • topic_id ("types.MessageTopic") – Pass topic identifier to get the result only in specific topic; pass null to get the result in all topics; forum topics aren’t supported

  • filter ("types.SearchMessagesFilter") – Filter for message content. Filters searchMessagesFilterEmpty, searchMessagesFilterMention, searchMessagesFilterUnreadMention, and searchMessagesFilterUnreadReaction are unsupported in this function

  • from_message_id (int) – The message identifier from which to return information about messages; use 0 to get results from the last message

Return type:

Union[Error, MessageCalendar]

Returns:

MessageCalendar

async getChatMessageCount(chat_id=0, topic_id=None, filter=None, return_local=False)[source]

Returns approximate number of messages of the specified type in the chat or its topic

Parameters:
  • chat_id (int) – Identifier of the chat in which to count messages

  • topic_id ("types.MessageTopic") – Pass topic identifier to get number of messages only in specific topic; pass null to get number of messages in all topics

  • filter ("types.SearchMessagesFilter") – Filter for message content; searchMessagesFilterEmpty is unsupported in this function

  • return_local (bool) – Pass true to get the number of messages without sending network requests, or -1 if the number of messages is unknown locally

Return type:

Union[Error, Count]

Returns:

Count

async getChatMessagePosition(chat_id=0, topic_id=None, filter=None, message_id=0)[source]

Returns approximate 1-based position of a message among messages, which can be found by the specified filter in the chat and topic. Cannot be used in secret chats

Parameters:
  • chat_id (int) – Identifier of the chat in which to find message position

  • topic_id ("types.MessageTopic") – Pass topic identifier to get position among messages only in specific topic; pass null to get position among all chat messages

  • filter ("types.SearchMessagesFilter") – Filter for message content; searchMessagesFilterEmpty, searchMessagesFilterUnreadMention, searchMessagesFilterUnreadReaction, and searchMessagesFilterFailedToSend are unsupported in this function

  • message_id (int) – Message identifier

Return type:

Union[Error, Count]

Returns:

Count

async getChatNotificationSettingsExceptions(scope=None, compare_sound=False)[source]

Returns the list of chats with non-default notification settings for new messages

Parameters:
  • scope ("types.NotificationSettingsScope") – If specified, only chats from the scope will be returned; pass null to return chats from all scopes

  • compare_sound (bool) – Pass true to include in the response chats with only non-default sound

Return type:

Union[Error, Chats]

Returns:

Chats

async getChatPinnedMessage(chat_id=0)[source]

Returns information about a newest pinned message in the chat. Returns a 404 error if the message doesn’t exist

Parameters:

chat_id (int) – Identifier of the chat the message belongs to

Return type:

Union[Error, Message]

Returns:

Message

async getChatPostedToChatPageStories(chat_id=0, from_story_id=0, limit=0)[source]

Returns the list of stories that posted by the given chat to its chat page. If from_story_id == 0, then pinned stories are returned first. Then, stories are returned in reverse chronological order (i.e., in order of decreasing story_id). For optimal performance, the number of returned stories is chosen by TDLib

Parameters:
  • chat_id (int) – Chat identifier

  • from_story_id (int) – Identifier of the story starting from which stories must be returned; use 0 to get results from pinned and the newest story

  • limit (int) – The maximum number of stories to be returned. For optimal performance, the number of returned stories is chosen by TDLib and can be smaller than the specified limit

Return type:

Union[Error, Stories]

Returns:

Stories

async getChatRevenueStatistics(chat_id=0, is_dark=False)[source]

Returns detailed revenue statistics about a chat. Currently, this method can be used only for channels if supergroupFullInfo.can_get_revenue_statistics == true or bots if userFullInfo.bot_info.can_get_revenue_statistics == true

Parameters:
  • chat_id (int) – Chat identifier

  • is_dark (bool) – Pass true if a dark theme is used by the application

Return type:

Union[Error, ChatRevenueStatistics]

Returns:

ChatRevenueStatistics

async getChatRevenueTransactions(chat_id=0, offset='', limit=0)[source]

Returns the list of revenue transactions for a chat. Currently, this method can be used only for channels if supergroupFullInfo.can_get_revenue_statistics == true or bots if userFullInfo.bot_info.can_get_revenue_statistics == true

Parameters:
  • chat_id (int) – Chat identifier

  • offset (str) – Offset of the first transaction to return as received from the previous request; use empty string to get the first chunk of results

  • limit (int) – The maximum number of transactions to be returned; up to 100

Return type:

Union[Error, ChatRevenueTransactions]

Returns:

ChatRevenueTransactions

async getChatRevenueWithdrawalUrl(chat_id=0, password='')[source]

Returns a URL for chat revenue withdrawal; requires owner privileges in the channel chat or the bot. Currently, this method can be used only if getOption("can_withdraw_chat_revenue") for channels with supergroupFullInfo.can_get_revenue_statistics == true or bots with userFullInfo.bot_info.can_get_revenue_statistics == true

Parameters:
  • chat_id (int) – Chat identifier

  • password (str) – The 2-step verification password of the current user

Return type:

Union[Error, HttpUrl]

Returns:

HttpUrl

async getChatScheduledMessages(chat_id=0)[source]

Returns all scheduled messages in a chat. The messages are returned in reverse chronological order (i.e., in order of decreasing message_id)

Parameters:

chat_id (int) – Chat identifier

Return type:

Union[Error, Messages]

Returns:

Messages

async getChatSimilarChatCount(chat_id=0, return_local=False)[source]

Returns approximate number of chats similar to the given chat

Parameters:
  • chat_id (int) – Identifier of the target chat; must be an identifier of a channel chat

  • return_local (bool) – Pass true to get the number of chats without sending network requests, or -1 if the number of chats is unknown locally

Return type:

Union[Error, Count]

Returns:

Count

async getChatSimilarChats(chat_id=0)[source]

Returns a list of chats similar to the given chat

Parameters:

chat_id (int) – Identifier of the target chat; must be an identifier of a channel chat

Return type:

Union[Error, Chats]

Returns:

Chats

async getChatSparseMessagePositions(chat_id=0, filter=None, from_message_id=0, limit=0, saved_messages_topic_id=0)[source]

Returns sparse positions of messages of the specified type in the chat to be used for shared media scroll implementation. Returns the results in reverse chronological order (i.e., in order of decreasing message_id). Cannot be used in secret chats or with searchMessagesFilterFailedToSend filter without an enabled message database

Parameters:
  • chat_id (int) – Identifier of the chat in which to return information about message positions

  • filter ("types.SearchMessagesFilter") – Filter for message content. Filters searchMessagesFilterEmpty, searchMessagesFilterMention, searchMessagesFilterUnreadMention, and searchMessagesFilterUnreadReaction are unsupported in this function

  • from_message_id (int) – The message identifier from which to return information about message positions

  • limit (int) – The expected number of message positions to be returned; 50-2000. A smaller number of positions can be returned, if there are not enough appropriate messages

  • saved_messages_topic_id (int) – If not 0, only messages in the specified Saved Messages topic will be considered; pass 0 to consider all messages, or for chats other than Saved Messages

Return type:

Union[Error, MessagePositions]

Returns:

MessagePositions

async getChatSponsoredMessages(chat_id=0)[source]

Returns sponsored messages to be shown in a chat; for channel chats and chats with bots only

Parameters:

chat_id (int) – Identifier of the chat

Return type:

Union[Error, SponsoredMessages]

Returns:

SponsoredMessages

async getChatStatistics(chat_id=0, is_dark=False)[source]

Returns detailed statistics about a chat. Currently, this method can be used only for supergroups and channels. Can be used only if supergroupFullInfo.can_get_statistics == true

Parameters:
  • chat_id (int) – Chat identifier

  • is_dark (bool) – Pass true if a dark theme is used by the application

Return type:

Union[Error, ChatStatistics]

Returns:

ChatStatistics

async getChatStoryAlbums(chat_id=0)[source]

Returns the list of story albums owned by the given chat

Parameters:

chat_id (int) – Chat identifier

Return type:

Union[Error, StoryAlbums]

Returns:

StoryAlbums

async getChatStoryInteractions(story_poster_chat_id=0, story_id=0, reaction_type=None, prefer_forwards=False, offset='', limit=0)[source]

Returns interactions with a story posted in a chat. Can be used only if story is posted on behalf of a chat and the user is an administrator in the chat

Parameters:
  • story_poster_chat_id (int) – The identifier of the poster of the story

  • story_id (int) – Story identifier

  • reaction_type ("types.ReactionType") – Pass the default heart reaction or a suggested reaction type to receive only interactions with the specified reaction type; pass null to receive all interactions; reactionTypePaid isn’t supported

  • prefer_forwards (bool) – Pass true to get forwards and reposts first, then reactions, then other views; pass false to get interactions sorted just by interaction date

  • offset (str) – Offset of the first entry to return as received from the previous request; use empty string to get the first chunk of results

  • limit (int) – The maximum number of story interactions to return

Return type:

Union[Error, StoryInteractions]

Returns:

StoryInteractions

async getChats(chat_list=None, limit=0)[source]

Returns an ordered list of chats from the beginning of a chat list. For informational purposes only. Use loadChats and updates processing instead to maintain chat lists in a consistent state

Parameters:
  • chat_list ("types.ChatList") – The chat list in which to return chats; pass null to get chats from the main chat list

  • limit (int) – The maximum number of chats to be returned

Return type:

Union[Error, Chats]

Returns:

Chats

Returns identifiers of chats from a chat folder, suitable for adding to a chat folder invite link

Parameters:

chat_folder_id (int) – Chat folder identifier

Return type:

Union[Error, Chats]

Returns:

Chats

async getChatsToPostStories()[source]

Returns supergroup and channel chats in which the current user has the right to post stories. The chats must be rechecked with canPostStory before actually trying to post a story there

Return type:

Union[Error, Chats]

Returns:

Chats

async getCloseFriends()[source]

Returns all close friends of the current user

Return type:

Union[Error, Users]

Returns:

Users

async getCollectibleItemInfo(type=None)[source]

Returns information about a given collectible item that was purchased at https://fragment.com

Parameters:

type ("types.CollectibleItemType") – Type of the collectible item. The item must be used by a user and must be visible to the current user

Return type:

Union[Error, CollectibleItemInfo]

Returns:

CollectibleItemInfo

async getCommands(scope=None, language_code='')[source]

Returns the list of commands supported by the bot for the given user scope and language; for bots only

Parameters:
  • scope ("types.BotCommandScope") – The scope to which the commands are relevant; pass null to get commands in the default bot command scope

  • language_code (str) – A two-letter ISO 639-1 language code or an empty string

Return type:

Union[Error, BotCommands]

Returns:

BotCommands

async getConnectedAffiliateProgram(affiliate=None, bot_user_id=0)[source]

Returns an affiliate program that were connected to the given affiliate by identifier of the bot that created the program

Parameters:
  • affiliate ("types.AffiliateType") – The affiliate to which the affiliate program will be connected

  • bot_user_id (int) – Identifier of the bot that created the program

Return type:

Union[Error, ConnectedAffiliateProgram]

Returns:

ConnectedAffiliateProgram

async getConnectedAffiliatePrograms(affiliate=None, offset='', limit=0)[source]

Returns affiliate programs that were connected to the given affiliate

Parameters:
  • affiliate ("types.AffiliateType") – The affiliate to which the affiliate program were connected

  • offset (str) – Offset of the first affiliate program to return as received from the previous request; use empty string to get the first chunk of results

  • limit (int) – The maximum number of affiliate programs to return

Return type:

Union[Error, ConnectedAffiliatePrograms]

Returns:

ConnectedAffiliatePrograms

async getConnectedWebsites()[source]

Returns all website where the current user used Telegram to log in

Return type:

Union[Error, ConnectedWebsites]

Returns:

ConnectedWebsites

async getContacts()[source]

Returns all contacts of the user

Return type:

Union[Error, Users]

Returns:

Users

async getCountries()[source]

Returns information about existing countries. Can be called before authorization

Return type:

Union[Error, Countries]

Returns:

Countries

async getCountryCode()[source]

Uses the current IP address to find the current country. Returns two-letter ISO 3166-1 alpha-2 country code. Can be called before authorization

Return type:

Union[Error, Text]

Returns:

Text

async getCountryFlagEmoji(country_code='')[source]

Returns an emoji for the given country. Returns an empty string on failure. Can be called synchronously

Parameters:

country_code (str) – A two-letter ISO 3166-1 alpha-2 country code as received from getCountries

Return type:

Union[Error, Text]

Returns:

Text

async getCreatedPublicChats(type=None)[source]

Returns a list of public chats of the specified type, owned by the user

Parameters:

type ("types.PublicChatType") – Type of the public chats to return

Return type:

Union[Error, Chats]

Returns:

Chats

async getCurrentState()[source]

Returns all updates needed to restore current TDLib state, i.e. all actual updateAuthorizationState/updateUser/updateNewChat and others. This is especially useful if TDLib is run in a separate process. Can be called before initialization

Return type:

Union[Error, Updates]

Returns:

Updates

async getCurrentWeather(location=None)[source]

Returns the current weather in the given location

Parameters:

location ("types.Location") – The location

Return type:

Union[Error, CurrentWeather]

Returns:

CurrentWeather

async getCustomEmojiReactionAnimations()[source]

Returns TGS stickers with generic animations for custom emoji reactions

Return type:

Union[Error, Stickers]

Returns:

Stickers

async getCustomEmojiStickers(custom_emoji_ids=None)[source]

Returns the list of custom emoji stickers by their identifiers. Stickers are returned in arbitrary order. Only found stickers are returned

Parameters:

custom_emoji_ids (List[int]) – Identifiers of custom emoji stickers. At most 200 custom emoji stickers can be received simultaneously

Return type:

Union[Error, Stickers]

Returns:

Stickers

async getDatabaseStatistics()[source]

Returns database statistics

Return type:

Union[Error, DatabaseStatistics]

Returns:

DatabaseStatistics

async getDeepLinkInfo(link='')[source]

Returns information about a tg:// deep link. Use "tg://need_update_for_some_feature" or "tg:some_unsupported_feature" for testing. Returns a 404 error for unknown links. Can be called before authorization

Parameters:

link (str) – The link

Return type:

Union[Error, DeepLinkInfo]

Returns:

DeepLinkInfo

async getDefaultBackgroundCustomEmojiStickers()[source]

Returns default list of custom emoji stickers for reply background

Return type:

Union[Error, Stickers]

Returns:

Stickers

async getDefaultChatEmojiStatuses()[source]

Returns default emoji statuses for chats

Return type:

Union[Error, EmojiStatusCustomEmojis]

Returns:

EmojiStatusCustomEmojis

async getDefaultChatPhotoCustomEmojiStickers()[source]

Returns default list of custom emoji stickers for placing on a chat photo

Return type:

Union[Error, Stickers]

Returns:

Stickers

async getDefaultEmojiStatuses()[source]

Returns default emoji statuses for self status

Return type:

Union[Error, EmojiStatusCustomEmojis]

Returns:

EmojiStatusCustomEmojis

async getDefaultMessageAutoDeleteTime()[source]

Returns default message auto-delete time setting for new chats

Return type:

Union[Error, MessageAutoDeleteTime]

Returns:

MessageAutoDeleteTime

async getDefaultProfilePhotoCustomEmojiStickers()[source]

Returns default list of custom emoji stickers for placing on a profile photo

Return type:

Union[Error, Stickers]

Returns:

Stickers

async getDirectMessagesChatTopic(chat_id=0, topic_id=0)[source]

Returns information about the topic in a channel direct messages chat administered by the current user

Parameters:
  • chat_id (int) – Chat identifier of the channel direct messages chat

  • topic_id (int) – Identifier of the topic to get

Return type:

Union[Error, DirectMessagesChatTopic]

Returns:

DirectMessagesChatTopic

async getDirectMessagesChatTopicHistory(chat_id=0, topic_id=0, from_message_id=0, offset=0, limit=0)[source]

Returns messages in the topic in a channel direct messages chat administered by the current user. The messages are returned in reverse chronological order (i.e., in order of decreasing message_id)

Parameters:
  • chat_id (int) – Chat identifier of the channel direct messages chat

  • topic_id (int) – Identifier of the topic which messages will be fetched

  • from_message_id (int) – Identifier of the message starting from which messages must be fetched; use 0 to get results from the last message

  • offset (int) – Specify 0 to get results from exactly the message from_message_id or a negative number from -99 to -1 to get additionally -offset newer messages

  • limit (int) – The maximum number of messages to be returned; must be positive and can’t be greater than 100. If the offset is negative, then the limit must be greater than or equal to -offset. For optimal performance, the number of returned messages is chosen by TDLib and can be smaller than the specified limit

Return type:

Union[Error, Messages]

Returns:

Messages

async getDirectMessagesChatTopicMessageByDate(chat_id=0, topic_id=0, date=0)[source]

Returns the last message sent in the topic in a channel direct messages chat administered by the current user no later than the specified date

Parameters:
  • chat_id (int) – Chat identifier of the channel direct messages chat

  • topic_id (int) – Identifier of the topic which messages will be fetched

  • date (int) – Point in time (Unix timestamp) relative to which to search for messages

Return type:

Union[Error, Message]

Returns:

Message

async getDirectMessagesChatTopicRevenue(chat_id=0, topic_id=0)[source]

Returns the total number of Telegram Stars received by the channel chat for direct messages from the given topic

Parameters:
  • chat_id (int) – Chat identifier of the channel direct messages chat administered by the current user

  • topic_id (int) – Identifier of the topic

Return type:

Union[Error, StarCount]

Returns:

StarCount

async getDisallowedChatEmojiStatuses()[source]

Returns the list of emoji statuses, which can’t be used as chat emoji status, even if they are from a sticker set with is_allowed_as_chat_emoji_status == true

Return type:

Union[Error, EmojiStatusCustomEmojis]

Returns:

EmojiStatusCustomEmojis

async getEmojiCategories(type=None)[source]

Returns available emoji categories

Parameters:

type ("types.EmojiCategoryType") – Type of emoji categories to return; pass null to get default emoji categories

Return type:

Union[Error, EmojiCategories]

Returns:

EmojiCategories

async getEmojiReaction(emoji='')[source]

Returns information about an emoji reaction. Returns a 404 error if the reaction is not found

Parameters:

emoji (str) – Text representation of the reaction

Return type:

Union[Error, EmojiReaction]

Returns:

EmojiReaction

async getEmojiSuggestionsUrl(language_code='')[source]

Returns an HTTP URL which can be used to automatically log in to the translation platform and suggest new emoji replacements. The URL will be valid for 30 seconds after generation

Parameters:

language_code (str) – Language code for which the emoji replacements will be suggested

Return type:

Union[Error, HttpUrl]

Returns:

HttpUrl

Returns an HTTP URL which can be used to automatically authorize the current user on a website after clicking an HTTP link. Use the method getExternalLinkInfo to find whether a prior user confirmation is needed

Parameters:
  • link (str) – The HTTP link

  • allow_write_access (bool) – Pass true if the current user allowed the bot, returned in getExternalLinkInfo, to send them messages

Return type:

Union[Error, HttpUrl]

Returns:

HttpUrl

async getExternalLinkInfo(link='')[source]

Returns information about an action to be done when the current user clicks an external link. Don’t use this method for links from secret chats if link preview is disabled in secret chats

Parameters:

link (str) – The link

Return type:

Union[Error, LoginUrlInfo]

Returns:

LoginUrlInfo

async getFavoriteStickers()[source]

Returns favorite stickers

Return type:

Union[Error, Stickers]

Returns:

Stickers

async getFile(file_id=0)[source]

Returns information about a file. This is an offline method

Parameters:

file_id (int) – Identifier of the file to get

Return type:

Union[Error, File]

Returns:

File

async getFileDownloadedPrefixSize(file_id=0, offset=0)[source]

Returns file downloaded prefix size from a given offset, in bytes

Parameters:
  • file_id (int) – Identifier of the file

  • offset (int) – Offset from which downloaded prefix size needs to be calculated

Return type:

Union[Error, FileDownloadedPrefixSize]

Returns:

FileDownloadedPrefixSize

async getFileExtension(mime_type='')[source]

Returns the extension of a file, guessed by its MIME type. Returns an empty string on failure. Can be called synchronously

Parameters:

mime_type (str) – The MIME type of the file

Return type:

Union[Error, Text]

Returns:

Text

async getFileMimeType(file_name='')[source]

Returns the MIME type of a file, guessed by its extension. Returns an empty string on failure. Can be called synchronously

Parameters:

file_name (str) – The name of the file or path to the file

Return type:

Union[Error, Text]

Returns:

Text

async getForumTopic(chat_id=0, message_thread_id=0)[source]

Returns information about a forum topic

Parameters:
  • chat_id (int) – Identifier of the chat

  • message_thread_id (int) – Message thread identifier of the forum topic

Return type:

Union[Error, ForumTopic]

Returns:

ForumTopic

async getForumTopicDefaultIcons()[source]

Returns the list of custom emoji, which can be used as forum topic icon by all users

Return type:

Union[Error, Stickers]

Returns:

Stickers

Returns an HTTPS link to a topic in a forum chat. This is an offline method

Parameters:
  • chat_id (int) – Identifier of the chat

  • message_thread_id (int) – Message thread identifier of the forum topic

Return type:

Union[Error, MessageLink]

Returns:

MessageLink

async getForumTopics(chat_id=0, query='', offset_date=0, offset_message_id=0, offset_message_thread_id=0, limit=0)[source]

Returns found forum topics in a forum chat. This is a temporary method for getting information about topic list from the server

Parameters:
  • chat_id (int) – Identifier of the forum chat

  • query (str) – Query to search for in the forum topic’s name

  • offset_date (int) – The date starting from which the results need to be fetched. Use 0 or any date in the future to get results from the last topic

  • offset_message_id (int) – The message identifier of the last message in the last found topic, or 0 for the first request

  • offset_message_thread_id (int) – The message thread identifier of the last found topic, or 0 for the first request

  • limit (int) – The maximum number of forum topics to be returned; up to 100. For optimal performance, the number of returned forum topics is chosen by TDLib and can be smaller than the specified limit

Return type:

Union[Error, ForumTopics]

Returns:

ForumTopics

async getGameHighScores(chat_id=0, message_id=0, user_id=0)[source]

Returns the high scores for a game and some part of the high score table in the range of the specified user; for bots only

Parameters:
  • chat_id (int) – The chat that contains the message with the game

  • message_id (int) – Identifier of the message

  • user_id (int) – User identifier

Return type:

Union[Error, GameHighScores]

Returns:

GameHighScores

async getGiftChatThemes(offset='', limit=0)[source]

Returns available to the current user gift chat themes

Parameters:
  • offset (str) – Offset of the first entry to return as received from the previous request; use empty string to get the first chunk of results

  • limit (int) – The maximum number of chat themes to return

Return type:

Union[Error, GiftChatThemes]

Returns:

GiftChatThemes

async getGiftCollections(owner_id=None)[source]

Returns collections of gifts owned by the given user or chat

Parameters:

owner_id ("types.MessageSender") – Identifier of the user or the channel chat that received the gifts

Return type:

Union[Error, GiftCollections]

Returns:

GiftCollections

async getGiftUpgradePreview(gift_id=0)[source]

Returns examples of possible upgraded gifts for a regular gift

Parameters:

gift_id (int) – Identifier of the gift

Return type:

Union[Error, GiftUpgradePreview]

Returns:

GiftUpgradePreview

async getGiveawayInfo(chat_id=0, message_id=0)[source]

Returns information about a giveaway

Parameters:
  • chat_id (int) – Identifier of the channel chat which started the giveaway

  • message_id (int) – Identifier of the giveaway or a giveaway winners message in the chat

Return type:

Union[Error, GiveawayInfo]

Returns:

GiveawayInfo

async getGreetingStickers()[source]

Returns greeting stickers from regular sticker sets that can be used for the start page of other users

Return type:

Union[Error, Stickers]

Returns:

Stickers

async getGrossingWebAppBots(offset='', limit=0)[source]

Returns the most grossing Web App bots

Parameters:
  • offset (str) – Offset of the first entry to return as received from the previous request; use empty string to get the first chunk of results

  • limit (int) – The maximum number of bots to be returned; up to 100

Return type:

Union[Error, FoundUsers]

Returns:

FoundUsers

async getGroupCall(group_call_id=0)[source]

Returns information about a group call

Parameters:

group_call_id (int) – Group call identifier

Return type:

Union[Error, GroupCall]

Returns:

GroupCall

async getGroupCallParticipants(input_group_call=None, limit=0)[source]

Returns information about participants of a non-joined group call that is not bound to a chat

Parameters:
  • input_group_call ("types.InputGroupCall") – The group call which participants will be returned

  • limit (int) – The maximum number of participants to return; must be positive

Return type:

Union[Error, GroupCallParticipants]

Returns:

GroupCallParticipants

async getGroupsInCommon(user_id=0, offset_chat_id=0, limit=0)[source]

Returns a list of common group chats with a given user. Chats are sorted by their type and creation date

Parameters:
  • user_id (int) – User identifier

  • offset_chat_id (int) – Chat identifier starting from which to return chats; use 0 for the first request

  • limit (int) – The maximum number of chats to be returned; up to 100

Return type:

Union[Error, Chats]

Returns:

Chats

async getImportedContactCount()[source]

Returns the total number of imported contacts

Return type:

Union[Error, Count]

Returns:

Count

async getInactiveSupergroupChats()[source]

Returns a list of recently inactive supergroups and channels. Can be used when user reaches limit on the number of joined supergroups and channels and receives the error "CHANNELS_TOO_MUCH". Also, the limit can be increased with Telegram Premium

Return type:

Union[Error, Chats]

Returns:

Chats

async getInlineGameHighScores(inline_message_id='', user_id=0)[source]

Returns game high scores and some part of the high score table in the range of the specified user; for bots only

Parameters:
  • inline_message_id (str) – Inline message identifier

  • user_id (int) – User identifier

Return type:

Union[Error, GameHighScores]

Returns:

GameHighScores

async getInlineQueryResults(bot_user_id=0, chat_id=0, user_location=None, query='', offset='')[source]

Sends an inline query to a bot and returns its results. Returns an error with code 502 if the bot fails to answer the query before the query timeout expires

Parameters:
  • bot_user_id (int) – Identifier of the target bot

  • chat_id (int) – Identifier of the chat where the query was sent

  • user_location ("types.Location") – Location of the user; pass null if unknown or the bot doesn’t need user’s location

  • query (str) – Text of the query

  • offset (str) – Offset of the first entry to return; use empty string to get the first chunk of results

Return type:

Union[Error, InlineQueryResults]

Returns:

InlineQueryResults

async getInstalledBackgrounds(for_dark_theme=False)[source]

Returns backgrounds installed by the user

Parameters:

for_dark_theme (bool) – Pass true to order returned backgrounds for a dark theme

Return type:

Union[Error, Backgrounds]

Returns:

Backgrounds

async getInstalledStickerSets(sticker_type=None)[source]

Returns a list of installed sticker sets

Parameters:

sticker_type ("types.StickerType") – Type of the sticker sets to return

Return type:

Union[Error, StickerSets]

Returns:

StickerSets

Returns an HTTPS or a tg: link with the given type. Can be called before authorization

Parameters:
  • type ("types.InternalLinkType") – Expected type of the link

  • is_http (bool) – Pass true to create an HTTPS link (only available for some link types); pass false to create a tg: link

Return type:

Union[Error, HttpUrl]

Returns:

HttpUrl

async getInternalLinkType(link='')[source]

Returns information about the type of internal link. Returns a 404 error if the link is not internal. Can be called before authorization

Parameters:

link (str) – The link

Return type:

Union[Error, InternalLinkType]

Returns:

InternalLinkType

async getJsonString(json_value=None)[source]

Converts a JsonValue object to corresponding JSON-serialized string. Can be called synchronously

Parameters:

json_value ("types.JsonValue") – The JsonValue object

Return type:

Union[Error, Text]

Returns:

Text

async getJsonValue(json='')[source]

Converts a JSON-serialized string to corresponding JsonValue object. Can be called synchronously

Parameters:

json (str) – The JSON-serialized string

Return type:

Union[Error, JsonValue]

Returns:

JsonValue

async getKeywordEmojis(text='', input_language_codes=None)[source]

Return emojis matching the keyword. Supported only if the file database is enabled. Order of results is unspecified

Parameters:
  • text (str) – Text to search for

  • input_language_codes (List[str]) – List of possible IETF language tags of the user’s input language; may be empty if unknown

Return type:

Union[Error, Emojis]

Returns:

Emojis

async getLanguagePackInfo(language_pack_id='')[source]

Returns information about a language pack. Returned language pack identifier may be different from a provided one. Can be called before authorization

Parameters:

language_pack_id (str) – Language pack identifier

Return type:

Union[Error, LanguagePackInfo]

Returns:

LanguagePackInfo

async getLanguagePackString(language_pack_database_path='', localization_target='', language_pack_id='', key='')[source]

Returns a string stored in the local database from the specified localization target and language pack by its key. Returns a 404 error if the string is not found. Can be called synchronously

Parameters:
  • language_pack_database_path (str) – Path to the language pack database in which strings are stored

  • localization_target (str) – Localization target to which the language pack belongs

  • language_pack_id (str) – Language pack identifier

  • key (str) – Language pack key of the string to be returned

Return type:

Union[Error, LanguagePackStringValue]

Returns:

LanguagePackStringValue

async getLanguagePackStrings(language_pack_id='', keys=None)[source]

Returns strings from a language pack in the current localization target by their keys. Can be called before authorization

Parameters:
  • language_pack_id (str) – Language pack identifier of the strings to be returned

  • keys (List[str]) – Language pack keys of the strings to be returned; leave empty to request all available strings

Return type:

Union[Error, LanguagePackStrings]

Returns:

LanguagePackStrings

async getLinkPreview(text=None, link_preview_options=None)[source]

Returns a link preview by the text of a message. Do not call this function too often. Returns a 404 error if the text has no link preview

Parameters:
  • text ("types.FormattedText") – Message text with formatting

  • link_preview_options ("types.LinkPreviewOptions") – Options to be used for generation of the link preview; pass null to use default link preview options

Return type:

Union[Error, LinkPreview]

Returns:

LinkPreview

async getLocalizationTargetInfo(only_local=False)[source]

Returns information about the current localization target. This is an offline method if only_local is true. Can be called before authorization

Parameters:

only_local (bool) – Pass true to get only locally available information without sending network requests

Return type:

Union[Error, LocalizationTargetInfo]

Returns:

LocalizationTargetInfo

async getLogStream()[source]

Returns information about currently used log stream for internal logging of TDLib. Can be called synchronously

Return type:

Union[Error, LogStream]

Returns:

LogStream

async getLogTagVerbosityLevel(tag='')[source]

Returns current verbosity level for a specified TDLib internal log tag. Can be called synchronously

Parameters:

tag (str) – Logging tag to change verbosity level

Return type:

Union[Error, LogVerbosityLevel]

Returns:

LogVerbosityLevel

async getLogTags()[source]

Returns the list of available TDLib internal log tags, for example, ["actor", "binlog", "connections", "notifications", "proxy"]. Can be called synchronously

Return type:

Union[Error, LogTags]

Returns:

LogTags

async getLogVerbosityLevel()[source]

Returns current verbosity level of the internal logging of TDLib. Can be called synchronously

Return type:

Union[Error, LogVerbosityLevel]

Returns:

LogVerbosityLevel

async getLoginUrl(chat_id=0, message_id=0, button_id=0, allow_write_access=False)[source]

Returns an HTTP URL which can be used to automatically authorize the user on a website after clicking an inline button of type inlineKeyboardButtonTypeLoginUrl. Use the method getLoginUrlInfo to find whether a prior user confirmation is needed. If an error is returned, then the button must be handled as an ordinary URL button

Parameters:
  • chat_id (int) – Chat identifier of the message with the button

  • message_id (int) – Message identifier of the message with the button

  • button_id (int) – Button identifier

  • allow_write_access (bool) – Pass true to allow the bot to send messages to the current user

Return type:

Union[Error, HttpUrl]

Returns:

HttpUrl

async getLoginUrlInfo(chat_id=0, message_id=0, button_id=0)[source]

Returns information about a button of type inlineKeyboardButtonTypeLoginUrl. The method needs to be called when the user presses the button

Parameters:
  • chat_id (int) – Chat identifier of the message with the button

  • message_id (int) – Message identifier of the message with the button. The message must not be scheduled

  • button_id (int) – Button identifier

Return type:

Union[Error, LoginUrlInfo]

Returns:

LoginUrlInfo

async getMainWebApp(chat_id=0, bot_user_id=0, start_parameter='', parameters=None)[source]

Returns information needed to open the main Web App of a bot

Parameters:
  • chat_id (int) – Identifier of the chat in which the Web App is opened; pass 0 if none

  • bot_user_id (int) – Identifier of the target bot. If the bot is restricted for the current user, then show an error instead of calling the method

  • start_parameter (str) – Start parameter from internalLinkTypeMainWebApp

  • parameters ("types.WebAppOpenParameters") – Parameters to use to open the Web App

Return type:

Union[Error, MainWebApp]

Returns:

MainWebApp

async getMapThumbnailFile(location=None, zoom=0, width=0, height=0, scale=0, chat_id=0)[source]

Returns information about a file with a map thumbnail in PNG format. Only map thumbnail files with size less than 1MB can be downloaded

Parameters:
  • location ("types.Location") – Location of the map center

  • zoom (int) – Map zoom level; 13-20

  • width (int) – Map width in pixels before applying scale; 16-1024

  • height (int) – Map height in pixels before applying scale; 16-1024

  • scale (int) – Map scale; 1-3

  • chat_id (int) – Identifier of a chat in which the thumbnail will be shown. Use 0 if unknown

Return type:

Union[Error, File]

Returns:

File

async getMarkdownText(text=None)[source]

Replaces text entities with Markdown formatting in a human-friendly format. Entities that can’t be represented in Markdown unambiguously are kept as is. Can be called synchronously

Parameters:

text ("types.FormattedText") – The text

Return type:

Union[Error, FormattedText]

Returns:

FormattedText

async getMe()[source]

Returns the current user

Return type:

Union[Error, User]

Returns:

User

async getMenuButton(user_id=0)[source]

Returns menu button set by the bot for the given user; for bots only

Parameters:

user_id (int) – Identifier of the user or 0 to get the default menu button

Return type:

Union[Error, BotMenuButton]

Returns:

BotMenuButton

async getMessage(chat_id=0, message_id=0)[source]

Returns information about a message. Returns a 404 error if the message doesn’t exist

Parameters:
  • chat_id (int) – Identifier of the chat the message belongs to

  • message_id (int) – Identifier of the message to get

Return type:

Union[Error, Message]

Returns:

Message

async getMessageAddedReactions(chat_id=0, message_id=0, reaction_type=None, offset='', limit=0)[source]

Returns reactions added for a message, along with their sender

Parameters:
  • chat_id (int) – Identifier of the chat to which the message belongs

  • message_id (int) – Identifier of the message. Use message.interaction_info.reactions.can_get_added_reactions to check whether added reactions can be received for the message

  • reaction_type ("types.ReactionType") – Type of the reactions to return; pass null to return all added reactions; reactionTypePaid isn’t supported

  • offset (str) – Offset of the first entry to return as received from the previous request; use empty string to get the first chunk of results

  • limit (int) – The maximum number of reactions to be returned; must be positive and can’t be greater than 100

Return type:

Union[Error, AddedReactions]

Returns:

AddedReactions

async getMessageAuthor(chat_id=0, message_id=0)[source]

Returns information about actual author of a message sent on behalf of a channel. The method can be called if messageProperties.can_get_author == true

Parameters:
  • chat_id (int) – Chat identifier

  • message_id (int) – Identifier of the message

Return type:

Union[Error, User]

Returns:

User

async getMessageAvailableReactions(chat_id=0, message_id=0, row_size=0)[source]

Returns reactions, which can be added to a message. The list can change after updateActiveEmojiReactions, updateChatAvailableReactions for the chat, or updateMessageInteractionInfo for the message

Parameters:
  • chat_id (int) – Identifier of the chat to which the message belongs

  • message_id (int) – Identifier of the message

  • row_size (int) – Number of reaction per row, 5-25

Return type:

Union[Error, AvailableReactions]

Returns:

AvailableReactions

async getMessageEffect(effect_id=0)[source]

Returns information about a message effect. Returns a 404 error if the effect is not found

Parameters:

effect_id (int) – Unique identifier of the effect

Return type:

Union[Error, MessageEffect]

Returns:

MessageEffect

async getMessageEmbeddingCode(chat_id=0, message_id=0, for_album=False)[source]

Returns an HTML code for embedding the message. Available only if messageProperties.can_get_embedding_code

Parameters:
  • chat_id (int) – Identifier of the chat to which the message belongs

  • message_id (int) – Identifier of the message

  • for_album (bool) – Pass true to return an HTML code for embedding of the whole media album

Return type:

Union[Error, Text]

Returns:

Text

async getMessageFileType(message_file_head='')[source]

Returns information about a file with messages exported from another application

Parameters:

message_file_head (str) – Beginning of the message file; up to 100 first lines

Return type:

Union[Error, MessageFileType]

Returns:

MessageFileType

async getMessageImportConfirmationText(chat_id=0)[source]

Returns a confirmation text to be shown to the user before starting message import

Parameters:

chat_id (int) – Identifier of a chat to which the messages will be imported. It must be an identifier of a private chat with a mutual contact or an identifier of a supergroup chat with can_change_info member right

Return type:

Union[Error, Text]

Returns:

Text

Returns an HTTPS link to a message in a chat. Available only if messageProperties.can_get_link, or if messageProperties.can_get_media_timestamp_links and a media timestamp link is generated. This is an offline method

Parameters:
  • chat_id (int) – Identifier of the chat to which the message belongs

  • message_id (int) – Identifier of the message

  • media_timestamp (int) – If not 0, timestamp from which the video/audio/video note/voice note/story playing must start, in seconds. The media can be in the message content or in its link preview

  • for_album (bool) – Pass true to create a link for the whole media album

  • in_message_thread (bool) – Pass true to create a link to the message as a channel post comment, in a message thread, or a forum topic

Return type:

Union[Error, MessageLink]

Returns:

MessageLink

async getMessageLinkInfo(url='')[source]

Returns information about a public or private message link. Can be called for any internal link of the type internalLinkTypeMessage

Parameters:

url (str) – The message link

Return type:

Union[Error, MessageLinkInfo]

Returns:

MessageLinkInfo

async getMessageLocally(chat_id=0, message_id=0)[source]

Returns information about a message, if it is available without sending network request. Returns a 404 error if message isn’t available locally. This is an offline method

Parameters:
  • chat_id (int) – Identifier of the chat the message belongs to

  • message_id (int) – Identifier of the message to get

Return type:

Union[Error, Message]

Returns:

Message

async getMessageProperties(chat_id=0, message_id=0)[source]

Returns properties of a message. This is an offline method

Parameters:
  • chat_id (int) – Chat identifier

  • message_id (int) – Identifier of the message

Return type:

Union[Error, MessageProperties]

Returns:

MessageProperties

async getMessagePublicForwards(chat_id=0, message_id=0, offset='', limit=0)[source]

Returns forwarded copies of a channel message to different public channels and public reposts as a story. Can be used only if messageProperties.can_get_statistics == true. For optimal performance, the number of returned messages and stories is chosen by TDLib

Parameters:
  • chat_id (int) – Chat identifier of the message

  • message_id (int) – Message identifier

  • offset (str) – Offset of the first entry to return as received from the previous request; use empty string to get the first chunk of results

  • limit (int) – The maximum number of messages and stories to be returned; must be positive and can’t be greater than 100. For optimal performance, the number of returned objects is chosen by TDLib and can be smaller than the specified limit

Return type:

Union[Error, PublicForwards]

Returns:

PublicForwards

async getMessageReadDate(chat_id=0, message_id=0)[source]

Returns read date of a recent outgoing message in a private chat. The method can be called if messageProperties.can_get_read_date == true

Parameters:
  • chat_id (int) – Chat identifier

  • message_id (int) – Identifier of the message

Return type:

Union[Error, MessageReadDate]

Returns:

MessageReadDate

async getMessageStatistics(chat_id=0, message_id=0, is_dark=False)[source]

Returns detailed statistics about a message. Can be used only if messageProperties.can_get_statistics == true

Parameters:
  • chat_id (int) – Chat identifier

  • message_id (int) – Message identifier

  • is_dark (bool) – Pass true if a dark theme is used by the application

Return type:

Union[Error, MessageStatistics]

Returns:

MessageStatistics

async getMessageThread(chat_id=0, message_id=0)[source]

Returns information about a message thread. Can be used only if messageProperties.can_get_message_thread == true

Parameters:
  • chat_id (int) – Chat identifier

  • message_id (int) – Identifier of the message

Return type:

Union[Error, MessageThreadInfo]

Returns:

MessageThreadInfo

async getMessageThreadHistory(chat_id=0, message_id=0, from_message_id=0, offset=0, limit=0)[source]

Returns messages in a message thread of a message. Can be used only if messageProperties.can_get_message_thread == true. Message thread of a channel message is in the channel’s linked supergroup. The messages are returned in reverse chronological order (i.e., in order of decreasing message_id). For optimal performance, the number of returned messages is chosen by TDLib

Parameters:
  • chat_id (int) – Chat identifier

  • message_id (int) – Message identifier, which thread history needs to be returned

  • from_message_id (int) – Identifier of the message starting from which history must be fetched; use 0 to get results from the last message

  • offset (int) – Specify 0 to get results from exactly the message from_message_id or a negative number from -99 to -1 to get additionally -offset newer messages

  • limit (int) – The maximum number of messages to be returned; must be positive and can’t be greater than 100. If the offset is negative, then the limit must be greater than or equal to -offset. For optimal performance, the number of returned messages is chosen by TDLib and can be smaller than the specified limit

Return type:

Union[Error, Messages]

Returns:

Messages

async getMessageViewers(chat_id=0, message_id=0)[source]

Returns viewers of a recent outgoing message in a basic group or a supergroup chat. For video notes and voice notes only users, opened content of the message, are returned. The method can be called if messageProperties.can_get_viewers == true

Parameters:
  • chat_id (int) – Chat identifier

  • message_id (int) – Identifier of the message

Return type:

Union[Error, MessageViewers]

Returns:

MessageViewers

async getMessages(chat_id=0, message_ids=None)[source]

Returns information about messages. If a message is not found, returns null on the corresponding position of the result

Parameters:
  • chat_id (int) – Identifier of the chat the messages belong to

  • message_ids (List[int]) – Identifiers of the messages to get

Return type:

Union[Error, Messages]

Returns:

Messages

async getNetworkStatistics(only_current=False)[source]

Returns network data usage statistics. Can be called before authorization

Parameters:

only_current (bool) – Pass true to get statistics only for the current library launch

Return type:

Union[Error, NetworkStatistics]

Returns:

NetworkStatistics

async getNewChatPrivacySettings()[source]

Returns privacy settings for new chat creation

Return type:

Union[Error, NewChatPrivacySettings]

Returns:

NewChatPrivacySettings

async getOption(name='')[source]

Returns the value of an option by its name. (Check the list of available options on https://core.telegram.org/tdlib/options.) Can be called before authorization. Can be called synchronously for options "version" and "commit_hash"

Parameters:

name (str) – The name of the option

Return type:

Union[Error, OptionValue]

Returns:

OptionValue

async getOwnedBots()[source]

Returns the list of bots owned by the current user

Return type:

Union[Error, Users]

Returns:

Users

async getOwnedStickerSets(offset_sticker_set_id=0, limit=0)[source]

Returns sticker sets owned by the current user

Parameters:
  • offset_sticker_set_id (int) – Identifier of the sticker set from which to return owned sticker sets; use 0 to get results from the beginning

  • limit (int) – The maximum number of sticker sets to be returned; must be positive and can’t be greater than 100. For optimal performance, the number of returned objects is chosen by TDLib and can be smaller than the specified limit

Return type:

Union[Error, StickerSets]

Returns:

StickerSets

async getPaidMessageRevenue(user_id=0)[source]

Returns the total number of Telegram Stars received by the current user for paid messages from the given user

Parameters:

user_id (int) – Identifier of the user

Return type:

Union[Error, StarCount]

Returns:

StarCount

async getPassportAuthorizationForm(bot_user_id=0, scope='', public_key='', nonce='')[source]

Returns a Telegram Passport authorization form for sharing data with a service

Parameters:
  • bot_user_id (int) – User identifier of the service’s bot

  • scope (str) – Telegram Passport element types requested by the service

  • public_key (str) – Service’s public key

  • nonce (str) – Unique request identifier provided by the service

Return type:

Union[Error, PassportAuthorizationForm]

Returns:

PassportAuthorizationForm

async getPassportAuthorizationFormAvailableElements(authorization_form_id=0, password='')[source]

Returns already available Telegram Passport elements suitable for completing a Telegram Passport authorization form. Result can be received only once for each authorization form

Parameters:
  • authorization_form_id (int) – Authorization form identifier

  • password (str) – The 2-step verification password of the current user

Return type:

Union[Error, PassportElementsWithErrors]

Returns:

PassportElementsWithErrors

async getPassportElement(type=None, password='')[source]

Returns one of the available Telegram Passport elements

Parameters:
  • type ("types.PassportElementType") – Telegram Passport element type

  • password (str) – The 2-step verification password of the current user

Return type:

Union[Error, PassportElement]

Returns:

PassportElement

async getPasswordState()[source]

Returns the current state of 2-step verification

Return type:

Union[Error, PasswordState]

Returns:

PasswordState

async getPaymentForm(input_invoice=None, theme=None)[source]

Returns an invoice payment form. This method must be called when the user presses inline button of the type inlineKeyboardButtonTypeBuy, or wants to buy access to media in a messagePaidMedia message

Parameters:
  • input_invoice ("types.InputInvoice") – The invoice

  • theme ("types.ThemeParameters") – Preferred payment form theme; pass null to use the default theme

Return type:

Union[Error, PaymentForm]

Returns:

PaymentForm

async getPaymentReceipt(chat_id=0, message_id=0)[source]

Returns information about a successful payment

Parameters:
  • chat_id (int) – Chat identifier of the messagePaymentSuccessful message

  • message_id (int) – Message identifier

Return type:

Union[Error, PaymentReceipt]

Returns:

PaymentReceipt

async getPhoneNumberInfo(phone_number_prefix='')[source]

Returns information about a phone number by its prefix. Can be called before authorization

Parameters:

phone_number_prefix (str) – The phone number prefix

Return type:

Union[Error, PhoneNumberInfo]

Returns:

PhoneNumberInfo

async getPhoneNumberInfoSync(language_code='', phone_number_prefix='')[source]

Returns information about a phone number by its prefix synchronously. getCountries must be called at least once after changing localization to the specified language if properly localized country information is expected. Can be called synchronously

Parameters:
  • language_code (str) – A two-letter ISO 639-1 language code for country information localization

  • phone_number_prefix (str) – The phone number prefix

Return type:

Union[Error, PhoneNumberInfo]

Returns:

PhoneNumberInfo

async getPollVoters(chat_id=0, message_id=0, option_id=0, offset=0, limit=0)[source]

Returns message senders voted for the specified option in a non-anonymous polls. For optimal performance, the number of returned users is chosen by TDLib

Parameters:
  • chat_id (int) – Identifier of the chat to which the poll belongs

  • message_id (int) – Identifier of the message containing the poll

  • option_id (int) – 0-based identifier of the answer option

  • offset (int) – Number of voters to skip in the result; must be non-negative

  • limit (int) – The maximum number of voters to be returned; must be positive and can’t be greater than 50. For optimal performance, the number of returned voters is chosen by TDLib and can be smaller than the specified limit, even if the end of the voter list has not been reached

Return type:

Union[Error, MessageSenders]

Returns:

MessageSenders

async getPreferredCountryLanguage(country_code='')[source]

Returns an IETF language tag of the language preferred in the country, which must be used to fill native fields in Telegram Passport personal details. Returns a 404 error if unknown

Parameters:

country_code (str) – A two-letter ISO 3166-1 alpha-2 country code

Return type:

Union[Error, Text]

Returns:

Text

async getPremiumFeatures(source=None)[source]

Returns information about features, available to Premium users

Parameters:

source ("types.PremiumSource") – Source of the request; pass null if the method is called from some non-standard source

Return type:

Union[Error, PremiumFeatures]

Returns:

PremiumFeatures

async getPremiumGiftPaymentOptions()[source]

Returns available options for gifting Telegram Premium to a user

Return type:

Union[Error, PremiumGiftPaymentOptions]

Returns:

PremiumGiftPaymentOptions

async getPremiumGiveawayPaymentOptions(boosted_chat_id=0)[source]

Returns available options for creating of Telegram Premium giveaway or manual distribution of Telegram Premium among chat members

Parameters:

boosted_chat_id (int) – Identifier of the supergroup or channel chat, which will be automatically boosted by receivers of the gift codes and which is administered by the user

Return type:

Union[Error, PremiumGiveawayPaymentOptions]

Returns:

PremiumGiveawayPaymentOptions

async getPremiumInfoSticker(month_count=0)[source]

Returns the sticker to be used as representation of the Telegram Premium subscription

Parameters:

month_count (int) – Number of months the Telegram Premium subscription will be active

Return type:

Union[Error, Sticker]

Returns:

Sticker

async getPremiumLimit(limit_type=None)[source]

Returns information about a limit, increased for Premium users. Returns a 404 error if the limit is unknown

Parameters:

limit_type ("types.PremiumLimitType") – Type of the limit

Return type:

Union[Error, PremiumLimit]

Returns:

PremiumLimit

async getPremiumState()[source]

Returns state of Telegram Premium subscription and promotion videos for Premium features

Return type:

Union[Error, PremiumState]

Returns:

PremiumState

async getPremiumStickerExamples()[source]

Returns examples of premium stickers for demonstration purposes

Return type:

Union[Error, Stickers]

Returns:

Stickers

async getPremiumStickers(limit=0)[source]

Returns premium stickers from regular sticker sets

Parameters:

limit (int) – The maximum number of stickers to be returned; 0-100

Return type:

Union[Error, Stickers]

Returns:

Stickers

async getPreparedInlineMessage(bot_user_id=0, prepared_message_id='')[source]

Saves an inline message to be sent by the given user

Parameters:
  • bot_user_id (int) – Identifier of the bot that created the message

  • prepared_message_id (str) – Identifier of the prepared message

Return type:

Union[Error, PreparedInlineMessage]

Returns:

PreparedInlineMessage

async getProxies()[source]

Returns the list of proxies that are currently set up. Can be called before authorization

Return type:

Union[Error, Proxies]

Returns:

Proxies

Returns an HTTPS link, which can be used to add a proxy. Available only for SOCKS5 and MTProto proxies. Can be called before authorization

Parameters:

proxy_id (int) – Proxy identifier

Return type:

Union[Error, HttpUrl]

Returns:

HttpUrl

async getPublicPostSearchLimits(query='')[source]

Checks public post search limits without actually performing the search

Parameters:

query (str) – Query that will be searched for

Return type:

Union[Error, PublicPostSearchLimits]

Returns:

PublicPostSearchLimits

async getPushReceiverId(payload='')[source]

Returns a globally unique push notification subscription identifier for identification of an account, which has received a push notification. Can be called synchronously

Parameters:

payload (str) – JSON-encoded push notification payload

Return type:

Union[Error, PushReceiverId]

Returns:

PushReceiverId

async getReadDatePrivacySettings()[source]

Returns privacy settings for message read date

Return type:

Union[Error, ReadDatePrivacySettings]

Returns:

ReadDatePrivacySettings

async getReceivedGift(received_gift_id='')[source]

Returns information about a received gift

Parameters:

received_gift_id (str) – Identifier of the gift

Return type:

Union[Error, ReceivedGift]

Returns:

ReceivedGift

async getReceivedGifts(business_connection_id='', owner_id=None, collection_id=0, exclude_unsaved=False, exclude_saved=False, exclude_unlimited=False, exclude_upgradable=False, exclude_non_upgradable=False, exclude_upgraded=False, sort_by_price=False, offset='', limit=0)[source]

Returns gifts received by the given user or chat

Parameters:
  • business_connection_id (str) – Unique identifier of business connection on behalf of which to send the request; for bots only

  • owner_id ("types.MessageSender") – Identifier of the gift receiver

  • collection_id (int) – Pass collection identifier to get gifts only from the specified collection; pass 0 to get gifts regardless of collections

  • exclude_unsaved (bool) – Pass true to exclude gifts that aren’t saved to the chat’s profile page. Always true for gifts received by other users and channel chats without can_post_messages administrator right

  • exclude_saved (bool) – Pass true to exclude gifts that are saved to the chat’s profile page. Always false for gifts received by other users and channel chats without can_post_messages administrator right

  • exclude_unlimited (bool) – Pass true to exclude gifts that can be purchased unlimited number of times

  • exclude_upgradable (bool) – Pass true to exclude gifts that can be purchased limited number of times and can be upgraded

  • exclude_non_upgradable (bool) – Pass true to exclude gifts that can be purchased limited number of times and can’t be upgraded

  • exclude_upgraded (bool) – Pass true to exclude upgraded gifts

  • sort_by_price (bool) – Pass true to sort results by gift price instead of send date

  • offset (str) – Offset of the first entry to return as received from the previous request; use empty string to get the first chunk of results

  • limit (int) – The maximum number of gifts to be returned; must be positive and can’t be greater than 100. For optimal performance, the number of returned objects is chosen by TDLib and can be smaller than the specified limit

Return type:

Union[Error, ReceivedGifts]

Returns:

ReceivedGifts

async getRecentEmojiStatuses()[source]

Returns recent emoji statuses for self status

Return type:

Union[Error, EmojiStatuses]

Returns:

EmojiStatuses

async getRecentInlineBots()[source]

Returns up to 20 recently used inline bots in the order of their last usage

Return type:

Union[Error, Users]

Returns:

Users

async getRecentStickers(is_attached=False)[source]

Returns a list of recently used stickers

Parameters:

is_attached (bool) – Pass true to return stickers and masks that were recently attached to photos or video files; pass false to return recently sent stickers

Return type:

Union[Error, Stickers]

Returns:

Stickers

async getRecentlyOpenedChats(limit=0)[source]

Returns recently opened chats. This is an offline method. Returns chats in the order of last opening

Parameters:

limit (int) – The maximum number of chats to be returned

Return type:

Union[Error, Chats]

Returns:

Chats

async getRecentlyVisitedTMeUrls(referrer='')[source]

Returns t.me URLs recently visited by a newly registered user

Parameters:

referrer (str) – Google Play referrer to identify the user

Return type:

Union[Error, TMeUrls]

Returns:

TMeUrls

async getRecommendedChatFolders()[source]

Returns recommended chat folders for the current user

Return type:

Union[Error, RecommendedChatFolders]

Returns:

RecommendedChatFolders

async getRecommendedChats()[source]

Returns a list of channel chats recommended to the current user

Return type:

Union[Error, Chats]

Returns:

Chats

async getRecoveryEmailAddress(password='')[source]

Returns a 2-step verification recovery email address that was previously set up. This method can be used to verify a password provided by the user

Parameters:

password (str) – The 2-step verification password for the current user

Return type:

Union[Error, RecoveryEmailAddress]

Returns:

RecoveryEmailAddress

async getRemoteFile(remote_file_id='', file_type=None)[source]

Returns information about a file by its remote identifier. This is an offline method. Can be used to register a URL as a file for further uploading, or sending as a message. Even the request succeeds, the file can be used only if it is still accessible to the user. For example, if the file is from a message, then the message must be not deleted and accessible to the user. If the file database is disabled, then the corresponding object with the file must be preloaded by the application

Parameters:
  • remote_file_id (str) – Remote identifier of the file to get

  • file_type ("types.FileType") – File type; pass null if unknown

Return type:

Union[Error, File]

Returns:

File

async getRepliedMessage(chat_id=0, message_id=0)[source]

Returns information about a non-bundled message that is replied by a given message. Also, returns the pinned message for messagePinMessage, the game message for messageGameScore, the invoice message for messagePaymentSuccessful, the message with a previously set same background for messageChatSetBackground, the giveaway message for messageGiveawayCompleted, the checklist message for messageChecklistTasksDone, messageChecklistTasksAdded, the message with suggested post information for messageSuggestedPostApprovalFailed, messageSuggestedPostApproved, messageSuggestedPostDeclined, messageSuggestedPostPaid, messageSuggestedPostRefunded, the message with the regular gift that was upgraded for messageUpgradedGift with origin of the type upgradedGiftOriginUpgrade, and the topic creation message for topic messages without non-bundled replied message. Returns a 404 error if the message doesn’t exist

Parameters:
  • chat_id (int) – Identifier of the chat the message belongs to

  • message_id (int) – Identifier of the reply message

Return type:

Union[Error, Message]

Returns:

Message

async getSavedAnimations()[source]

Returns saved animations

Return type:

Union[Error, Animations]

Returns:

Animations

async getSavedMessagesTags(saved_messages_topic_id=0)[source]

Returns tags used in Saved Messages or a Saved Messages topic

Parameters:

saved_messages_topic_id (int) – Identifier of Saved Messages topic which tags will be returned; pass 0 to get all Saved Messages tags

Return type:

Union[Error, SavedMessagesTags]

Returns:

SavedMessagesTags

async getSavedMessagesTopicHistory(saved_messages_topic_id=0, from_message_id=0, offset=0, limit=0)[source]

Returns messages in a Saved Messages topic. The messages are returned in reverse chronological order (i.e., in order of decreasing message_id)

Parameters:
  • saved_messages_topic_id (int) – Identifier of Saved Messages topic which messages will be fetched

  • from_message_id (int) – Identifier of the message starting from which messages must be fetched; use 0 to get results from the last message

  • offset (int) – Specify 0 to get results from exactly the message from_message_id or a negative number from -99 to -1 to get additionally -offset newer messages

  • limit (int) – The maximum number of messages to be returned; must be positive and can’t be greater than 100. If the offset is negative, then the limit must be greater than or equal to -offset. For optimal performance, the number of returned messages is chosen by TDLib and can be smaller than the specified limit

Return type:

Union[Error, Messages]

Returns:

Messages

async getSavedMessagesTopicMessageByDate(saved_messages_topic_id=0, date=0)[source]

Returns the last message sent in a Saved Messages topic no later than the specified date

Parameters:
  • saved_messages_topic_id (int) – Identifier of Saved Messages topic which message will be returned

  • date (int) – Point in time (Unix timestamp) relative to which to search for messages

Return type:

Union[Error, Message]

Returns:

Message

async getSavedNotificationSound(notification_sound_id=0)[source]

Returns saved notification sound by its identifier. Returns a 404 error if there is no saved notification sound with the specified identifier

Parameters:

notification_sound_id (int) – Identifier of the notification sound

Return type:

Union[Error, NotificationSounds]

Returns:

NotificationSounds

async getSavedNotificationSounds()[source]

Returns the list of saved notification sounds. If a sound isn’t in the list, then default sound needs to be used

Return type:

Union[Error, NotificationSounds]

Returns:

NotificationSounds

async getSavedOrderInfo()[source]

Returns saved order information. Returns a 404 error if there is no saved order information

Return type:

Union[Error, OrderInfo]

Returns:

OrderInfo

async getScopeNotificationSettings(scope=None)[source]

Returns the notification settings for chats of a given type

Parameters:

scope ("types.NotificationSettingsScope") – Types of chats for which to return the notification settings information

Return type:

Union[Error, ScopeNotificationSettings]

Returns:

ScopeNotificationSettings

async getSearchSponsoredChats(query='')[source]

Returns sponsored chats to be shown in the search results

Parameters:

query (str) – Query the user searches for

Return type:

Union[Error, SponsoredChats]

Returns:

SponsoredChats

async getSearchedForTags(tag_prefix='', limit=0)[source]

Returns recently searched for hashtags or cashtags by their prefix

Parameters:
  • tag_prefix (str) – Prefix of hashtags or cashtags to return

  • limit (int) – The maximum number of items to be returned

Return type:

Union[Error, Hashtags]

Returns:

Hashtags

async getSecretChat(secret_chat_id=0)[source]

Returns information about a secret chat by its identifier. This is an offline method

Parameters:

secret_chat_id (int) – Secret chat identifier

Return type:

Union[Error, SecretChat]

Returns:

SecretChat

async getStarAdAccountUrl(owner_id=None)[source]

Returns a URL for a Telegram Ad platform account that can be used to set up advertisements for the chat paid in the owned Telegram Stars

Parameters:

owner_id ("types.MessageSender") – Identifier of the owner of the Telegram Stars; can be identifier of an owned bot, or identifier of an owned channel chat

Return type:

Union[Error, HttpUrl]

Returns:

HttpUrl

async getStarGiftPaymentOptions(user_id=0)[source]

Returns available options for Telegram Stars gifting

Parameters:

user_id (int) – Identifier of the user that will receive Telegram Stars; pass 0 to get options for an unspecified user

Return type:

Union[Error, StarPaymentOptions]

Returns:

StarPaymentOptions

async getStarGiveawayPaymentOptions()[source]

Returns available options for Telegram Star giveaway creation

Return type:

Union[Error, StarGiveawayPaymentOptions]

Returns:

StarGiveawayPaymentOptions

async getStarPaymentOptions()[source]

Returns available options for Telegram Stars purchase

Return type:

Union[Error, StarPaymentOptions]

Returns:

StarPaymentOptions

async getStarRevenueStatistics(owner_id=None, is_dark=False)[source]

Returns detailed Telegram Star revenue statistics

Parameters:
  • owner_id ("types.MessageSender") – Identifier of the owner of the Telegram Stars; can be identifier of the current user, an owned bot, or a supergroup or a channel chat with supergroupFullInfo.can_get_star_revenue_statistics == true

  • is_dark (bool) – Pass true if a dark theme is used by the application

Return type:

Union[Error, StarRevenueStatistics]

Returns:

StarRevenueStatistics

async getStarSubscriptions(only_expiring=False, offset='')[source]

Returns the list of Telegram Star subscriptions for the current user

Parameters:
  • only_expiring (bool) – Pass true to receive only expiring subscriptions for which there are no enough Telegram Stars to extend

  • offset (str) – Offset of the first subscription to return as received from the previous request; use empty string to get the first chunk of results

Return type:

Union[Error, StarSubscriptions]

Returns:

StarSubscriptions

async getStarTransactions(owner_id=None, subscription_id='', direction=None, offset='', limit=0)[source]

Returns the list of Telegram Star transactions for the specified owner

Parameters:
  • owner_id ("types.MessageSender") – Identifier of the owner of the Telegram Stars; can be the identifier of the current user, identifier of an owned bot, or identifier of a supergroup or a channel chat with supergroupFullInfo.can_get_star_revenue_statistics == true

  • subscription_id (str) – If non-empty, only transactions related to the Star Subscription will be returned

  • direction ("types.TransactionDirection") – Direction of the transactions to receive; pass null to get all transactions

  • offset (str) – Offset of the first transaction to return as received from the previous request; use empty string to get the first chunk of results

  • limit (int) – The maximum number of transactions to return

Return type:

Union[Error, StarTransactions]

Returns:

StarTransactions

async getStarWithdrawalUrl(owner_id=None, star_count=0, password='')[source]

Returns a URL for Telegram Star withdrawal

Parameters:
  • owner_id ("types.MessageSender") – Identifier of the owner of the Telegram Stars; can be identifier of the current user, an owned bot, or an owned supergroup or channel chat

  • star_count (int) – The number of Telegram Stars to withdraw; must be between getOption("star_withdrawal_count_min") and getOption("star_withdrawal_count_max")

  • password (str) – The 2-step verification password of the current user

Return type:

Union[Error, HttpUrl]

Returns:

HttpUrl

async getStatisticalGraph(chat_id=0, token='', x=0)[source]

Loads an asynchronous or a zoomed in statistical graph

Parameters:
  • chat_id (int) – Chat identifier

  • token (str) – The token for graph loading

  • x (int) – X-value for zoomed in graph or 0 otherwise

Return type:

Union[Error, StatisticalGraph]

Returns:

StatisticalGraph

async getStickerEmojis(sticker=None)[source]

Returns emoji corresponding to a sticker. The list is only for informational purposes, because a sticker is always sent with a fixed emoji from the corresponding Sticker object

Parameters:

sticker ("types.InputFile") – Sticker file identifier

Return type:

Union[Error, Emojis]

Returns:

Emojis

async getStickerOutline(sticker_file_id=0, for_animated_emoji=False, for_clicked_animated_emoji_message=False)[source]

Returns outline of a sticker. This is an offline method. Returns a 404 error if the outline isn’t known

Parameters:
  • sticker_file_id (int) – File identifier of the sticker

  • for_animated_emoji (bool) – Pass true to get the outline scaled for animated emoji

  • for_clicked_animated_emoji_message (bool) – Pass true to get the outline scaled for clicked animated emoji message

Return type:

Union[Error, Outline]

Returns:

Outline

async getStickerSet(set_id=0)[source]

Returns information about a sticker set by its identifier

Parameters:

set_id (int) – Identifier of the sticker set

Return type:

Union[Error, StickerSet]

Returns:

StickerSet

async getStickerSetName(set_id=0)[source]

Returns name of a sticker set by its identifier

Parameters:

set_id (int) – Identifier of the sticker set

Return type:

Union[Error, Text]

Returns:

Text

async getStickers(sticker_type=None, query='', limit=0, chat_id=0)[source]

Returns stickers from the installed sticker sets that correspond to any of the given emoji or can be found by sticker-specific keywords. If the query is non-empty, then favorite, recently used or trending stickers may also be returned

Parameters:
  • sticker_type ("types.StickerType") – Type of the stickers to return

  • query (str) – Search query; a space-separated list of emojis or a keyword prefix. If empty, returns all known installed stickers

  • limit (int) – The maximum number of stickers to be returned

  • chat_id (int) – Chat identifier for which to return stickers. Available custom emoji stickers may be different for different chats

Return type:

Union[Error, Stickers]

Returns:

Stickers

async getStorageStatistics(chat_limit=0)[source]

Returns storage usage statistics. Can be called before authorization

Parameters:

chat_limit (int) – The maximum number of chats with the largest storage usage for which separate statistics need to be returned. All other chats will be grouped in entries with chat_id == 0. If the chat info database is not used, the chat_limit is ignored and is always set to 0

Return type:

Union[Error, StorageStatistics]

Returns:

StorageStatistics

async getStorageStatisticsFast()[source]

Quickly returns approximate storage usage statistics. Can be called before authorization

Return type:

Union[Error, StorageStatisticsFast]

Returns:

StorageStatisticsFast

async getStory(story_poster_chat_id=0, story_id=0, only_local=False)[source]

Returns a story

Parameters:
  • story_poster_chat_id (int) – Identifier of the chat that posted the story

  • story_id (int) – Story identifier

  • only_local (bool) – Pass true to get only locally available information without sending network requests

Return type:

Union[Error, Story]

Returns:

Story

async getStoryAlbumStories(chat_id=0, story_album_id=0, offset=0, limit=0)[source]

Returns the list of stories added to the given story album. For optimal performance, the number of returned stories is chosen by TDLib

Parameters:
  • chat_id (int) – Chat identifier

  • story_album_id (int) – Story album identifier

  • offset (int) – Offset of the first entry to return; use 0 to get results from the first album story

  • limit (int) – The maximum number of stories to be returned. For optimal performance, the number of returned stories is chosen by TDLib and can be smaller than the specified limit

Return type:

Union[Error, Stories]

Returns:

Stories

async getStoryAvailableReactions(row_size=0)[source]

Returns reactions, which can be chosen for a story

Parameters:

row_size (int) – Number of reaction per row, 5-25

Return type:

Union[Error, AvailableReactions]

Returns:

AvailableReactions

async getStoryInteractions(story_id=0, query='', only_contacts=False, prefer_forwards=False, prefer_with_reaction=False, offset='', limit=0)[source]

Returns interactions with a story. The method can be called only for stories posted on behalf of the current user

Parameters:
  • story_id (int) – Story identifier

  • query (str) – Query to search for in names, usernames and titles; may be empty to get all relevant interactions

  • only_contacts (bool) – Pass true to get only interactions by contacts; pass false to get all relevant interactions

  • prefer_forwards (bool) – Pass true to get forwards and reposts first, then reactions, then other views; pass false to get interactions sorted just by interaction date

  • prefer_with_reaction (bool) – Pass true to get interactions with reaction first; pass false to get interactions sorted just by interaction date. Ignored if prefer_forwards == true

  • offset (str) – Offset of the first entry to return as received from the previous request; use empty string to get the first chunk of results

  • limit (int) – The maximum number of story interactions to return

Return type:

Union[Error, StoryInteractions]

Returns:

StoryInteractions

async getStoryNotificationSettingsExceptions()[source]

Returns the list of chats with non-default notification settings for stories

Return type:

Union[Error, Chats]

Returns:

Chats

async getStoryPublicForwards(story_poster_chat_id=0, story_id=0, offset='', limit=0)[source]

Returns forwards of a story as a message to public chats and reposts by public channels. Can be used only if the story is posted on behalf of the current user or story.can_get_statistics == true. For optimal performance, the number of returned messages and stories is chosen by TDLib

Parameters:
  • story_poster_chat_id (int) – The identifier of the poster of the story

  • story_id (int) – The identifier of the story

  • offset (str) – Offset of the first entry to return as received from the previous request; use empty string to get the first chunk of results

  • limit (int) – The maximum number of messages and stories to be returned; must be positive and can’t be greater than 100. For optimal performance, the number of returned objects is chosen by TDLib and can be smaller than the specified limit

Return type:

Union[Error, PublicForwards]

Returns:

PublicForwards

async getStoryStatistics(chat_id=0, story_id=0, is_dark=False)[source]

Returns detailed statistics about a story. Can be used only if story.can_get_statistics == true

Parameters:
  • chat_id (int) – Chat identifier

  • story_id (int) – Story identifier

  • is_dark (bool) – Pass true if a dark theme is used by the application

Return type:

Union[Error, StoryStatistics]

Returns:

StoryStatistics

async getSuggestedFileName(file_id=0, directory='')[source]

Returns suggested name for saving a file in a given directory

Parameters:
  • file_id (int) – Identifier of the file

  • directory (str) – Directory in which the file is expected to be saved

Return type:

Union[Error, Text]

Returns:

Text

async getSuggestedStickerSetName(title='')[source]

Returns a suggested name for a new sticker set with a given title

Parameters:

title (str) – Sticker set title; 1-64 characters

Return type:

Union[Error, Text]

Returns:

Text

async getSuitableDiscussionChats()[source]

Returns a list of basic group and supergroup chats, which can be used as a discussion group for a channel. Returned basic group chats must be first upgraded to supergroups before they can be set as a discussion group. To set a returned supergroup as a discussion group, access to its old messages must be enabled using toggleSupergroupIsAllHistoryAvailable first

Return type:

Union[Error, Chats]

Returns:

Chats

async getSuitablePersonalChats()[source]

Returns a list of channel chats, which can be used as a personal chat

Return type:

Union[Error, Chats]

Returns:

Chats

async getSupergroup(supergroup_id=0)[source]

Returns information about a supergroup or a channel by its identifier. This is an offline method if the current user is not a bot

Parameters:

supergroup_id (int) – Supergroup or channel identifier

Return type:

Union[Error, Supergroup]

Returns:

Supergroup

async getSupergroupFullInfo(supergroup_id=0)[source]

Returns full information about a supergroup or a channel by its identifier, cached for up to 1 minute

Parameters:

supergroup_id (int) – Supergroup or channel identifier

Return type:

Union[Error, SupergroupFullInfo]

Returns:

SupergroupFullInfo

async getSupergroupMembers(supergroup_id=0, filter=None, offset=0, limit=0)[source]

Returns information about members or banned users in a supergroup or channel. Can be used only if supergroupFullInfo.can_get_members == true; additionally, administrator privileges may be required for some filters

Parameters:
  • supergroup_id (int) – Identifier of the supergroup or channel

  • filter ("types.SupergroupMembersFilter") – The type of users to return; pass null to use supergroupMembersFilterRecent

  • offset (int) – Number of users to skip

  • limit (int) – The maximum number of users to be returned; up to 200

Return type:

Union[Error, ChatMembers]

Returns:

ChatMembers

async getSupportName()[source]

Returns localized name of the Telegram support user; for Telegram support only

Return type:

Union[Error, Text]

Returns:

Text

async getSupportUser()[source]

Returns a user that can be contacted to get support

Return type:

Union[Error, User]

Returns:

User

async getTemporaryPasswordState()[source]

Returns information about the current temporary password

Return type:

Union[Error, TemporaryPasswordState]

Returns:

TemporaryPasswordState

async getTextEntities(text='')[source]

Returns all entities (mentions, hashtags, cashtags, bot commands, bank card numbers, URLs, and email addresses) found in the text. Can be called synchronously

Parameters:

text (str) – The text in which to look for entities

Return type:

Union[Error, TextEntities]

Returns:

TextEntities

async getThemeParametersJsonString(theme=None)[source]

Converts a themeParameters object to corresponding JSON-serialized string. Can be called synchronously

Parameters:

theme ("types.ThemeParameters") – Theme parameters to convert to JSON

Return type:

Union[Error, Text]

Returns:

Text

async getThemedChatEmojiStatuses()[source]

Returns up to 8 emoji statuses, which must be shown in the emoji status list for chats

Return type:

Union[Error, EmojiStatusCustomEmojis]

Returns:

EmojiStatusCustomEmojis

async getThemedEmojiStatuses()[source]

Returns up to 8 emoji statuses, which must be shown right after the default Premium Badge in the emoji status list for self status

Return type:

Union[Error, EmojiStatusCustomEmojis]

Returns:

EmojiStatusCustomEmojis

async getTimeZones()[source]

Returns the list of supported time zones

Return type:

Union[Error, TimeZones]

Returns:

TimeZones

async getTonRevenueStatistics(is_dark=False)[source]

Returns detailed Toncoin revenue statistics of the current user

Parameters:

is_dark (bool) – Pass true if a dark theme is used by the application

Return type:

Union[Error, TonRevenueStatistics]

Returns:

TonRevenueStatistics

async getTonTransactions(direction=None, offset='', limit=0)[source]

Returns the list of Toncoin transactions of the current user

Parameters:
  • direction ("types.TransactionDirection") – Direction of the transactions to receive; pass null to get all transactions

  • offset (str) – Offset of the first transaction to return as received from the previous request; use empty string to get the first chunk of results

  • limit (int) – The maximum number of transactions to return

Return type:

Union[Error, TonTransactions]

Returns:

TonTransactions

async getTonWithdrawalUrl(password='')[source]

Returns a URL for Toncoin withdrawal from the current user’s account. The user must have at least 10 toncoins to withdraw and can withdraw up to 100000 Toncoins in one transaction

Parameters:

password (str) – The 2-step verification password of the current user

Return type:

Union[Error, HttpUrl]

Returns:

HttpUrl

async getTopChats(category=None, limit=0)[source]

Returns a list of frequently used chats

Parameters:
  • category ("types.TopChatCategory") – Category of chats to be returned

  • limit (int) – The maximum number of chats to be returned; up to 30

Return type:

Union[Error, Chats]

Returns:

Chats

async getTrendingStickerSets(sticker_type=None, offset=0, limit=0)[source]

Returns a list of trending sticker sets. For optimal performance, the number of returned sticker sets is chosen by TDLib

Parameters:
  • sticker_type ("types.StickerType") – Type of the sticker sets to return

  • offset (int) – The offset from which to return the sticker sets; must be non-negative

  • limit (int) – The maximum number of sticker sets to be returned; up to 100. For optimal performance, the number of returned sticker sets is chosen by TDLib and can be smaller than the specified limit, even if the end of the list has not been reached

Return type:

Union[Error, TrendingStickerSets]

Returns:

TrendingStickerSets

async getUpgradedGift(name='')[source]

Returns information about an upgraded gift by its name

Parameters:

name (str) – Unique name of the upgraded gift

Return type:

Union[Error, UpgradedGift]

Returns:

UpgradedGift

async getUpgradedGiftEmojiStatuses()[source]

Returns available upgraded gift emoji statuses for self status

Return type:

Union[Error, EmojiStatuses]

Returns:

EmojiStatuses

async getUpgradedGiftValueInfo(name='')[source]

Returns information about value of an upgraded gift by its name

Parameters:

name (str) – Unique name of the upgraded gift

Return type:

Union[Error, UpgradedGiftValueInfo]

Returns:

UpgradedGiftValueInfo

async getUpgradedGiftWithdrawalUrl(received_gift_id='', password='')[source]

Returns a URL for upgraded gift withdrawal in the TON blockchain as an NFT; requires owner privileges for gifts owned by a chat

Parameters:
  • received_gift_id (str) – Identifier of the gift

  • password (str) – The 2-step verification password of the current user

Return type:

Union[Error, HttpUrl]

Returns:

HttpUrl

async getUser(user_id=0)[source]

Returns information about a user by their identifier. This is an offline method if the current user is not a bot

Parameters:

user_id (int) – User identifier

Return type:

Union[Error, User]

Returns:

User

async getUserChatBoosts(chat_id=0, user_id=0)[source]

Returns the list of boosts applied to a chat by a given user; requires administrator rights in the chat; for bots only

Parameters:
  • chat_id (int) – Identifier of the chat

  • user_id (int) – Identifier of the user

Return type:

Union[Error, FoundChatBoosts]

Returns:

FoundChatBoosts

async getUserFullInfo(user_id=0)[source]

Returns full information about a user by their identifier

Parameters:

user_id (int) – User identifier

Return type:

Union[Error, UserFullInfo]

Returns:

UserFullInfo

Returns an HTTPS link, which can be used to get information about the current user

Return type:

Union[Error, UserLink]

Returns:

UserLink

async getUserPrivacySettingRules(setting=None)[source]

Returns the current privacy settings

Parameters:

setting ("types.UserPrivacySetting") – The privacy setting

Return type:

Union[Error, UserPrivacySettingRules]

Returns:

UserPrivacySettingRules

async getUserProfileAudios(user_id=0, offset=0, limit=0)[source]

Returns the list of profile audio files of a user

Parameters:
  • user_id (int) – User identifier

  • offset (int) – The number of audio files to skip; must be non-negative

  • limit (int) – The maximum number of audio files to be returned; up to 100

Return type:

Union[Error, Audios]

Returns:

Audios

async getUserProfilePhotos(user_id=0, offset=0, limit=0)[source]

Returns the profile photos of a user. Personal and public photo aren’t returned

Parameters:
  • user_id (int) – User identifier

  • offset (int) – The number of photos to skip; must be non-negative

  • limit (int) – The maximum number of photos to be returned; up to 100

Return type:

Union[Error, ChatPhotos]

Returns:

ChatPhotos

async getUserSupportInfo(user_id=0)[source]

Returns support information for the given user; for Telegram support only

Parameters:

user_id (int) – User identifier

Return type:

Union[Error, UserSupportInfo]

Returns:

UserSupportInfo

async getVideoChatAvailableParticipants(chat_id=0)[source]

Returns the list of participant identifiers, on whose behalf a video chat in the chat can be joined

Parameters:

chat_id (int) – Chat identifier

Return type:

Union[Error, MessageSenders]

Returns:

MessageSenders

Returns invite link to a video chat in a public chat

Parameters:
  • group_call_id (int) – Group call identifier

  • can_self_unmute (bool) – Pass true if the invite link needs to contain an invite hash, passing which to joinVideoChat would allow the invited user to unmute themselves. Requires groupCall.can_be_managed right

Return type:

Union[Error, HttpUrl]

Returns:

HttpUrl

async getVideoChatRtmpUrl(chat_id=0)[source]

Returns RTMP URL for streaming to the video chat of a chat; requires can_manage_video_chats administrator right

Parameters:

chat_id (int) – Chat identifier

Return type:

Union[Error, RtmpUrl]

Returns:

RtmpUrl

async getVideoChatStreamSegment(group_call_id=0, time_offset=0, scale=0, channel_id=0, video_quality=None)[source]

Returns a file with a segment of a video chat stream in a modified OGG format for audio or MPEG-4 format for video

Parameters:
  • group_call_id (int) – Group call identifier

  • time_offset (int) – Point in time when the stream segment begins; Unix timestamp in milliseconds

  • scale (int) – Segment duration scale; 0-1. Segment’s duration is 1000/(2**scale) milliseconds

  • channel_id (int) – Identifier of an audio/video channel to get as received from tgcalls

  • video_quality ("types.GroupCallVideoQuality") – Video quality as received from tgcalls; pass null to get the worst available quality

Return type:

Union[Error, Data]

Returns:

Data

async getVideoChatStreams(group_call_id=0)[source]

Returns information about available video chat streams

Parameters:

group_call_id (int) – Group call identifier

Return type:

Union[Error, VideoChatStreams]

Returns:

VideoChatStreams

async getVideoMessageAdvertisements(chat_id=0, message_id=0)[source]

Returns advertisements to be shown while a video from a message is watched. Available only if messageProperties.can_get_video_advertisements

Parameters:
  • chat_id (int) – Identifier of the chat with the message

  • message_id (int) – Identifier of the message

Return type:

Union[Error, VideoMessageAdvertisements]

Returns:

VideoMessageAdvertisements

async getWebAppLinkUrl(chat_id=0, bot_user_id=0, web_app_short_name='', start_parameter='', allow_write_access=False, parameters=None)[source]

Returns an HTTPS URL of a Web App to open after a link of the type internalLinkTypeWebApp is clicked

Parameters:
  • chat_id (int) – Identifier of the chat in which the link was clicked; pass 0 if none

  • bot_user_id (int) – Identifier of the target bot

  • web_app_short_name (str) – Short name of the Web App

  • start_parameter (str) – Start parameter from internalLinkTypeWebApp

  • allow_write_access (bool) – Pass true if the current user allowed the bot to send them messages

  • parameters ("types.WebAppOpenParameters") – Parameters to use to open the Web App

Return type:

Union[Error, HttpUrl]

Returns:

HttpUrl

async getWebAppPlaceholder(bot_user_id=0)[source]

Returns a default placeholder for Web Apps of a bot. This is an offline method. Returns a 404 error if the placeholder isn’t known

Parameters:

bot_user_id (int) – Identifier of the target bot

Return type:

Union[Error, Outline]

Returns:

Outline

async getWebAppUrl(bot_user_id=0, url='', parameters=None)[source]

Returns an HTTPS URL of a Web App to open from the side menu, a keyboardButtonTypeWebApp button, or an inlineQueryResultsButtonTypeWebApp button

Parameters:
  • bot_user_id (int) – Identifier of the target bot. If the bot is restricted for the current user, then show an error instead of calling the method

  • url (str) – The URL from a keyboardButtonTypeWebApp button, inlineQueryResultsButtonTypeWebApp button, or an empty string when the bot is opened from the side menu

  • parameters ("types.WebAppOpenParameters") – Parameters to use to open the Web App

Return type:

Union[Error, HttpUrl]

Returns:

HttpUrl

async getWebPageInstantView(url='', only_local=False)[source]

Returns an instant view version of a web page if available. This is an offline method if only_local is true. Returns a 404 error if the web page has no instant view page

Parameters:
  • url (str) – The web page URL

  • only_local (bool) – Pass true to get only locally available information without sending network requests

Return type:

Union[Error, WebPageInstantView]

Returns:

WebPageInstantView

async giftPremiumWithStars(user_id=0, star_count=0, month_count=0, text=None)[source]

Allows to buy a Telegram Premium subscription for another user with payment in Telegram Stars; for bots only

Parameters:
  • user_id (int) – Identifier of the user which will receive Telegram Premium

  • star_count (int) – The number of Telegram Stars to pay for subscription

  • month_count (int) – Number of months the Telegram Premium subscription will be active for the user

  • text ("types.FormattedText") – Text to show to the user receiving Telegram Premium; 0-getOption("gift_text_length_max") characters. Only Bold, Italic, Underline, Strikethrough, Spoiler, and CustomEmoji entities are allowed

Return type:

Union[Error, Ok]

Returns:

Ok

async hideContactCloseBirthdays()[source]

Hides the list of contacts that have close birthdays for 24 hours

Return type:

Union[Error, Ok]

Returns:

Ok

async hideSuggestedAction(action=None)[source]

Hides a suggested action

Parameters:

action ("types.SuggestedAction") – Suggested action to hide

Return type:

Union[Error, Ok]

Returns:

Ok

async importContacts(contacts=None)[source]

Adds new contacts or edits existing contacts by their phone numbers; contacts’ user identifiers are ignored

Parameters:

contacts (List["types.Contact"]) – The list of contacts to import or edit; contacts’ vCard are ignored and are not imported

Return type:

Union[Error, ImportedContacts]

Returns:

ImportedContacts

async importMessages(chat_id=0, message_file=None, attached_files=None)[source]

Imports messages exported from another app

Parameters:
  • chat_id (int) – Identifier of a chat to which the messages will be imported. It must be an identifier of a private chat with a mutual contact or an identifier of a supergroup chat with can_change_info member right

  • message_file ("types.InputFile") – File with messages to import. Only inputFileLocal and inputFileGenerated are supported. The file must not be previously uploaded

  • attached_files (List["types.InputFile"]) – Files used in the imported messages. Only inputFileLocal and inputFileGenerated are supported. The files must not be previously uploaded

Return type:

Union[Error, Ok]

Returns:

Ok

async inviteGroupCallParticipant(group_call_id=0, user_id=0, is_video=False)[source]

Invites a user to an active group call; for group calls not bound to a chat only. Sends a service message of the type messageGroupCall. The group call can have at most getOption("group_call_participant_count_max") participants

Parameters:
  • group_call_id (int) – Group call identifier

  • user_id (int) – User identifier

  • is_video (bool) – Pass true if the group call is a video call

Return type:

Union[Error, InviteGroupCallParticipantResult]

Returns:

InviteGroupCallParticipantResult

async inviteVideoChatParticipants(group_call_id=0, user_ids=None)[source]

Invites users to an active video chat. Sends a service message of the type messageInviteVideoChatParticipants to the chat bound to the group call

Parameters:
  • group_call_id (int) – Group call identifier

  • user_ids (List[int]) – User identifiers. At most 10 users can be invited simultaneously

Return type:

Union[Error, Ok]

Returns:

Ok

async isProfileAudio(file_id=0)[source]

Checks whether a file is in the profile audio files of the current user. Returns a 404 error if it isn’t

Parameters:

file_id (int) – Identifier of the audio file to check

Return type:

Union[Error, Ok]

Returns:

Ok

async joinChat(chat_id=0)[source]

Adds the current user as a new member to a chat. Private and secret chats can’t be joined using this method. May return an error with a message "INVITE_REQUEST_SENT" if only a join request was created

Parameters:

chat_id (int) – Chat identifier

Return type:

Union[Error, Ok]

Returns:

Ok

Uses an invite link to add the current user to the chat if possible. May return an error with a message "INVITE_REQUEST_SENT" if only a join request was created

Parameters:

invite_link (str) – Invite link to use

Return type:

Union[Error, Chat]

Returns:

Chat

async joinGroupCall(input_group_call=None, join_parameters=None)[source]

Joins a group call that is not bound to a chat

Parameters:
  • input_group_call ("types.InputGroupCall") – The group call to join

  • join_parameters ("types.GroupCallJoinParameters") – Parameters to join the call

Return type:

Union[Error, GroupCallInfo]

Returns:

GroupCallInfo

async joinVideoChat(group_call_id=0, participant_id=None, join_parameters=None, invite_hash='')[source]

Joins an active video chat. Returns join response payload for tgcalls

Parameters:
  • group_call_id (int) – Group call identifier

  • participant_id ("types.MessageSender") – Identifier of a group call participant, which will be used to join the call; pass null to join as self; video chats only

  • join_parameters ("types.GroupCallJoinParameters") – Parameters to join the call

  • invite_hash (str) – Invite hash as received from internalLinkTypeVideoChat

Return type:

Union[Error, Text]

Returns:

Text

async launchPrepaidGiveaway(giveaway_id=0, parameters=None, winner_count=0, star_count=0)[source]

Launches a prepaid giveaway

Parameters:
  • giveaway_id (int) – Unique identifier of the prepaid giveaway

  • parameters ("types.GiveawayParameters") – Giveaway parameters

  • winner_count (int) – The number of users to receive giveaway prize

  • star_count (int) – The number of Telegram Stars to be distributed through the giveaway; pass 0 for Telegram Premium giveaways

Return type:

Union[Error, Ok]

Returns:

Ok

async leaveChat(chat_id=0)[source]

Removes the current user from chat members. Private and secret chats can’t be left using this method

Parameters:

chat_id (int) – Chat identifier

Return type:

Union[Error, Ok]

Returns:

Ok

async leaveGroupCall(group_call_id=0)[source]

Leaves a group call

Parameters:

group_call_id (int) – Group call identifier

Return type:

Union[Error, Ok]

Returns:

Ok

async loadActiveStories(story_list=None)[source]

Loads more active stories from a story list. The loaded stories will be sent through updates. Active stories are sorted by the pair (active_stories.order, active_stories.story_poster_chat_id) in descending order. Returns a 404 error if all active stories have been loaded

Parameters:

story_list ("types.StoryList") – The story list in which to load active stories

Return type:

Union[Error, Ok]

Returns:

Ok

async loadChats(chat_list=None, limit=0)[source]

Loads more chats from a chat list. The loaded chats and their positions in the chat list will be sent through updates. Chats are sorted by the pair (chat.position.order, chat.id) in descending order. Returns a 404 error if all chats have been loaded

Parameters:
  • chat_list ("types.ChatList") – The chat list in which to load chats; pass null to load chats from the main chat list

  • limit (int) – The maximum number of chats to be loaded. For optimal performance, the number of loaded chats is chosen by TDLib and can be smaller than the specified limit, even if the end of the list is not reached

Return type:

Union[Error, Ok]

Returns:

Ok

async loadDirectMessagesChatTopics(chat_id=0, limit=0)[source]

Loads more topics in a channel direct messages chat administered by the current user. The loaded topics will be sent through updateDirectMessagesChatTopic. Topics are sorted by their topic.order in descending order. Returns a 404 error if all topics have been loaded

Parameters:
  • chat_id (int) – Chat identifier of the channel direct messages chat

  • limit (int) – The maximum number of topics to be loaded. For optimal performance, the number of loaded topics is chosen by TDLib and can be smaller than the specified limit, even if the end of the list is not reached

Return type:

Union[Error, Ok]

Returns:

Ok

async loadGroupCallParticipants(group_call_id=0, limit=0)[source]

Loads more participants of a group call. The loaded participants will be received through updates. Use the field groupCall.loaded_all_participants to check whether all participants have already been loaded

Parameters:
  • group_call_id (int) – Group call identifier. The group call must be previously received through getGroupCall and must be joined or being joined

  • limit (int) – The maximum number of participants to load; up to 100

Return type:

Union[Error, Ok]

Returns:

Ok

async loadQuickReplyShortcutMessages(shortcut_id=0)[source]

Loads quick reply messages that can be sent by a given quick reply shortcut. The loaded messages will be sent through updateQuickReplyShortcutMessages

Parameters:

shortcut_id (int) – Unique identifier of the quick reply shortcut

Return type:

Union[Error, Ok]

Returns:

Ok

async loadQuickReplyShortcuts()[source]

Loads quick reply shortcuts created by the current user. The loaded data will be sent through updateQuickReplyShortcut and updateQuickReplyShortcuts

Return type:

Union[Error, Ok]

Returns:

Ok

async loadSavedMessagesTopics(limit=0)[source]

Loads more Saved Messages topics. The loaded topics will be sent through updateSavedMessagesTopic. Topics are sorted by their topic.order in descending order. Returns a 404 error if all topics have been loaded

Parameters:

limit (int) – The maximum number of topics to be loaded. For optimal performance, the number of loaded topics is chosen by TDLib and can be smaller than the specified limit, even if the end of the list is not reached

Return type:

Union[Error, Ok]

Returns:

Ok

async logOut()[source]

Closes the TDLib instance after a proper logout. Requires an available network connection. All local data will be destroyed. After the logout completes, updateAuthorizationState with authorizationStateClosed will be sent

Return type:

Union[Error, Ok]

Returns:

Ok

async markChecklistTasksAsDone(chat_id=0, message_id=0, marked_as_done_task_ids=None, marked_as_not_done_task_ids=None)[source]

Adds tasks of a checklist in a message as done or not done

Parameters:
  • chat_id (int) – Identifier of the chat with the message

  • message_id (int) – Identifier of the message containing the checklist. Use messageProperties.can_mark_tasks_as_done to check whether the tasks can be marked as done or not done

  • marked_as_done_task_ids (List[int]) – Identifiers of tasks that were marked as done

  • marked_as_not_done_task_ids (List[int]) – Identifiers of tasks that were marked as not done

Return type:

Union[Error, Ok]

Returns:

Ok

async openBotSimilarBot(bot_user_id=0, opened_bot_user_id=0)[source]

Informs TDLib that a bot was opened from the list of similar bots

Parameters:
  • bot_user_id (int) – Identifier of the original bot, which similar bots were requested

  • opened_bot_user_id (int) – Identifier of the opened bot

Return type:

Union[Error, Ok]

Returns:

Ok

async openChat(chat_id=0)[source]

Informs TDLib that the chat is opened by the user. Many useful activities depend on the chat being opened or closed (e.g., in supergroups and channels all updates are received only for opened chats)

Parameters:

chat_id (int) – Chat identifier

Return type:

Union[Error, Ok]

Returns:

Ok

async openChatSimilarChat(chat_id=0, opened_chat_id=0)[source]

Informs TDLib that a chat was opened from the list of similar chats. The method is independent of openChat and closeChat methods

Parameters:
  • chat_id (int) – Identifier of the original chat, which similar chats were requested

  • opened_chat_id (int) – Identifier of the opened chat

Return type:

Union[Error, Ok]

Returns:

Ok

async openMessageContent(chat_id=0, message_id=0)[source]

Informs TDLib that the message content has been opened (e.g., the user has opened a photo, video, document, location or venue, or has listened to an audio file or voice note message). An updateMessageContentOpened update will be generated if something has changed

Parameters:
  • chat_id (int) – Chat identifier of the message

  • message_id (int) – Identifier of the message with the opened content

Return type:

Union[Error, Ok]

Returns:

Ok

async openSponsoredChat(sponsored_chat_unique_id=0)[source]

Informs TDLib that the user opened a sponsored chat

Parameters:

sponsored_chat_unique_id (int) – Unique identifier of the sponsored chat

Return type:

Union[Error, Ok]

Returns:

Ok

async openStory(story_poster_chat_id=0, story_id=0)[source]

Informs TDLib that a story is opened and is being viewed by the user

Parameters:
  • story_poster_chat_id (int) – The identifier of the chat that posted the opened story

  • story_id (int) – The identifier of the story

Return type:

Union[Error, Ok]

Returns:

Ok

async openWebApp(chat_id=0, bot_user_id=0, url='', message_thread_id=0, direct_messages_chat_topic_id=0, reply_to=None, parameters=None)[source]

Informs TDLib that a Web App is being opened from the attachment menu, a botMenuButton button, an internalLinkTypeAttachmentMenuBot link, or an inlineKeyboardButtonTypeWebApp button. For each bot, a confirmation alert about data sent to the bot must be shown once

Parameters:
  • chat_id (int) – Identifier of the chat in which the Web App is opened. The Web App can’t be opened in secret chats

  • bot_user_id (int) – Identifier of the bot, providing the Web App. If the bot is restricted for the current user, then show an error instead of calling the method

  • url (str) – The URL from an inlineKeyboardButtonTypeWebApp button, a botMenuButton button, an internalLinkTypeAttachmentMenuBot link, or an empty string otherwise

  • message_thread_id (int) – If not 0, the message thread identifier to which the message will be sent

  • direct_messages_chat_topic_id (int) – If not 0, unique identifier of the topic of channel direct messages chat to which the message will be sent

  • reply_to ("types.InputMessageReplyTo") – Information about the message or story to be replied in the message sent by the Web App; pass null if none

  • parameters ("types.WebAppOpenParameters") – Parameters to use to open the Web App

Return type:

Union[Error, WebAppInfo]

Returns:

WebAppInfo

async optimizeStorage(size=0, ttl=0, count=0, immunity_delay=0, file_types=None, chat_ids=None, exclude_chat_ids=None, return_deleted_file_statistics=False, chat_limit=0)[source]

Optimizes storage usage, i.e. deletes some files and returns new storage usage statistics. Secret thumbnails can’t be deleted

Parameters:
  • size (int) – Limit on the total size of files after deletion, in bytes. Pass -1 to use the default limit

  • ttl (int) – Limit on the time that has passed since the last time a file was accessed (or creation time for some filesystems). Pass -1 to use the default limit

  • count (int) – Limit on the total number of files after deletion. Pass -1 to use the default limit

  • immunity_delay (int) – The amount of time after the creation of a file during which it can’t be deleted, in seconds. Pass -1 to use the default value

  • file_types (List["types.FileType"]) – If non-empty, only files with the given types are considered. By default, all types except thumbnails, profile photos, stickers and wallpapers are deleted

  • chat_ids (List[int]) – If non-empty, only files from the given chats are considered. Use 0 as chat identifier to delete files not belonging to any chat (e.g., profile photos)

  • exclude_chat_ids (List[int]) – If non-empty, files from the given chats are excluded. Use 0 as chat identifier to exclude all files not belonging to any chat (e.g., profile photos)

  • return_deleted_file_statistics (bool) – Pass true if statistics about the files that were deleted must be returned instead of the whole storage usage statistics. Affects only returned statistics

  • chat_limit (int) – Same as in getStorageStatistics. Affects only returned statistics

Return type:

Union[Error, StorageStatistics]

Returns:

StorageStatistics

async parseMarkdown(text=None)[source]

Parses Markdown entities in a human-friendly format, ignoring markup errors. Can be called synchronously

Parameters:

text ("types.FormattedText") – The text to parse. For example, "__italic__ ~~strikethrough~~ ||spoiler|| **bold** `code` ```pre``` __[italic__ text_url](telegram.org) __italic**bold italic__bold**"

Return type:

Union[Error, FormattedText]

Returns:

FormattedText

async parseTextEntities(text='', parse_mode=None)[source]

Parses Bold, Italic, Underline, Strikethrough, Spoiler, CustomEmoji, BlockQuote, ExpandableBlockQuote, Code, Pre, PreCode, TextUrl and MentionName entities from a marked-up text. Can be called synchronously

Parameters:
  • text (str) – The text to parse

  • parse_mode ("types.TextParseMode") – Text parse mode

Return type:

Union[Error, FormattedText]

Returns:

FormattedText

async pinChatMessage(chat_id=0, message_id=0, disable_notification=False, only_for_self=False)[source]

Pins a message in a chat. A message can be pinned only if messageProperties.can_be_pinned

Parameters:
  • chat_id (int) – Identifier of the chat

  • message_id (int) – Identifier of the new pinned message

  • disable_notification (bool) – Pass true to disable notification about the pinned message. Notifications are always disabled in channels and private chats

  • only_for_self (bool) – Pass true to pin the message only for self; private chats only

Return type:

Union[Error, Ok]

Returns:

Ok

async pingProxy(proxy_id=0)[source]

Computes time needed to receive a response from a Telegram server through a proxy. Can be called before authorization

Parameters:

proxy_id (int) – Proxy identifier. Use 0 to ping a Telegram server without a proxy

Return type:

Union[Error, Seconds]

Returns:

Seconds

async postStory(chat_id=0, content=None, areas=None, caption=None, privacy_settings=None, album_ids=None, active_period=0, from_story_full_id=None, is_posted_to_chat_page=False, protect_content=False)[source]

Posts a new story on behalf of a chat; requires can_post_stories administrator right for supergroup and channel chats. Returns a temporary story

Parameters:
  • chat_id (int) – Identifier of the chat that will post the story. Pass Saved Messages chat identifier when posting a story on behalf of the current user

  • content ("types.InputStoryContent") – Content of the story

  • areas ("types.InputStoryAreas") – Clickable rectangle areas to be shown on the story media; pass null if none

  • caption ("types.FormattedText") – Story caption; pass null to use an empty caption; 0-getOption("story_caption_length_max") characters; can have entities only if getOption("can_use_text_entities_in_story_caption")

  • privacy_settings ("types.StoryPrivacySettings") – The privacy settings for the story; ignored for stories posted on behalf of supergroup and channel chats

  • album_ids (List[int]) – Identifiers of story albums to which the story will be added upon posting. An album can have up to getOption("story_album_story_count_max")

  • active_period (int) – Period after which the story is moved to archive, in seconds; must be one of 6 * 3600, 12 * 3600, 86400, or 2 * 86400 for Telegram Premium users, and 86400 otherwise

  • from_story_full_id ("types.StoryFullId") – Full identifier of the original story, which content was used to create the story; pass null if the story isn’t repost of another story

  • is_posted_to_chat_page (bool) – Pass true to keep the story accessible after expiration

  • protect_content (bool) – Pass true if the content of the story must be protected from forwarding and screenshotting

Return type:

Union[Error, Story]

Returns:

Story

async preliminaryUploadFile(file=None, file_type=None, priority=0)[source]

Preliminary uploads a file to the cloud before sending it in a message, which can be useful for uploading of being recorded voice and video notes. In all other cases there is no need to preliminary upload a file. Updates updateFile will be used to notify about upload progress. The upload will not be completed until the file is sent in a message

Parameters:
  • file ("types.InputFile") – File to upload

  • file_type ("types.FileType") – File type; pass null if unknown

  • priority (int) – Priority of the upload (1-32). The higher the priority, the earlier the file will be uploaded. If the priorities of two files are equal, then the first one for which preliminaryUploadFile was called will be uploaded first

Return type:

Union[Error, File]

Returns:

File

async processChatFolderNewChats(chat_folder_id=0, added_chat_ids=None)[source]

Process new chats added to a shareable chat folder by its owner

Parameters:
  • chat_folder_id (int) – Chat folder identifier

  • added_chat_ids (List[int]) – Identifiers of the new chats, which are added to the chat folder. The chats are automatically joined if they aren’t joined yet

Return type:

Union[Error, Ok]

Returns:

Ok

async processChatJoinRequest(chat_id=0, user_id=0, approve=False)[source]

Handles a pending join request in a chat

Parameters:
  • chat_id (int) – Chat identifier

  • user_id (int) – Identifier of the user that sent the request

  • approve (bool) – Pass true to approve the request; pass false to decline it

Return type:

Union[Error, Ok]

Returns:

Ok

async processChatJoinRequests(chat_id=0, invite_link='', approve=False)[source]

Handles all pending join requests for a given link in a chat

Parameters:
  • chat_id (int) – Chat identifier

  • invite_link (str) – Invite link for which to process join requests. If empty, all join requests will be processed. Requires administrator privileges and can_invite_users right in the chat for own links and owner privileges for other links

  • approve (bool) – Pass true to approve all requests; pass false to decline them

Return type:

Union[Error, Ok]

Returns:

Ok

async processPushNotification(payload='')[source]

Handles a push notification. Returns error with code 406 if the push notification is not supported and connection to the server is required to fetch new data. Can be called before authorization

Parameters:

payload (str) – JSON-encoded push notification payload with all fields sent by the server, and "google.sent_time" and "google.notification.sound" fields added

Return type:

Union[Error, Ok]

Returns:

Ok

async rateSpeechRecognition(chat_id=0, message_id=0, is_good=False)[source]

Rates recognized speech in a video note or a voice note message

Parameters:
  • chat_id (int) – Identifier of the chat to which the message belongs

  • message_id (int) – Identifier of the message

  • is_good (bool) – Pass true if the speech recognition is good

Return type:

Union[Error, Ok]

Returns:

Ok

async readAllChatMentions(chat_id=0)[source]

Marks all mentions in a chat as read

Parameters:

chat_id (int) – Chat identifier

Return type:

Union[Error, Ok]

Returns:

Ok

async readAllChatReactions(chat_id=0)[source]

Marks all reactions in a chat or a forum topic as read

Parameters:

chat_id (int) – Chat identifier

Return type:

Union[Error, Ok]

Returns:

Ok

async readAllDirectMessagesChatTopicReactions(chat_id=0, topic_id=0)[source]

Removes all unread reactions in the topic in a channel direct messages chat administered by the current user

Parameters:
  • chat_id (int) – Identifier of the chat

  • topic_id (int) – Topic identifier

Return type:

Union[Error, Ok]

Returns:

Ok

async readAllMessageThreadMentions(chat_id=0, message_thread_id=0)[source]

Marks all mentions in a forum topic as read

Parameters:
  • chat_id (int) – Chat identifier

  • message_thread_id (int) – Message thread identifier in which mentions are marked as read

Return type:

Union[Error, Ok]

Returns:

Ok

async readAllMessageThreadReactions(chat_id=0, message_thread_id=0)[source]

Marks all reactions in a forum topic as read

Parameters:
  • chat_id (int) – Chat identifier

  • message_thread_id (int) – Message thread identifier in which reactions are marked as read

Return type:

Union[Error, Ok]

Returns:

Ok

async readBusinessMessage(business_connection_id='', chat_id=0, message_id=0)[source]

Reads a message on behalf of a business account; for bots only

Parameters:
  • business_connection_id (str) – Unique identifier of business connection through which the message was received

  • chat_id (int) – The chat the message belongs to

  • message_id (int) – Identifier of the message

Return type:

Union[Error, Ok]

Returns:

Ok

async readChatList(chat_list=None)[source]

Traverse all chats in a chat list and marks all messages in the chats as read

Parameters:

chat_list ("types.ChatList") – Chat list in which to mark all chats as read

Return type:

Union[Error, Ok]

Returns:

Ok

async readFilePart(file_id=0, offset=0, count=0)[source]

Reads a part of a file from the TDLib file cache and returns read bytes. This method is intended to be used only if the application has no direct access to TDLib’s file system, because it is usually slower than a direct read from the file

Parameters:
  • file_id (int) – Identifier of the file. The file must be located in the TDLib file cache

  • offset (int) – The offset from which to read the file

  • count (int) – Number of bytes to read. An error will be returned if there are not enough bytes available in the file from the specified position. Pass 0 to read all available data from the specified position

Return type:

Union[Error, Data]

Returns:

Data

async readdQuickReplyShortcutMessages(shortcut_name='', message_ids=None)[source]

Readds quick reply messages which failed to add. Can be called only for messages for which messageSendingStateFailed.can_retry is true and after specified in messageSendingStateFailed.retry_after time passed. If a message is readded, the corresponding failed to send message is deleted. Returns the sent messages in the same order as the message identifiers passed in message_ids. If a message can’t be readded, null will be returned instead of the message

Parameters:
  • shortcut_name (str) – Name of the target shortcut

  • message_ids (List[int]) – Identifiers of the quick reply messages to readd. Message identifiers must be in a strictly increasing order

Return type:

Union[Error, QuickReplyMessages]

Returns:

QuickReplyMessages

async recognizeSpeech(chat_id=0, message_id=0)[source]

Recognizes speech in a video note or a voice note message

Parameters:
  • chat_id (int) – Identifier of the chat to which the message belongs

  • message_id (int) – Identifier of the message. Use messageProperties.can_recognize_speech to check whether the message is suitable

Return type:

Union[Error, Ok]

Returns:

Ok

async recoverAuthenticationPassword(recovery_code='', new_password='', new_hint='')[source]

Recovers the 2-step verification password with a password recovery code sent to an email address that was previously set up. Works only when the current authorization state is authorizationStateWaitPassword

Parameters:
  • recovery_code (str) – Recovery code to check

  • new_password (str) – New 2-step verification password of the user; may be empty to remove the password

  • new_hint (str) – New password hint; may be empty

Return type:

Union[Error, Ok]

Returns:

Ok

async recoverPassword(recovery_code='', new_password='', new_hint='')[source]

Recovers the 2-step verification password using a recovery code sent to an email address that was previously set up

Parameters:
  • recovery_code (str) – Recovery code to check

  • new_password (str) – New 2-step verification password of the user; may be empty to remove the password

  • new_hint (str) – New password hint; may be empty

Return type:

Union[Error, PasswordState]

Returns:

PasswordState

async refundStarPayment(user_id=0, telegram_payment_charge_id='')[source]

Refunds a previously done payment in Telegram Stars; for bots only

Parameters:
  • user_id (int) – Identifier of the user that did the payment

  • telegram_payment_charge_id (str) – Telegram payment identifier

Return type:

Union[Error, Ok]

Returns:

Ok

async registerDevice(device_token=None, other_user_ids=None)[source]

Registers the currently used device for receiving push notifications. Returns a globally unique identifier of the push notification subscription

Parameters:
  • device_token ("types.DeviceToken") – Device token

  • other_user_ids (List[int]) – List of user identifiers of other users currently using the application

Return type:

Union[Error, PushReceiverId]

Returns:

PushReceiverId

async registerUser(first_name='', last_name='', disable_notification=False)[source]

Finishes user registration. Works only when the current authorization state is authorizationStateWaitRegistration

Parameters:
  • first_name (str) – The first name of the user; 1-64 characters

  • last_name (str) – The last name of the user; 0-64 characters

  • disable_notification (bool) – Pass true to disable notification about the current user joining Telegram for other users that added them to contact list

Return type:

Union[Error, Ok]

Returns:

Ok

async removeAllFilesFromDownloads(only_active=False, only_completed=False, delete_from_cache=False)[source]

Removes all files from the file download list

Parameters:
  • only_active (bool) – Pass true to remove only active downloads, including paused

  • only_completed (bool) – Pass true to remove only completed downloads

  • delete_from_cache (bool) – Pass true to delete the file from the TDLib file cache

Return type:

Union[Error, Ok]

Returns:

Ok

async removeBusinessConnectedBotFromChat(chat_id=0)[source]

Removes the connected business bot from a specific chat by adding the chat to businessRecipients.excluded_chat_ids

Parameters:

chat_id (int) – Chat identifier

Return type:

Union[Error, Ok]

Returns:

Ok

async removeChatActionBar(chat_id=0)[source]

Removes a chat action bar without any other action

Parameters:

chat_id (int) – Chat identifier

Return type:

Union[Error, Ok]

Returns:

Ok

async removeContacts(user_ids=None)[source]

Removes users from the contact list

Parameters:

user_ids (List[int]) – Identifiers of users to be deleted

Return type:

Union[Error, Ok]

Returns:

Ok

async removeFavoriteSticker(sticker=None)[source]

Removes a sticker from the list of favorite stickers

Parameters:

sticker ("types.InputFile") – Sticker file to delete from the list

Return type:

Union[Error, Ok]

Returns:

Ok

async removeFileFromDownloads(file_id=0, delete_from_cache=False)[source]

Removes a file from the file download list

Parameters:
  • file_id (int) – Identifier of the downloaded file

  • delete_from_cache (bool) – Pass true to delete the file from the TDLib file cache

Return type:

Union[Error, Ok]

Returns:

Ok

async removeGiftCollectionGifts(owner_id=None, collection_id=0, received_gift_ids=None)[source]

Removes gifts from a collection. If the collection is owned by a channel chat, then requires can_post_messages administrator right in the channel chat. Returns the changed collection

Parameters:
  • owner_id ("types.MessageSender") – Identifier of the user or the channel chat that owns the collection

  • collection_id (int) – Identifier of the gift collection

  • received_gift_ids (List[str]) – Identifier of the gifts to remove from the collection

Return type:

Union[Error, GiftCollection]

Returns:

GiftCollection

async removeInstalledBackground(background_id=0)[source]

Removes background from the list of installed backgrounds

Parameters:

background_id (int) – The background identifier

Return type:

Union[Error, Ok]

Returns:

Ok

async removeMessageReaction(chat_id=0, message_id=0, reaction_type=None)[source]

Removes a reaction from a message. A chosen reaction can always be removed

Parameters:
  • chat_id (int) – Identifier of the chat to which the message belongs

  • message_id (int) – Identifier of the message

  • reaction_type ("types.ReactionType") – Type of the reaction to remove. The paid reaction can’t be removed

Return type:

Union[Error, Ok]

Returns:

Ok

async removeMessageSenderBotVerification(bot_user_id=0, verified_id=None)[source]

Removes the verification status of a user or a chat by an owned bot

Parameters:
  • bot_user_id (int) – Identifier of the owned bot, which verified the user or the chat

  • verified_id ("types.MessageSender") – Identifier of the user or the supergroup or channel chat, which verification is removed

Return type:

Union[Error, Ok]

Returns:

Ok

async removeNotification(notification_group_id=0, notification_id=0)[source]

Removes an active notification from notification list. Needs to be called only if the notification is removed by the current user

Parameters:
  • notification_group_id (int) – Identifier of notification group to which the notification belongs

  • notification_id (int) – Identifier of removed notification

Return type:

Union[Error, Ok]

Returns:

Ok

async removeNotificationGroup(notification_group_id=0, max_notification_id=0)[source]

Removes a group of active notifications. Needs to be called only if the notification group is removed by the current user

Parameters:
  • notification_group_id (int) – Notification group identifier

  • max_notification_id (int) – The maximum identifier of removed notifications

Return type:

Union[Error, Ok]

Returns:

Ok

async removePendingPaidMessageReactions(chat_id=0, message_id=0)[source]

Removes all pending paid reactions on a message

Parameters:
  • chat_id (int) – Identifier of the chat to which the message belongs

  • message_id (int) – Identifier of the message

Return type:

Union[Error, Ok]

Returns:

Ok

async removeProfileAudio(file_id=0)[source]

Removes an audio file from the profile audio files of the current user

Parameters:

file_id (int) – Identifier of the audio file to be removed

Return type:

Union[Error, Ok]

Returns:

Ok

async removeProxy(proxy_id=0)[source]

Removes a proxy server. Can be called before authorization

Parameters:

proxy_id (int) – Proxy identifier

Return type:

Union[Error, Ok]

Returns:

Ok

async removeRecentHashtag(hashtag='')[source]

Removes a hashtag from the list of recently used hashtags

Parameters:

hashtag (str) – Hashtag to delete

Return type:

Union[Error, Ok]

Returns:

Ok

async removeRecentSticker(is_attached=False, sticker=None)[source]

Removes a sticker from the list of recently used stickers

Parameters:
  • is_attached (bool) – Pass true to remove the sticker from the list of stickers recently attached to photo or video files; pass false to remove the sticker from the list of recently sent stickers

  • sticker ("types.InputFile") – Sticker file to delete

Return type:

Union[Error, Ok]

Returns:

Ok

async removeRecentlyFoundChat(chat_id=0)[source]

Removes a chat from the list of recently found chats

Parameters:

chat_id (int) – Identifier of the chat to be removed

Return type:

Union[Error, Ok]

Returns:

Ok

async removeSavedAnimation(animation=None)[source]

Removes an animation from the list of saved animations

Parameters:

animation ("types.InputFile") – Animation file to be removed

Return type:

Union[Error, Ok]

Returns:

Ok

async removeSavedNotificationSound(notification_sound_id=0)[source]

Removes a notification sound from the list of saved notification sounds

Parameters:

notification_sound_id (int) – Identifier of the notification sound

Return type:

Union[Error, Ok]

Returns:

Ok

async removeSearchedForTag(tag='')[source]

Removes a hashtag or a cashtag from the list of recently searched for hashtags or cashtags

Parameters:

tag (str) – Hashtag or cashtag to delete

Return type:

Union[Error, Ok]

Returns:

Ok

async removeStickerFromSet(sticker=None)[source]

Removes a sticker from the set to which it belongs. The sticker set must be owned by the current user

Parameters:

sticker ("types.InputFile") – Sticker to remove from the set

Return type:

Union[Error, Ok]

Returns:

Ok

async removeStoryAlbumStories(chat_id=0, story_album_id=0, story_ids=None)[source]

Removes stories from an album. If the album is owned by a supergroup or a channel chat, then requires can_edit_stories administrator right in the chat. Returns the changed album

Parameters:
  • chat_id (int) – Identifier of the chat that owns the stories

  • story_album_id (int) – Identifier of the story album

  • story_ids (List[int]) – Identifier of the stories to remove from the album

Return type:

Union[Error, StoryAlbum]

Returns:

StoryAlbum

async removeTopChat(category=None, chat_id=0)[source]

Removes a chat from the list of frequently used chats. Supported only if the chat info database is enabled

Parameters:
  • category ("types.TopChatCategory") – Category of frequently used chats

  • chat_id (int) – Chat identifier

Return type:

Union[Error, Ok]

Returns:

Ok

async reorderActiveUsernames(usernames=None)[source]

Changes order of active usernames of the current user

Parameters:

usernames (List[str]) – The new order of active usernames. All currently active usernames must be specified

Return type:

Union[Error, Ok]

Returns:

Ok

async reorderBotActiveUsernames(bot_user_id=0, usernames=None)[source]

Changes order of active usernames of a bot. Can be called only if userTypeBot.can_be_edited == true

Parameters:
  • bot_user_id (int) – Identifier of the target bot

  • usernames (List[str]) – The new order of active usernames. All currently active usernames must be specified

Return type:

Union[Error, Ok]

Returns:

Ok

async reorderBotMediaPreviews(bot_user_id=0, language_code='', file_ids=None)[source]

Changes order of media previews in the list of media previews of a bot

Parameters:
  • bot_user_id (int) – Identifier of the target bot. The bot must be owned and must have the main Web App

  • language_code (str) – Language code of the media previews to reorder

  • file_ids (List[int]) – File identifiers of the media in the new order

Return type:

Union[Error, Ok]

Returns:

Ok

async reorderChatFolders(chat_folder_ids=None, main_chat_list_position=0)[source]

Changes the order of chat folders

Parameters:
  • chat_folder_ids (List[int]) – Identifiers of chat folders in the new correct order

  • main_chat_list_position (int) – Position of the main chat list among chat folders, 0-based. Can be non-zero only for Premium users

Return type:

Union[Error, Ok]

Returns:

Ok

async reorderGiftCollectionGifts(owner_id=None, collection_id=0, received_gift_ids=None)[source]

Changes order of gifts in a collection. If the collection is owned by a channel chat, then requires can_post_messages administrator right in the channel chat. Returns the changed collection

Parameters:
  • owner_id ("types.MessageSender") – Identifier of the user or the channel chat that owns the collection

  • collection_id (int) – Identifier of the gift collection

  • received_gift_ids (List[str]) – Identifier of the gifts to move to the beginning of the collection. All other gifts are placed in the current order after the specified gifts

Return type:

Union[Error, GiftCollection]

Returns:

GiftCollection

async reorderGiftCollections(owner_id=None, collection_ids=None)[source]

Changes order of gift collections. If the collections are owned by a channel chat, then requires can_post_messages administrator right in the channel chat

Parameters:
  • owner_id ("types.MessageSender") – Identifier of the user or the channel chat that owns the collection

  • collection_ids (List[int]) – New order of gift collections

Return type:

Union[Error, Ok]

Returns:

Ok

async reorderInstalledStickerSets(sticker_type=None, sticker_set_ids=None)[source]

Changes the order of installed sticker sets

Parameters:
  • sticker_type ("types.StickerType") – Type of the sticker sets to reorder

  • sticker_set_ids (List[int]) – Identifiers of installed sticker sets in the new correct order

Return type:

Union[Error, Ok]

Returns:

Ok

async reorderQuickReplyShortcuts(shortcut_ids=None)[source]

Changes the order of quick reply shortcuts

Parameters:

shortcut_ids (List[int]) – The new order of quick reply shortcuts

Return type:

Union[Error, Ok]

Returns:

Ok

async reorderStoryAlbumStories(chat_id=0, story_album_id=0, story_ids=None)[source]

Changes order of stories in an album. If the album is owned by a supergroup or a channel chat, then requires can_edit_stories administrator right in the chat. Returns the changed album

Parameters:
  • chat_id (int) – Identifier of the chat that owns the stories

  • story_album_id (int) – Identifier of the story album

  • story_ids (List[int]) – Identifier of the stories to move to the beginning of the album. All other stories are placed in the current order after the specified stories

Return type:

Union[Error, StoryAlbum]

Returns:

StoryAlbum

async reorderStoryAlbums(chat_id=0, story_album_ids=None)[source]

Changes order of story albums. If the albums are owned by a supergroup or a channel chat, then requires can_edit_stories administrator right in the chat

Parameters:
  • chat_id (int) – Identifier of the chat that owns the stories

  • story_album_ids (List[int]) – New order of story albums

Return type:

Union[Error, Ok]

Returns:

Ok

async reorderSupergroupActiveUsernames(supergroup_id=0, usernames=None)[source]

Changes order of active usernames of a supergroup or channel, requires owner privileges in the supergroup or channel

Parameters:
  • supergroup_id (int) – Identifier of the supergroup or channel

  • usernames (List[str]) – The new order of active usernames. All currently active usernames must be specified

Return type:

Union[Error, Ok]

Returns:

Ok

Replaces current primary invite link for a chat with a new primary invite link. Available for basic groups, supergroups, and channels. Requires administrator privileges and can_invite_users right

Parameters:

chat_id (int) – Chat identifier

Return type:

Union[Error, ChatInviteLink]

Returns:

ChatInviteLink

async replaceStickerInSet(user_id=0, name='', old_sticker=None, new_sticker=None)[source]

Replaces existing sticker in a set. The function is equivalent to removeStickerFromSet, then addStickerToSet, then setStickerPositionInSet

Parameters:
  • user_id (int) – Sticker set owner; ignored for regular users

  • name (str) – Sticker set name. The sticker set must be owned by the current user

  • old_sticker ("types.InputFile") – Sticker to remove from the set

  • new_sticker ("types.InputSticker") – Sticker to add to the set

Return type:

Union[Error, Ok]

Returns:

Ok

async replaceVideoChatRtmpUrl(chat_id=0)[source]

Replaces the current RTMP URL for streaming to the video chat of a chat; requires owner privileges in the chat

Parameters:

chat_id (int) – Chat identifier

Return type:

Union[Error, RtmpUrl]

Returns:

RtmpUrl

async reportAuthenticationCodeMissing(mobile_network_code='')[source]

Reports that authentication code wasn’t delivered via SMS; for official mobile applications only. Works only when the current authorization state is authorizationStateWaitCode

Parameters:

mobile_network_code (str) – Current mobile network code

Return type:

Union[Error, Ok]

Returns:

Ok

async reportChat(chat_id=0, option_id=b'', message_ids=None, text='')[source]

Reports a chat to the Telegram moderators. A chat can be reported only from the chat action bar, or if chat.can_be_reported

Parameters:
  • chat_id (int) – Chat identifier

  • option_id (bytes) – Option identifier chosen by the user; leave empty for the initial request

  • message_ids (List[int]) – Identifiers of reported messages. Use messageProperties.can_report_chat to check whether the message can be reported

  • text (str) – Additional report details if asked by the server; 0-1024 characters; leave empty for the initial request

Return type:

Union[Error, ReportChatResult]

Returns:

ReportChatResult

async reportChatPhoto(chat_id=0, file_id=0, reason=None, text='')[source]

Reports a chat photo to the Telegram moderators. A chat photo can be reported only if chat.can_be_reported

Parameters:
  • chat_id (int) – Chat identifier

  • file_id (int) – Identifier of the photo to report. Only full photos from chatPhoto can be reported

  • reason ("types.ReportReason") – The reason for reporting the chat photo

  • text (str) – Additional report details; 0-1024 characters

Return type:

Union[Error, Ok]

Returns:

Ok

async reportChatSponsoredMessage(chat_id=0, message_id=0, option_id=b'')[source]

Reports a sponsored message to Telegram moderators

Parameters:
  • chat_id (int) – Chat identifier of the sponsored message

  • message_id (int) – Identifier of the sponsored message

  • option_id (bytes) – Option identifier chosen by the user; leave empty for the initial request

Return type:

Union[Error, ReportSponsoredResult]

Returns:

ReportSponsoredResult

async reportMessageReactions(chat_id=0, message_id=0, sender_id=None)[source]

Reports reactions set on a message to the Telegram moderators. Reactions on a message can be reported only if messageProperties.can_report_reactions

Parameters:
  • chat_id (int) – Chat identifier

  • message_id (int) – Message identifier

  • sender_id ("types.MessageSender") – Identifier of the sender, which added the reaction

Return type:

Union[Error, Ok]

Returns:

Ok

async reportPhoneNumberCodeMissing(mobile_network_code='')[source]

Reports that authentication code wasn’t delivered via SMS to the specified phone number; for official mobile applications only

Parameters:

mobile_network_code (str) – Current mobile network code

Return type:

Union[Error, Ok]

Returns:

Ok

async reportSponsoredChat(sponsored_chat_unique_id=0, option_id=b'')[source]

Reports a sponsored chat to Telegram moderators

Parameters:
  • sponsored_chat_unique_id (int) – Unique identifier of the sponsored chat

  • option_id (bytes) – Option identifier chosen by the user; leave empty for the initial request

Return type:

Union[Error, ReportSponsoredResult]

Returns:

ReportSponsoredResult

async reportStory(story_poster_chat_id=0, story_id=0, option_id=b'', text='')[source]

Reports a story to the Telegram moderators

Parameters:
  • story_poster_chat_id (int) – The identifier of the poster of the story to report

  • story_id (int) – The identifier of the story to report

  • option_id (bytes) – Option identifier chosen by the user; leave empty for the initial request

  • text (str) – Additional report details; 0-1024 characters; leave empty for the initial request

Return type:

Union[Error, ReportStoryResult]

Returns:

ReportStoryResult

async reportSupergroupAntiSpamFalsePositive(supergroup_id=0, message_id=0)[source]

Reports a false deletion of a message by aggressive anti-spam checks; requires administrator rights in the supergroup. Can be called only for messages from chatEventMessageDeleted with can_report_anti_spam_false_positive == true

Parameters:
  • supergroup_id (int) – Supergroup identifier

  • message_id (int) – Identifier of the erroneously deleted message from chatEventMessageDeleted

Return type:

Union[Error, Ok]

Returns:

Ok

async reportSupergroupSpam(supergroup_id=0, message_ids=None)[source]

Reports messages in a supergroup as spam; requires administrator rights in the supergroup

Parameters:
  • supergroup_id (int) – Supergroup identifier

  • message_ids (List[int]) – Identifiers of messages to report. Use messageProperties.can_report_supergroup_spam to check whether the message can be reported

Return type:

Union[Error, Ok]

Returns:

Ok

async reportVideoMessageAdvertisement(advertisement_unique_id=0, option_id=b'')[source]

Reports a video message advertisement to Telegram moderators

Parameters:
  • advertisement_unique_id (int) – Unique identifier of the advertisement

  • option_id (bytes) – Option identifier chosen by the user; leave empty for the initial request

Return type:

Union[Error, ReportSponsoredResult]

Returns:

ReportSponsoredResult

async requestAuthenticationPasswordRecovery()[source]

Requests to send a 2-step verification password recovery code to an email address that was previously set up. Works only when the current authorization state is authorizationStateWaitPassword

Return type:

Union[Error, Ok]

Returns:

Ok

async requestPasswordRecovery()[source]

Requests to send a 2-step verification password recovery code to an email address that was previously set up

Return type:

Union[Error, EmailAddressAuthenticationCodeInfo]

Returns:

EmailAddressAuthenticationCodeInfo

async requestQrCodeAuthentication(other_user_ids=None)[source]

Requests QR code authentication by scanning a QR code on another logged in device. Works only when the current authorization state is authorizationStateWaitPhoneNumber, or if there is no pending authentication query and the current authorization state is authorizationStateWaitPremiumPurchase, authorizationStateWaitEmailAddress, authorizationStateWaitEmailCode, authorizationStateWaitCode, authorizationStateWaitRegistration, or authorizationStateWaitPassword

Parameters:

other_user_ids (List[int]) – List of user identifiers of other users currently using the application

Return type:

Union[Error, Ok]

Returns:

Ok

async resendAuthenticationCode(reason=None)[source]

Resends an authentication code to the user. Works only when the current authorization state is authorizationStateWaitCode, the next_code_type of the result is not null and the server-specified timeout has passed, or when the current authorization state is authorizationStateWaitEmailCode

Parameters:

reason ("types.ResendCodeReason") – Reason of code resending; pass null if unknown

Return type:

Union[Error, Ok]

Returns:

Ok

async resendEmailAddressVerificationCode()[source]

Resends the code to verify an email address to be added to a user’s Telegram Passport

Return type:

Union[Error, EmailAddressAuthenticationCodeInfo]

Returns:

EmailAddressAuthenticationCodeInfo

async resendLoginEmailAddressCode()[source]

Resends the login email address verification code

Return type:

Union[Error, EmailAddressAuthenticationCodeInfo]

Returns:

EmailAddressAuthenticationCodeInfo

async resendMessages(chat_id=0, message_ids=None, quote=None, paid_message_star_count=0)[source]

Resends messages which failed to send. Can be called only for messages for which messageSendingStateFailed.can_retry is true and after specified in messageSendingStateFailed.retry_after time passed. If a message is re-sent, the corresponding failed to send message is deleted. Returns the sent messages in the same order as the message identifiers passed in message_ids. If a message can’t be re-sent, null will be returned instead of the message

Parameters:
  • chat_id (int) – Identifier of the chat to send messages

  • message_ids (List[int]) – Identifiers of the messages to resend. Message identifiers must be in a strictly increasing order

  • quote ("types.InputTextQuote") – New manually chosen quote from the message to be replied; pass null if none. Ignored if more than one message is re-sent, or if messageSendingStateFailed.need_another_reply_quote == false

  • paid_message_star_count (int) – The number of Telegram Stars the user agreed to pay to send the messages. Ignored if messageSendingStateFailed.required_paid_message_star_count == 0

Return type:

Union[Error, Messages]

Returns:

Messages

async resendPhoneNumberCode(reason=None)[source]

Resends the authentication code sent to a phone number. Works only if the previously received authenticationCodeInfo next_code_type was not null and the server-specified timeout has passed

Parameters:

reason ("types.ResendCodeReason") – Reason of code resending; pass null if unknown

Return type:

Union[Error, AuthenticationCodeInfo]

Returns:

AuthenticationCodeInfo

async resendRecoveryEmailAddressCode()[source]

Resends the 2-step verification recovery email address verification code

Return type:

Union[Error, PasswordState]

Returns:

PasswordState

async resetAllNotificationSettings()[source]

Resets all chat and scope notification settings to their default values. By default, all chats are unmuted and message previews are shown

Return type:

Union[Error, Ok]

Returns:

Ok

async resetAuthenticationEmailAddress()[source]

Resets the login email address. May return an error with a message "TASK_ALREADY_EXISTS" if reset is still pending. Works only when the current authorization state is authorizationStateWaitEmailCode and authorization_state.can_reset_email_address == true

Return type:

Union[Error, Ok]

Returns:

Ok

async resetInstalledBackgrounds()[source]

Resets list of installed backgrounds to its default value

Return type:

Union[Error, Ok]

Returns:

Ok

async resetNetworkStatistics()[source]

Resets all network data usage statistics to zero. Can be called before authorization

Return type:

Union[Error, Ok]

Returns:

Ok

async resetPassword()[source]

Removes 2-step verification password without previous password and access to recovery email address. The password can’t be reset immediately and the request needs to be repeated after the specified time

Return type:

Union[Error, ResetPasswordResult]

Returns:

ResetPasswordResult

async reuseStarSubscription(subscription_id='')[source]

Reuses an active Telegram Star subscription to a channel chat and joins the chat again

Parameters:

subscription_id (str) – Identifier of the subscription

Return type:

Union[Error, Ok]

Returns:

Ok

Revokes invite link for a chat. Available for basic groups, supergroups, and channels. Requires administrator privileges and can_invite_users right in the chat for own links and owner privileges for other links. If a primary link is revoked, then additionally to the revoked link returns new primary link

Parameters:
  • chat_id (int) – Chat identifier

  • invite_link (str) – Invite link to be revoked

Return type:

Union[Error, ChatInviteLinks]

Returns:

ChatInviteLinks

Revokes invite link for a group call. Requires groupCall.can_be_managed right for video chats or groupCall.is_owned otherwise

Parameters:

group_call_id (int) – Group call identifier

Return type:

Union[Error, Ok]

Returns:

Ok

async saveApplicationLogEvent(type='', chat_id=0, data=None)[source]

Saves application log event on the server. Can be called before authorization

Parameters:
  • type (str) – Event type

  • chat_id (int) – Optional chat identifier, associated with the event

  • data ("types.JsonValue") – The log event data

Return type:

Union[Error, Ok]

Returns:

Ok

async savePreparedInlineMessage(user_id=0, result=None, chat_types=None)[source]

Saves an inline message to be sent by the given user; for bots only

Parameters:
  • user_id (int) – Identifier of the user

  • result ("types.InputInlineQueryResult") – The description of the message

  • chat_types ("types.TargetChatTypes") – Types of the chats to which the message can be sent

Return type:

Union[Error, PreparedInlineMessageId]

Returns:

PreparedInlineMessageId

async searchAffiliatePrograms(affiliate=None, sort_order=None, offset='', limit=0)[source]

Searches affiliate programs that can be connected to the given affiliate

Parameters:
  • affiliate ("types.AffiliateType") – The affiliate for which affiliate programs are searched for

  • sort_order ("types.AffiliateProgramSortOrder") – Sort order for the results

  • offset (str) – Offset of the first affiliate program to return as received from the previous request; use empty string to get the first chunk of results

  • limit (int) – The maximum number of affiliate programs to return

Return type:

Union[Error, FoundAffiliatePrograms]

Returns:

FoundAffiliatePrograms

async searchBackground(name='')[source]

Searches for a background by its name

Parameters:

name (str) – The name of the background

Return type:

Union[Error, Background]

Returns:

Background

async searchCallMessages(offset='', limit=0, only_missed=False)[source]

Searches for call and group call messages. Returns the results in reverse chronological order (i.e., in order of decreasing message_id). For optimal performance, the number of returned messages is chosen by TDLib

Parameters:
  • offset (str) – Offset of the first entry to return as received from the previous request; use empty string to get the first chunk of results

  • limit (int) – The maximum number of messages to be returned; up to 100. For optimal performance, the number of returned messages is chosen by TDLib and can be smaller than the specified limit

  • only_missed (bool) – Pass true to search only for messages with missed/declined calls

Return type:

Union[Error, FoundMessages]

Returns:

FoundMessages

async searchChatAffiliateProgram(username='', referrer='')[source]

Searches a chat with an affiliate program. Returns the chat if found and the program is active

Parameters:
  • username (str) – Username of the chat

  • referrer (str) – The referrer from an internalLinkTypeChatAffiliateProgram link

Return type:

Union[Error, Chat]

Returns:

Chat

async searchChatMembers(chat_id=0, query='', limit=0, filter=None)[source]

Searches for a specified query in the first name, last name and usernames of the members of a specified chat. Requires administrator rights if the chat is a channel

Parameters:
  • chat_id (int) – Chat identifier

  • query (str) – Query to search for

  • limit (int) – The maximum number of users to be returned; up to 200

  • filter ("types.ChatMembersFilter") – The type of users to search for; pass null to search among all chat members

Return type:

Union[Error, ChatMembers]

Returns:

ChatMembers

async searchChatMessages(chat_id=0, topic_id=None, query='', sender_id=None, from_message_id=0, offset=0, limit=0, filter=None)[source]

Searches for messages with given words in the chat. Returns the results in reverse chronological order, i.e. in order of decreasing message_id. Cannot be used in secret chats with a non-empty query (searchSecretMessages must be used instead), or without an enabled message database. For optimal performance, the number of returned messages is chosen by TDLib and can be smaller than the specified limit. A combination of query, sender_id, filter and topic_id search criteria is expected to be supported, only if it is required for Telegram official application implementation

Parameters:
  • chat_id (int) – Identifier of the chat in which to search messages

  • topic_id ("types.MessageTopic") – Pass topic identifier to search messages only in specific topic; pass null to search for messages in all topics

  • query (str) – Query to search for

  • sender_id ("types.MessageSender") – Identifier of the sender of messages to search for; pass null to search for messages from any sender. Not supported in secret chats

  • from_message_id (int) – Identifier of the message starting from which history must be fetched; use 0 to get results from the last message

  • offset (int) – Specify 0 to get results from exactly the message from_message_id or a negative number to get the specified message and some newer messages

  • limit (int) – The maximum number of messages to be returned; must be positive and can’t be greater than 100. If the offset is negative, then the limit must be greater than -offset. For optimal performance, the number of returned messages is chosen by TDLib and can be smaller than the specified limit

  • filter ("types.SearchMessagesFilter") – Additional filter for messages to search; pass null to search for all messages

Return type:

Union[Error, FoundChatMessages]

Returns:

FoundChatMessages

async searchChatRecentLocationMessages(chat_id=0, limit=0)[source]

Returns information about the recent locations of chat members that were sent to the chat. Returns up to 1 location message per user

Parameters:
  • chat_id (int) – Chat identifier

  • limit (int) – The maximum number of messages to be returned

Return type:

Union[Error, Messages]

Returns:

Messages

async searchChats(query='', limit=0)[source]

Searches for the specified query in the title and username of already known chats. This is an offline method. Returns chats in the order seen in the main chat list

Parameters:
  • query (str) – Query to search for. If the query is empty, returns up to 50 recently found chats

  • limit (int) – The maximum number of chats to be returned

Return type:

Union[Error, Chats]

Returns:

Chats

async searchChatsOnServer(query='', limit=0)[source]

Searches for the specified query in the title and username of already known chats via request to the server. Returns chats in the order seen in the main chat list

Parameters:
  • query (str) – Query to search for

  • limit (int) – The maximum number of chats to be returned

Return type:

Union[Error, Chats]

Returns:

Chats

async searchContacts(query='', limit=0)[source]

Searches for the specified query in the first names, last names and usernames of the known user contacts

Parameters:
  • query (str) – Query to search for; may be empty to return all contacts

  • limit (int) – The maximum number of users to be returned

Return type:

Union[Error, Users]

Returns:

Users

async searchEmojis(text='', input_language_codes=None)[source]

Searches for emojis by keywords. Supported only if the file database is enabled. Order of results is unspecified

Parameters:
  • text (str) – Text to search for

  • input_language_codes (List[str]) – List of possible IETF language tags of the user’s input language; may be empty if unknown

Return type:

Union[Error, EmojiKeywords]

Returns:

EmojiKeywords

async searchFileDownloads(query='', only_active=False, only_completed=False, offset='', limit=0)[source]

Searches for files in the file download list or recently downloaded files from the list

Parameters:
  • query (str) – Query to search for; may be empty to return all downloaded files

  • only_active (bool) – Pass true to search only for active downloads, including paused

  • only_completed (bool) – Pass true to search only for completed downloads

  • offset (str) – Offset of the first entry to return as received from the previous request; use empty string to get the first chunk of results

  • limit (int) – The maximum number of files to be returned

Return type:

Union[Error, FoundFileDownloads]

Returns:

FoundFileDownloads

async searchGiftsForResale(gift_id=0, order=None, attributes=None, offset='', limit=0)[source]

Returns upgraded gifts that can be bought from other owners using sendResoldGift

Parameters:
  • gift_id (int) – Identifier of the regular gift that was upgraded to a unique gift

  • order ("types.GiftForResaleOrder") – Order in which the results will be sorted

  • attributes (List["types.UpgradedGiftAttributeId"]) – Attributes used to filter received gifts. If multiple attributes of the same type are specified, then all of them are allowed. If none attributes of specific type are specified, then all values for this attribute type are allowed

  • offset (str) – Offset of the first entry to return as received from the previous request with the same order and attributes; use empty string to get the first chunk of results

  • limit (int) – The maximum number of gifts to return

Return type:

Union[Error, GiftsForResale]

Returns:

GiftsForResale

async searchHashtags(prefix='', limit=0)[source]

Searches for recently used hashtags by their prefix

Parameters:
  • prefix (str) – Hashtag prefix to search for

  • limit (int) – The maximum number of hashtags to be returned

Return type:

Union[Error, Hashtags]

Returns:

Hashtags

async searchInstalledStickerSets(sticker_type=None, query='', limit=0)[source]

Searches for installed sticker sets by looking for specified query in their title and name

Parameters:
  • sticker_type ("types.StickerType") – Type of the sticker sets to search for

  • query (str) – Query to search for

  • limit (int) – The maximum number of sticker sets to return

Return type:

Union[Error, StickerSets]

Returns:

StickerSets

async searchMessages(chat_list=None, query='', offset='', limit=0, filter=None, chat_type_filter=None, min_date=0, max_date=0)[source]

Searches for messages in all chats except secret chats. Returns the results in reverse chronological order (i.e., in order of decreasing (date, chat_id, message_id)). For optimal performance, the number of returned messages is chosen by TDLib and can be smaller than the specified limit

Parameters:
  • chat_list ("types.ChatList") – Chat list in which to search messages; pass null to search in all chats regardless of their chat list. Only Main and Archive chat lists are supported

  • query (str) – Query to search for

  • offset (str) – Offset of the first entry to return as received from the previous request; use empty string to get the first chunk of results

  • limit (int) – The maximum number of messages to be returned; up to 100. For optimal performance, the number of returned messages is chosen by TDLib and can be smaller than the specified limit

  • filter ("types.SearchMessagesFilter") – Additional filter for messages to search; pass null to search for all messages. Filters searchMessagesFilterMention, searchMessagesFilterUnreadMention, searchMessagesFilterUnreadReaction, searchMessagesFilterFailedToSend, and searchMessagesFilterPinned are unsupported in this function

  • chat_type_filter ("types.SearchMessagesChatTypeFilter") – Additional filter for type of the chat of the searched messages; pass null to search for messages in all chats

  • min_date (int) – If not 0, the minimum date of the messages to return

  • max_date (int) – If not 0, the maximum date of the messages to return

Return type:

Union[Error, FoundMessages]

Returns:

FoundMessages

async searchOutgoingDocumentMessages(query='', limit=0)[source]

Searches for outgoing messages with content of the type messageDocument in all chats except secret chats. Returns the results in reverse chronological order

Parameters:
  • query (str) – Query to search for in document file name and message caption

  • limit (int) – The maximum number of messages to be returned; up to 100

Return type:

Union[Error, FoundMessages]

Returns:

FoundMessages

async searchPublicChat(username='')[source]

Searches a public chat by its username. Currently, only private chats, supergroups and channels can be public. Returns the chat if found; otherwise, an error is returned

Parameters:

username (str) – Username to be resolved

Return type:

Union[Error, Chat]

Returns:

Chat

async searchPublicChats(query='')[source]

Searches public chats by looking for specified query in their username and title. Currently, only private chats, supergroups and channels can be public. Returns a meaningful number of results. Excludes private chats with contacts and chats from the chat list from the results

Parameters:

query (str) – Query to search for

Return type:

Union[Error, Chats]

Returns:

Chats

async searchPublicMessagesByTag(tag='', offset='', limit=0)[source]

Searches for public channel posts containing the given hashtag or cashtag. For optimal performance, the number of returned messages is chosen by TDLib and can be smaller than the specified limit

Parameters:
  • tag (str) – Hashtag or cashtag to search for

  • offset (str) – Offset of the first entry to return as received from the previous request; use empty string to get the first chunk of results

  • limit (int) – The maximum number of messages to be returned; up to 100. For optimal performance, the number of returned messages is chosen by TDLib and can be smaller than the specified limit

Return type:

Union[Error, FoundMessages]

Returns:

FoundMessages

async searchPublicPosts(query='', offset='', limit=0, star_count=0)[source]

Searches for public channel posts using the given query. For optimal performance, the number of returned messages is chosen by TDLib and can be smaller than the specified limit

Parameters:
  • query (str) – Query to search for

  • offset (str) – Offset of the first entry to return as received from the previous request; use empty string to get the first chunk of results

  • limit (int) – The maximum number of messages to be returned; up to 100. For optimal performance, the number of returned messages is chosen by TDLib and can be smaller than the specified limit

  • star_count (int) – The amount of Telegram Stars the user agreed to pay for the search; pass 0 for free searches

Return type:

Union[Error, FoundPublicPosts]

Returns:

FoundPublicPosts

async searchPublicStoriesByLocation(address=None, offset='', limit=0)[source]

Searches for public stories by the given address location. For optimal performance, the number of returned stories is chosen by TDLib and can be smaller than the specified limit

Parameters:
  • address ("types.LocationAddress") – Address of the location

  • offset (str) – Offset of the first entry to return as received from the previous request; use empty string to get the first chunk of results

  • limit (int) – The maximum number of stories to be returned; up to 100. For optimal performance, the number of returned stories is chosen by TDLib and can be smaller than the specified limit

Return type:

Union[Error, FoundStories]

Returns:

FoundStories

async searchPublicStoriesByTag(story_poster_chat_id=0, tag='', offset='', limit=0)[source]

Searches for public stories containing the given hashtag or cashtag. For optimal performance, the number of returned stories is chosen by TDLib and can be smaller than the specified limit

Parameters:
  • story_poster_chat_id (int) – Identifier of the chat that posted the stories to search for; pass 0 to search stories in all chats

  • tag (str) – Hashtag or cashtag to search for

  • offset (str) – Offset of the first entry to return as received from the previous request; use empty string to get the first chunk of results

  • limit (int) – The maximum number of stories to be returned; up to 100. For optimal performance, the number of returned stories is chosen by TDLib and can be smaller than the specified limit

Return type:

Union[Error, FoundStories]

Returns:

FoundStories

async searchPublicStoriesByVenue(venue_provider='', venue_id='', offset='', limit=0)[source]

Searches for public stories from the given venue. For optimal performance, the number of returned stories is chosen by TDLib and can be smaller than the specified limit

Parameters:
  • venue_provider (str) – Provider of the venue

  • venue_id (str) – Identifier of the venue in the provider database

  • offset (str) – Offset of the first entry to return as received from the previous request; use empty string to get the first chunk of results

  • limit (int) – The maximum number of stories to be returned; up to 100. For optimal performance, the number of returned stories is chosen by TDLib and can be smaller than the specified limit

Return type:

Union[Error, FoundStories]

Returns:

FoundStories

async searchQuote(text=None, quote=None, quote_position=0)[source]

Searches for a given quote in a text. Returns found quote start position in UTF-16 code units. Returns a 404 error if the quote is not found. Can be called synchronously

Parameters:
  • text ("types.FormattedText") – Text in which to search for the quote

  • quote ("types.FormattedText") – Quote to search for

  • quote_position (int) – Approximate quote position in UTF-16 code units

Return type:

Union[Error, FoundPosition]

Returns:

FoundPosition

async searchRecentlyFoundChats(query='', limit=0)[source]

Searches for the specified query in the title and username of up to 50 recently found chats. This is an offline method

Parameters:
  • query (str) – Query to search for

  • limit (int) – The maximum number of chats to be returned

Return type:

Union[Error, Chats]

Returns:

Chats

async searchSavedMessages(saved_messages_topic_id=0, tag=None, query='', from_message_id=0, offset=0, limit=0)[source]

Searches for messages tagged by the given reaction and with the given words in the Saved Messages chat; for Telegram Premium users only. Returns the results in reverse chronological order, i.e. in order of decreasing message_id. For optimal performance, the number of returned messages is chosen by TDLib and can be smaller than the specified limit

Parameters:
  • saved_messages_topic_id (int) – If not 0, only messages in the specified Saved Messages topic will be considered; pass 0 to consider all messages

  • tag ("types.ReactionType") – Tag to search for; pass null to return all suitable messages

  • query (str) – Query to search for

  • from_message_id (int) – Identifier of the message starting from which messages must be fetched; use 0 to get results from the last message

  • offset (int) – Specify 0 to get results from exactly the message from_message_id or a negative number to get the specified message and some newer messages

  • limit (int) – The maximum number of messages to be returned; must be positive and can’t be greater than 100. If the offset is negative, then the limit must be greater than -offset. For optimal performance, the number of returned messages is chosen by TDLib and can be smaller than the specified limit

Return type:

Union[Error, FoundChatMessages]

Returns:

FoundChatMessages

async searchSecretMessages(chat_id=0, query='', offset='', limit=0, filter=None)[source]

Searches for messages in secret chats. Returns the results in reverse chronological order. For optimal performance, the number of returned messages is chosen by TDLib

Parameters:
  • chat_id (int) – Identifier of the chat in which to search. Specify 0 to search in all secret chats

  • query (str) – Query to search for. If empty, searchChatMessages must be used instead

  • offset (str) – Offset of the first entry to return as received from the previous request; use empty string to get the first chunk of results

  • limit (int) – The maximum number of messages to be returned; up to 100. For optimal performance, the number of returned messages is chosen by TDLib and can be smaller than the specified limit

  • filter ("types.SearchMessagesFilter") – Additional filter for messages to search; pass null to search for all messages

Return type:

Union[Error, FoundMessages]

Returns:

FoundMessages

async searchStickerSet(name='', ignore_cache=False)[source]

Searches for a sticker set by its name

Parameters:
  • name (str) – Name of the sticker set

  • ignore_cache (bool) – Pass true to ignore local cache of sticker sets and always send a network request

Return type:

Union[Error, StickerSet]

Returns:

StickerSet

async searchStickerSets(sticker_type=None, query='')[source]

Searches for sticker sets by looking for specified query in their title and name. Excludes installed sticker sets from the results

Parameters:
  • sticker_type ("types.StickerType") – Type of the sticker sets to return

  • query (str) – Query to search for

Return type:

Union[Error, StickerSets]

Returns:

StickerSets

async searchStickers(sticker_type=None, emojis='', query='', input_language_codes=None, offset=0, limit=0)[source]

Searches for stickers from public sticker sets that correspond to any of the given emoji

Parameters:
  • sticker_type ("types.StickerType") – Type of the stickers to return

  • emojis (str) – Space-separated list of emojis to search for

  • query (str) – Query to search for; may be empty to search for emoji only

  • input_language_codes (List[str]) – List of possible IETF language tags of the user’s input language; may be empty if unknown

  • offset (int) – The offset from which to return the stickers; must be non-negative

  • limit (int) – The maximum number of stickers to be returned; 0-100

Return type:

Union[Error, Stickers]

Returns:

Stickers

async searchStringsByPrefix(strings=None, query='', limit=0, return_none_for_empty_query=False)[source]

Searches specified query by word prefixes in the provided strings. Returns 0-based positions of strings that matched. Can be called synchronously

Parameters:
  • strings (List[str]) – The strings to search in for the query

  • query (str) – Query to search for

  • limit (int) – The maximum number of objects to return

  • return_none_for_empty_query (bool) – Pass true to receive no results for an empty query

Return type:

Union[Error, FoundPositions]

Returns:

FoundPositions

async searchUserByPhoneNumber(phone_number='', only_local=False)[source]

Searches a user by their phone number. Returns a 404 error if the user can’t be found

Parameters:
  • phone_number (str) – Phone number to search for

  • only_local (bool) – Pass true to get only locally available information without sending network requests

Return type:

Union[Error, User]

Returns:

User

async searchUserByToken(token='')[source]

Searches a user by a token from the user’s link

Parameters:

token (str) – Token to search for

Return type:

Union[Error, User]

Returns:

User

async searchWebApp(bot_user_id=0, web_app_short_name='')[source]

Returns information about a Web App by its short name. Returns a 404 error if the Web App is not found

Parameters:
  • bot_user_id (int) – Identifier of the target bot

  • web_app_short_name (str) – Short name of the Web App

Return type:

Union[Error, FoundWebApp]

Returns:

FoundWebApp

async sellGift(business_connection_id='', received_gift_id='')[source]

Sells a gift for Telegram Stars; requires owner privileges for gifts owned by a chat

Parameters:
  • business_connection_id (str) – Unique identifier of business connection on behalf of which to send the request; for bots only

  • received_gift_id (str) – Identifier of the gift

Return type:

Union[Error, Ok]

Returns:

Ok

async sendAuthenticationFirebaseSms(token='')[source]

Sends Firebase Authentication SMS to the phone number of the user. Works only when the current authorization state is authorizationStateWaitCode and the server returned code of the type authenticationCodeTypeFirebaseAndroid or authenticationCodeTypeFirebaseIos

Parameters:

token (str) – Play Integrity API or SafetyNet Attestation API token for the Android application, or secret from push notification for the iOS application

Return type:

Union[Error, Ok]

Returns:

Ok

async sendBotStartMessage(bot_user_id=0, chat_id=0, parameter='')[source]

Invites a bot to a chat (if it is not yet a member) and sends it the /start command; requires can_invite_users member right. Bots can’t be invited to a private chat other than the chat with the bot. Bots can’t be invited to channels (although they can be added as admins) and secret chats. Returns the sent message

Parameters:
  • bot_user_id (int) – Identifier of the bot

  • chat_id (int) – Identifier of the target chat

  • parameter (str) – A hidden parameter sent to the bot for deep linking purposes (https://core.telegram.org/bots#deep-linking)

Return type:

Union[Error, Message]

Returns:

Message

async sendBusinessMessage(business_connection_id='', chat_id=0, reply_to=None, disable_notification=False, protect_content=False, effect_id=0, reply_markup=None, input_message_content=None)[source]

Sends a message on behalf of a business account; for bots only. Returns the message after it was sent

Parameters:
  • business_connection_id (str) – Unique identifier of business connection on behalf of which to send the request

  • chat_id (int) – Target chat

  • reply_to ("types.InputMessageReplyTo") – Information about the message to be replied; pass null if none

  • disable_notification (bool) – Pass true to disable notification for the message

  • protect_content (bool) – Pass true if the content of the message must be protected from forwarding and saving

  • effect_id (int) – Identifier of the effect to apply to the message

  • reply_markup ("types.ReplyMarkup") – Markup for replying to the message; pass null if none

  • input_message_content ("types.InputMessageContent") – The content of the message to be sent

Return type:

Union[Error, BusinessMessage]

Returns:

BusinessMessage

async sendBusinessMessageAlbum(business_connection_id='', chat_id=0, reply_to=None, disable_notification=False, protect_content=False, effect_id=0, input_message_contents=None)[source]

Sends 2-10 messages grouped together into an album on behalf of a business account; for bots only. Currently, only audio, document, photo and video messages can be grouped into an album. Documents and audio files can be only grouped in an album with messages of the same type. Returns sent messages

Parameters:
  • business_connection_id (str) – Unique identifier of business connection on behalf of which to send the request

  • chat_id (int) – Target chat

  • reply_to ("types.InputMessageReplyTo") – Information about the message to be replied; pass null if none

  • disable_notification (bool) – Pass true to disable notification for the message

  • protect_content (bool) – Pass true if the content of the message must be protected from forwarding and saving

  • effect_id (int) – Identifier of the effect to apply to the message

  • input_message_contents (List["types.InputMessageContent"]) – Contents of messages to be sent. At most 10 messages can be added to an album. All messages must have the same value of show_caption_above_media

Return type:

Union[Error, BusinessMessages]

Returns:

BusinessMessages

async sendCallDebugInformation(call_id=0, debug_information='')[source]

Sends debug information for a call to Telegram servers

Parameters:
  • call_id (int) – Call identifier

  • debug_information (str) – Debug information in application-specific format

Return type:

Union[Error, Ok]

Returns:

Ok

async sendCallLog(call_id=0, log_file=None)[source]

Sends log file for a call to Telegram servers

Parameters:
  • call_id (int) – Call identifier

  • log_file ("types.InputFile") – Call log file. Only inputFileLocal and inputFileGenerated are supported

Return type:

Union[Error, Ok]

Returns:

Ok

async sendCallRating(call_id=0, rating=0, comment='', problems=None)[source]

Sends a call rating

Parameters:
  • call_id (int) – Call identifier

  • rating (int) – Call rating; 1-5

  • comment (str) – An optional user comment if the rating is less than 5

  • problems (List["types.CallProblem"]) – List of the exact types of problems with the call, specified by the user

Return type:

Union[Error, Ok]

Returns:

Ok

async sendCallSignalingData(call_id=0, data=b'')[source]

Sends call signaling data

Parameters:
  • call_id (int) – Call identifier

  • data (bytes) – The data

Return type:

Union[Error, Ok]

Returns:

Ok

async sendChatAction(chat_id=0, message_thread_id=0, business_connection_id='', action=None)[source]

Sends a notification about user activity in a chat

Parameters:
  • chat_id (int) – Chat identifier

  • message_thread_id (int) – If not 0, the message thread identifier in which the action was performed

  • business_connection_id (str) – Unique identifier of business connection on behalf of which to send the request; for bots only

  • action ("types.ChatAction") – The action description; pass null to cancel the currently active action

Return type:

Union[Error, Ok]

Returns:

Ok

async sendCustomRequest(method='', parameters='')[source]

Sends a custom request; for bots only

Parameters:
  • method (str) – The method name

  • parameters (str) – JSON-serialized method parameters

Return type:

Union[Error, CustomRequestResult]

Returns:

CustomRequestResult

async sendEmailAddressVerificationCode(email_address='')[source]

Sends a code to verify an email address to be added to a user’s Telegram Passport

Parameters:

email_address (str) – Email address

Return type:

Union[Error, EmailAddressAuthenticationCodeInfo]

Returns:

EmailAddressAuthenticationCodeInfo

async sendGift(gift_id=0, owner_id=None, text=None, is_private=False, pay_for_upgrade=False)[source]

Sends a gift to another user or channel chat. May return an error with a message "STARGIFT_USAGE_LIMITED" if the gift was sold out

Parameters:
  • gift_id (int) – Identifier of the gift to send

  • owner_id ("types.MessageSender") – Identifier of the user or the channel chat that will receive the gift; limited gifts can’t be sent to channel chats

  • text ("types.FormattedText") – Text to show along with the gift; 0-getOption("gift_text_length_max") characters. Only Bold, Italic, Underline, Strikethrough, Spoiler, and CustomEmoji entities are allowed. Must be empty if the receiver enabled paid messages

  • is_private (bool) – Pass true to show gift text and sender only to the gift receiver; otherwise, everyone will be able to see them

  • pay_for_upgrade (bool) – Pass true to additionally pay for the gift upgrade and allow the receiver to upgrade it for free

Return type:

Union[Error, Ok]

Returns:

Ok

async sendInlineQueryResultMessage(chat_id=0, message_thread_id=0, reply_to=None, options=None, query_id=0, result_id='', hide_via_bot=False)[source]

Sends the result of an inline query as a message. Returns the sent message. Always clears a chat draft message

Parameters:
  • chat_id (int) – Target chat

  • message_thread_id (int) – If not 0, the message thread identifier in which the message will be sent

  • reply_to ("types.InputMessageReplyTo") – Information about the message or story to be replied; pass null if none

  • options ("types.MessageSendOptions") – Options to be used to send the message; pass null to use default options

  • query_id (int) – Identifier of the inline query

  • result_id (str) – Identifier of the inline query result

  • hide_via_bot (bool) – Pass true to hide the bot, via which the message is sent. Can be used only for bots getOption("animation_search_bot_username"), getOption("photo_search_bot_username"), and getOption("venue_search_bot_username")

Return type:

Union[Error, Message]

Returns:

Message

async sendMessage(chat_id=0, message_thread_id=0, reply_to=None, options=None, reply_markup=None, input_message_content=None)[source]

Sends a message. Returns the sent message

Parameters:
  • chat_id (int) – Target chat

  • message_thread_id (int) – If not 0, the message thread identifier in which the message will be sent

  • reply_to ("types.InputMessageReplyTo") – Information about the message or story to be replied; pass null if none

  • options ("types.MessageSendOptions") – Options to be used to send the message; pass null to use default options

  • reply_markup ("types.ReplyMarkup") – Markup for replying to the message; pass null if none; for bots only

  • input_message_content ("types.InputMessageContent") – The content of the message to be sent

Return type:

Union[Error, Message]

Returns:

Message

async sendMessageAlbum(chat_id=0, message_thread_id=0, reply_to=None, options=None, input_message_contents=None)[source]

Sends 2-10 messages grouped together into an album. Currently, only audio, document, photo and video messages can be grouped into an album. Documents and audio files can be only grouped in an album with messages of the same type. Returns sent messages

Parameters:
  • chat_id (int) – Target chat

  • message_thread_id (int) – If not 0, the message thread identifier in which the messages will be sent

  • reply_to ("types.InputMessageReplyTo") – Information about the message or story to be replied; pass null if none

  • options ("types.MessageSendOptions") – Options to be used to send the messages; pass null to use default options

  • input_message_contents (List["types.InputMessageContent"]) – Contents of messages to be sent. At most 10 messages can be added to an album. All messages must have the same value of show_caption_above_media

Return type:

Union[Error, Messages]

Returns:

Messages

async sendPassportAuthorizationForm(authorization_form_id=0, types=None)[source]

Sends a Telegram Passport authorization form, effectively sharing data with the service. This method must be called after getPassportAuthorizationFormAvailableElements if some previously available elements are going to be reused

Parameters:
  • authorization_form_id (int) – Authorization form identifier

  • types (List["types.PassportElementType"]) – Types of Telegram Passport elements chosen by user to complete the authorization form

Return type:

Union[Error, Ok]

Returns:

Ok

async sendPaymentForm(input_invoice=None, payment_form_id=0, order_info_id='', shipping_option_id='', credentials=None, tip_amount=0)[source]

Sends a filled-out payment form to the bot for final verification

Parameters:
  • input_invoice ("types.InputInvoice") – The invoice

  • payment_form_id (int) – Payment form identifier returned by getPaymentForm

  • order_info_id (str) – Identifier returned by validateOrderInfo, or an empty string

  • shipping_option_id (str) – Identifier of a chosen shipping option, if applicable

  • credentials ("types.InputCredentials") – The credentials chosen by user for payment; pass null for a payment in Telegram Stars

  • tip_amount (int) – Chosen by the user amount of tip in the smallest units of the currency

Return type:

Union[Error, PaymentResult]

Returns:

PaymentResult

async sendPhoneNumberCode(phone_number='', settings=None, type=None)[source]

Sends a code to the specified phone number. Aborts previous phone number verification if there was one. On success, returns information about the sent code

Parameters:
  • phone_number (str) – The phone number, in international format

  • settings ("types.PhoneNumberAuthenticationSettings") – Settings for the authentication of the user’s phone number; pass null to use default settings

  • type ("types.PhoneNumberCodeType") – Type of the request for which the code is sent

Return type:

Union[Error, AuthenticationCodeInfo]

Returns:

AuthenticationCodeInfo

async sendPhoneNumberFirebaseSms(token='')[source]

Sends Firebase Authentication SMS to the specified phone number. Works only when received a code of the type authenticationCodeTypeFirebaseAndroid or authenticationCodeTypeFirebaseIos

Parameters:

token (str) – Play Integrity API or SafetyNet Attestation API token for the Android application, or secret from push notification for the iOS application

Return type:

Union[Error, Ok]

Returns:

Ok

async sendQuickReplyShortcutMessages(chat_id=0, shortcut_id=0, sending_id=0)[source]

Sends messages from a quick reply shortcut. Requires Telegram Business subscription. Can’t be used to send paid messages

Parameters:
  • chat_id (int) – Identifier of the chat to which to send messages. The chat must be a private chat with a regular user

  • shortcut_id (int) – Unique identifier of the quick reply shortcut

  • sending_id (int) – Non-persistent identifier, which will be returned back in messageSendingStatePending object and can be used to match sent messages and corresponding updateNewMessage updates

Return type:

Union[Error, Messages]

Returns:

Messages

async sendResoldGift(gift_name='', owner_id=None, price=None)[source]

Sends an upgraded gift that is available for resale to another user or channel chat; gifts already owned by the current user must be transferred using transferGift and can’t be passed to the method

Parameters:
  • gift_name (str) – Name of the upgraded gift to send

  • owner_id ("types.MessageSender") – Identifier of the user or the channel chat that will receive the gift

  • price ("types.GiftResalePrice") – The price that the user agreed to pay for the gift

Return type:

Union[Error, GiftResaleResult]

Returns:

GiftResaleResult

async sendWebAppCustomRequest(bot_user_id=0, method='', parameters='')[source]

Sends a custom request from a Web App

Parameters:
  • bot_user_id (int) – Identifier of the bot

  • method (str) – The method name

  • parameters (str) – JSON-serialized method parameters

Return type:

Union[Error, CustomRequestResult]

Returns:

CustomRequestResult

async sendWebAppData(bot_user_id=0, button_text='', data='')[source]

Sends data received from a keyboardButtonTypeWebApp Web App to a bot

Parameters:
  • bot_user_id (int) – Identifier of the target bot

  • button_text (str) – Text of the keyboardButtonTypeWebApp button, which opened the Web App

  • data (str) – The data

Return type:

Union[Error, Ok]

Returns:

Ok

async setAccentColor(accent_color_id=0, background_custom_emoji_id=0)[source]

Changes accent color and background custom emoji for the current user; for Telegram Premium users only

Parameters:
  • accent_color_id (int) – Identifier of the accent color to use

  • background_custom_emoji_id (int) – Identifier of a custom emoji to be shown on the reply header and link preview background; 0 if none

Return type:

Union[Error, Ok]

Returns:

Ok

async setAccountTtl(ttl=None)[source]

Changes the period of inactivity after which the account of the current user will automatically be deleted

Parameters:

ttl ("types.AccountTtl") – New account TTL

Return type:

Union[Error, Ok]

Returns:

Ok

async setAlarm(seconds=0.0)[source]

Succeeds after a specified amount of time has passed. Can be called before initialization

Parameters:

seconds (float) – Number of seconds before the function returns

Return type:

Union[Error, Ok]

Returns:

Ok

async setApplicationVerificationToken(verification_id=0, token='')[source]

Application or reCAPTCHA verification has been completed. Can be called before authorization

Parameters:
  • verification_id (int) – Unique identifier for the verification process as received from updateApplicationVerificationRequired or updateApplicationRecaptchaVerificationRequired

  • token (str) – Play Integrity API token for the Android application, or secret from push notification for the iOS application for application verification, or reCAPTCHA token for reCAPTCHA verifications; pass an empty string to abort verification and receive the error "VERIFICATION_FAILED" for the request

Return type:

Union[Error, Ok]

Returns:

Ok

async setArchiveChatListSettings(settings=None)[source]

Changes settings for automatic moving of chats to and from the Archive chat lists

Parameters:

settings ("types.ArchiveChatListSettings") – New settings

Return type:

Union[Error, Ok]

Returns:

Ok

async setAuthenticationEmailAddress(email_address='')[source]

Sets the email address of the user and sends an authentication code to the email address. Works only when the current authorization state is authorizationStateWaitEmailAddress

Parameters:

email_address (str) – The email address of the user

Return type:

Union[Error, Ok]

Returns:

Ok

async setAuthenticationPhoneNumber(phone_number='', settings=None)[source]

Sets the phone number of the user and sends an authentication code to the user. Works only when the current authorization state is authorizationStateWaitPhoneNumber, or if there is no pending authentication query and the current authorization state is authorizationStateWaitPremiumPurchase, authorizationStateWaitEmailAddress, authorizationStateWaitEmailCode, authorizationStateWaitCode, authorizationStateWaitRegistration, or authorizationStateWaitPassword

Parameters:
  • phone_number (str) – The phone number of the user, in international format

  • settings ("types.PhoneNumberAuthenticationSettings") – Settings for the authentication of the user’s phone number; pass null to use default settings

Return type:

Union[Error, Ok]

Returns:

Ok

async setAuthenticationPremiumPurchaseTransaction(transaction=None, is_restore=False, currency='', amount=0)[source]

Informs server about an in-store purchase of Telegram Premium before authorization. Works only when the current authorization state is authorizationStateWaitPremiumPurchase

Parameters:
  • transaction ("types.StoreTransaction") – Information about the transaction

  • is_restore (bool) – Pass true if this is a restore of a Telegram Premium purchase; only for App Store

  • currency (str) – ISO 4217 currency code of the payment currency

  • amount (int) – Paid amount, in the smallest units of the currency

Return type:

Union[Error, Ok]

Returns:

Ok

async setAutoDownloadSettings(settings=None, type=None)[source]

Sets auto-download settings

Parameters:
  • settings ("types.AutoDownloadSettings") – New user auto-download settings

  • type ("types.NetworkType") – Type of the network for which the new settings are relevant

Return type:

Union[Error, Ok]

Returns:

Ok

async setAutosaveSettings(scope=None, settings=None)[source]

Sets autosave settings for the given scope. The method is guaranteed to work only after at least one call to getAutosaveSettings

Parameters:
  • scope ("types.AutosaveSettingsScope") – Autosave settings scope

  • settings ("types.ScopeAutosaveSettings") – New autosave settings for the scope; pass null to set autosave settings to default

Return type:

Union[Error, Ok]

Returns:

Ok

async setBio(bio='')[source]

Changes the bio of the current user

Parameters:

bio (str) – The new value of the user bio; 0-getOption("bio_length_max") characters without line feeds

Return type:

Union[Error, Ok]

Returns:

Ok

async setBirthdate(birthdate=None)[source]

Changes the birthdate of the current user

Parameters:

birthdate ("types.Birthdate") – The new value of the current user’s birthdate; pass null to remove the birthdate

Return type:

Union[Error, Ok]

Returns:

Ok

async setBotInfoDescription(bot_user_id=0, language_code='', description='')[source]

Sets the text shown in the chat with a bot if the chat is empty. Can be called only if userTypeBot.can_be_edited == true

Parameters:
  • bot_user_id (int) – Identifier of the target bot

  • language_code (str) – A two-letter ISO 639-1 language code. If empty, the description will be shown to all users for whose languages there is no dedicated description

  • description (str) – New bot’s description on the specified language

Return type:

Union[Error, Ok]

Returns:

Ok

async setBotInfoShortDescription(bot_user_id=0, language_code='', short_description='')[source]

Sets the text shown on a bot’s profile page and sent together with the link when users share the bot. Can be called only if userTypeBot.can_be_edited == true

Parameters:
  • bot_user_id (int) – Identifier of the target bot

  • language_code (str) – A two-letter ISO 639-1 language code. If empty, the short description will be shown to all users for whose languages there is no dedicated description

  • short_description (str) – New bot’s short description on the specified language

Return type:

Union[Error, Ok]

Returns:

Ok

async setBotName(bot_user_id=0, language_code='', name='')[source]

Sets the name of a bot. Can be called only if userTypeBot.can_be_edited == true

Parameters:
  • bot_user_id (int) – Identifier of the target bot

  • language_code (str) – A two-letter ISO 639-1 language code. If empty, the name will be shown to all users for whose languages there is no dedicated name

  • name (str) – New bot’s name on the specified language; 0-64 characters; must be non-empty if language code is empty

Return type:

Union[Error, Ok]

Returns:

Ok

async setBotProfilePhoto(bot_user_id=0, photo=None)[source]

Changes a profile photo for a bot

Parameters:
  • bot_user_id (int) – Identifier of the target bot

  • photo ("types.InputChatPhoto") – Profile photo to set; pass null to delete the chat photo

Return type:

Union[Error, Ok]

Returns:

Ok

async setBotUpdatesStatus(pending_update_count=0, error_message='')[source]

Informs the server about the number of pending bot updates if they haven’t been processed for a long time; for bots only

Parameters:
  • pending_update_count (int) – The number of pending updates

  • error_message (str) – The last error message

Return type:

Union[Error, Ok]

Returns:

Ok

async setBusinessAccountBio(business_connection_id='', bio='')[source]

Changes the bio of a business account; for bots only

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

  • bio (str) – The new value of the bio; 0-getOption("bio_length_max") characters without line feeds

Return type:

Union[Error, Ok]

Returns:

Ok

async setBusinessAccountGiftSettings(business_connection_id='', settings=None)[source]

Changes settings for gift receiving of a business account; for bots only

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

  • settings ("types.GiftSettings") – The new settings

Return type:

Union[Error, Ok]

Returns:

Ok

async setBusinessAccountName(business_connection_id='', first_name='', last_name='')[source]

Changes the first and last name of a business account; for bots only

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

  • first_name (str) – The new value of the first name for the business account; 1-64 characters

  • last_name (str) – The new value of the optional last name for the business account; 0-64 characters

Return type:

Union[Error, Ok]

Returns:

Ok

async setBusinessAccountProfilePhoto(business_connection_id='', photo=None, is_public=False)[source]

Changes a profile photo of a business account; for bots only

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

  • photo ("types.InputChatPhoto") – Profile photo to set; pass null to remove the photo

  • is_public (bool) – Pass true to set the public photo, which will be visible even if the main photo is hidden by privacy settings

Return type:

Union[Error, Ok]

Returns:

Ok

async setBusinessAccountUsername(business_connection_id='', username='')[source]

Changes the editable username of a business account; for bots only

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

  • username (str) – The new value of the username

Return type:

Union[Error, Ok]

Returns:

Ok

async setBusinessAwayMessageSettings(away_message_settings=None)[source]

Changes the business away message settings of the current user. Requires Telegram Business subscription

Parameters:

away_message_settings ("types.BusinessAwayMessageSettings") – The new settings for the away message of the business; pass null to disable the away message

Return type:

Union[Error, Ok]

Returns:

Ok

async setBusinessConnectedBot(bot=None)[source]

Adds or changes business bot that is connected to the current user account

Parameters:

bot ("types.BusinessConnectedBot") – Connection settings for the bot

Return type:

Union[Error, Ok]

Returns:

Ok

async setBusinessGreetingMessageSettings(greeting_message_settings=None)[source]

Changes the business greeting message settings of the current user. Requires Telegram Business subscription

Parameters:

greeting_message_settings ("types.BusinessGreetingMessageSettings") – The new settings for the greeting message of the business; pass null to disable the greeting message

Return type:

Union[Error, Ok]

Returns:

Ok

async setBusinessLocation(location=None)[source]

Changes the business location of the current user. Requires Telegram Business subscription

Parameters:

location ("types.BusinessLocation") – The new location of the business; pass null to remove the location

Return type:

Union[Error, Ok]

Returns:

Ok

async setBusinessMessageIsPinned(business_connection_id='', chat_id=0, message_id=0, is_pinned=False)[source]

Pins or unpins a message sent on behalf of a business account; for bots only

Parameters:
  • business_connection_id (str) – Unique identifier of business connection on behalf of which the message was sent

  • chat_id (int) – The chat the message belongs to

  • message_id (int) – Identifier of the message

  • is_pinned (bool) – Pass true to pin the message, pass false to unpin it

Return type:

Union[Error, Ok]

Returns:

Ok

async setBusinessOpeningHours(opening_hours=None)[source]

Changes the business opening hours of the current user. Requires Telegram Business subscription

Parameters:

opening_hours ("types.BusinessOpeningHours") – The new opening hours of the business; pass null to remove the opening hours; up to 28 time intervals can be specified

Return type:

Union[Error, Ok]

Returns:

Ok

async setBusinessStartPage(start_page=None)[source]

Changes the business start page of the current user. Requires Telegram Business subscription

Parameters:

start_page ("types.InputBusinessStartPage") – The new start page of the business; pass null to remove custom start page

Return type:

Union[Error, Ok]

Returns:

Ok

async setChatAccentColor(chat_id=0, accent_color_id=0, background_custom_emoji_id=0)[source]

Changes accent color and background custom emoji of a channel chat. Requires can_change_info administrator right

Parameters:
  • chat_id (int) – Chat identifier

  • accent_color_id (int) – Identifier of the accent color to use. The chat must have at least accentColor.min_channel_chat_boost_level boost level to pass the corresponding color

  • background_custom_emoji_id (int) – Identifier of a custom emoji to be shown on the reply header and link preview background; 0 if none. Use chatBoostLevelFeatures.can_set_background_custom_emoji to check whether a custom emoji can be set

Return type:

Union[Error, Ok]

Returns:

Ok

async setChatActiveStoriesList(chat_id=0, story_list=None)[source]

Changes story list in which stories from the chat are shown

Parameters:
  • chat_id (int) – Identifier of the chat that posted stories

  • story_list ("types.StoryList") – New list for active stories posted by the chat

Return type:

Union[Error, Ok]

Returns:

Ok

async setChatAffiliateProgram(chat_id=0, parameters=None)[source]

Changes affiliate program for a bot

Parameters:
  • chat_id (int) – Identifier of the chat with an owned bot for which affiliate program is changed

  • parameters ("types.AffiliateProgramParameters") – Parameters of the affiliate program; pass null to close the currently active program. If there is an active program, then commission and program duration can only be increased. If the active program is scheduled to be closed, then it can’t be changed anymore

Return type:

Union[Error, Ok]

Returns:

Ok

async setChatAvailableReactions(chat_id=0, available_reactions=None)[source]

Changes reactions, available in a chat. Available for basic groups, supergroups, and channels. Requires can_change_info member right

Parameters:
  • chat_id (int) – Identifier of the chat

  • available_reactions ("types.ChatAvailableReactions") – Reactions available in the chat. All explicitly specified emoji reactions must be active. In channel chats up to the chat’s boost level custom emoji reactions can be explicitly specified

Return type:

Union[Error, Ok]

Returns:

Ok

async setChatBackground(chat_id=0, background=None, type=None, dark_theme_dimming=0, only_for_self=False)[source]

Sets the background in a specific chat. Supported only in private and secret chats with non-deleted users, and in chats with sufficient boost level and can_change_info administrator right

Parameters:
  • chat_id (int) – Chat identifier

  • background ("types.InputBackground") – The input background to use; pass null to create a new filled or chat theme background

  • type ("types.BackgroundType") – Background type; pass null to use default background type for the chosen background; backgroundTypeChatTheme isn’t supported for private and secret chats. Use chatBoostLevelFeatures.chat_theme_background_count and chatBoostLevelFeatures.can_set_custom_background to check whether the background type can be set in the boosted chat

  • dark_theme_dimming (int) – Dimming of the background in dark themes, as a percentage; 0-100. Applied only to Wallpaper and Fill types of background

  • only_for_self (bool) – Pass true to set background only for self; pass false to set background for all chat users. Always false for backgrounds set in boosted chats. Background can be set for both users only by Telegram Premium users and if set background isn’t of the type inputBackgroundPrevious

Return type:

Union[Error, Ok]

Returns:

Ok

async setChatClientData(chat_id=0, client_data='')[source]

Changes application-specific data associated with a chat

Parameters:
  • chat_id (int) – Chat identifier

  • client_data (str) – New value of client_data

Return type:

Union[Error, Ok]

Returns:

Ok

async setChatDescription(chat_id=0, description='')[source]

Changes information about a chat. Available for basic groups, supergroups, and channels. Requires can_change_info member right

Parameters:
  • chat_id (int) – Identifier of the chat

  • description (str) – New chat description; 0-255 characters

Return type:

Union[Error, Ok]

Returns:

Ok

async setChatDirectMessagesGroup(chat_id=0, is_enabled=False, paid_message_star_count=0)[source]

Changes direct messages group settings for a channel chat; requires owner privileges in the chat

Parameters:
  • chat_id (int) – Identifier of the channel chat

  • is_enabled (bool) – Pass true if the direct messages group is enabled for the channel chat; pass false otherwise

  • paid_message_star_count (int) – The new number of Telegram Stars that must be paid for each message that is sent to the direct messages chat unless the sender is an administrator of the channel chat; 0-getOption("paid_message_star_count_max"). The channel will receive getOption("paid_message_earnings_per_mille") Telegram Stars for each 1000 Telegram Stars paid for message sending. Requires supergroupFullInfo.can_enable_paid_messages for positive amounts

Return type:

Union[Error, Ok]

Returns:

Ok

async setChatDiscussionGroup(chat_id=0, discussion_chat_id=0)[source]

Changes the discussion group of a channel chat; requires can_change_info administrator right in the channel if it is specified

Parameters:
  • chat_id (int) – Identifier of the channel chat. Pass 0 to remove a link from the supergroup passed in the second argument to a linked channel chat (requires can_pin_messages member right in the supergroup)

  • discussion_chat_id (int) – Identifier of a new channel’s discussion group. Use 0 to remove the discussion group. Use the method getSuitableDiscussionChats to find all suitable groups. Basic group chats must be first upgraded to supergroup chats. If new chat members don’t have access to old messages in the supergroup, then toggleSupergroupIsAllHistoryAvailable must be used first to change that

Return type:

Union[Error, Ok]

Returns:

Ok

async setChatDraftMessage(chat_id=0, message_thread_id=0, draft_message=None)[source]

Changes the draft message in a chat

Parameters:
  • chat_id (int) – Chat identifier

  • message_thread_id (int) – If not 0, the message thread identifier in which the draft was changed

  • draft_message ("types.DraftMessage") – New draft message; pass null to remove the draft. All files in draft message content must be of the type inputFileLocal. Media thumbnails and captions are ignored

Return type:

Union[Error, Ok]

Returns:

Ok

async setChatEmojiStatus(chat_id=0, emoji_status=None)[source]

Changes the emoji status of a chat. Use chatBoostLevelFeatures.can_set_emoji_status to check whether an emoji status can be set. Requires can_change_info administrator right

Parameters:
  • chat_id (int) – Chat identifier

  • emoji_status ("types.EmojiStatus") – New emoji status; pass null to remove emoji status

Return type:

Union[Error, Ok]

Returns:

Ok

async setChatLocation(chat_id=0, location=None)[source]

Changes the location of a chat. Available only for some location-based supergroups, use supergroupFullInfo.can_set_location to check whether the method is allowed to use

Parameters:
  • chat_id (int) – Chat identifier

  • location ("types.ChatLocation") – New location for the chat; must be valid and not null

Return type:

Union[Error, Ok]

Returns:

Ok

async setChatMemberStatus(chat_id=0, member_id=None, status=None)[source]

Changes the status of a chat member; requires can_invite_users member right to add a chat member, can_promote_members administrator right to change administrator rights of the member, and can_restrict_members administrator right to change restrictions of a user. This function is currently not suitable for transferring chat ownership; use transferChatOwnership instead. Use addChatMember or banChatMember if some additional parameters needs to be passed

Parameters:
  • chat_id (int) – Chat identifier

  • member_id ("types.MessageSender") – Member identifier. Chats can be only banned and unbanned in supergroups and channels

  • status ("types.ChatMemberStatus") – The new status of the member in the chat

Return type:

Union[Error, Ok]

Returns:

Ok

async setChatMessageAutoDeleteTime(chat_id=0, message_auto_delete_time=0)[source]

Changes the message auto-delete or self-destruct (for secret chats) time in a chat. Requires change_info administrator right in basic groups, supergroups and channels. Message auto-delete time can’t be changed in a chat with the current user (Saved Messages) and the chat 777000 (Telegram).

Parameters:
  • chat_id (int) – Chat identifier

  • message_auto_delete_time (int) – New time value, in seconds; unless the chat is secret, it must be from 0 up to 365 * 86400 and be divisible by 86400. If 0, then messages aren’t deleted automatically

Return type:

Union[Error, Ok]

Returns:

Ok

async setChatMessageSender(chat_id=0, message_sender_id=None)[source]

Selects a message sender to send messages in a chat

Parameters:
  • chat_id (int) – Chat identifier

  • message_sender_id ("types.MessageSender") – New message sender for the chat

Return type:

Union[Error, Ok]

Returns:

Ok

async setChatNotificationSettings(chat_id=0, notification_settings=None)[source]

Changes the notification settings of a chat. Notification settings of a chat with the current user (Saved Messages) can’t be changed

Parameters:
  • chat_id (int) – Chat identifier

  • notification_settings ("types.ChatNotificationSettings") – New notification settings for the chat. If the chat is muted for more than 366 days, it is considered to be muted forever

Return type:

Union[Error, Ok]

Returns:

Ok

async setChatPaidMessageStarCount(chat_id=0, paid_message_star_count=0)[source]

Changes the amount of Telegram Stars that must be paid to send a message to a supergroup chat; requires can_restrict_members administrator right and supergroupFullInfo.can_enable_paid_messages

Parameters:
  • chat_id (int) – Identifier of the supergroup chat

  • paid_message_star_count (int) – The new number of Telegram Stars that must be paid for each message that is sent to the supergroup chat unless the sender is an administrator of the chat; 0-getOption("paid_message_star_count_max"). The supergroup will receive getOption("paid_message_earnings_per_mille") Telegram Stars for each 1000 Telegram Stars paid for message sending

Return type:

Union[Error, Ok]

Returns:

Ok

async setChatPermissions(chat_id=0, permissions=None)[source]

Changes the chat members permissions. Supported only for basic groups and supergroups. Requires can_restrict_members administrator right

Parameters:
  • chat_id (int) – Chat identifier

  • permissions ("types.ChatPermissions") – New non-administrator members permissions in the chat

Return type:

Union[Error, Ok]

Returns:

Ok

async setChatPhoto(chat_id=0, photo=None)[source]

Changes the photo of a chat. Supported only for basic groups, supergroups and channels. Requires can_change_info member right

Parameters:
  • chat_id (int) – Chat identifier

  • photo ("types.InputChatPhoto") – New chat photo; pass null to delete the chat photo

Return type:

Union[Error, Ok]

Returns:

Ok

async setChatPinnedStories(chat_id=0, story_ids=None)[source]

Changes the list of pinned stories on a chat page; requires can_edit_stories administrator right in the chat

Parameters:
  • chat_id (int) – Identifier of the chat that posted the stories

  • story_ids (List[int]) – New list of pinned stories. All stories must be posted to the chat page first. There can be up to getOption("pinned_story_count_max") pinned stories on a chat page

Return type:

Union[Error, Ok]

Returns:

Ok

async setChatProfileAccentColor(chat_id=0, profile_accent_color_id=0, profile_background_custom_emoji_id=0)[source]

Changes accent color and background custom emoji for profile of a supergroup or channel chat. Requires can_change_info administrator right

Parameters:
  • chat_id (int) – Chat identifier

  • profile_accent_color_id (int) – Identifier of the accent color to use for profile; pass -1 if none. The chat must have at least profileAccentColor.min_supergroup_chat_boost_level for supergroups or profileAccentColor.min_channel_chat_boost_level for channels boost level to pass the corresponding color

  • profile_background_custom_emoji_id (int) – Identifier of a custom emoji to be shown on the chat’s profile photo background; 0 if none. Use chatBoostLevelFeatures.can_set_profile_background_custom_emoji to check whether a custom emoji can be set

Return type:

Union[Error, Ok]

Returns:

Ok

async setChatSlowModeDelay(chat_id=0, slow_mode_delay=0)[source]

Changes the slow mode delay of a chat. Available only for supergroups; requires can_restrict_members administrator right

Parameters:
  • chat_id (int) – Chat identifier

  • slow_mode_delay (int) – New slow mode delay for the chat, in seconds; must be one of 0, 10, 30, 60, 300, 900, 3600

Return type:

Union[Error, Ok]

Returns:

Ok

async setChatTheme(chat_id=0, theme=None)[source]

Changes the chat theme. Supported only in private and secret chats

Parameters:
  • chat_id (int) – Chat identifier

  • theme ("types.InputChatTheme") – New chat theme; pass null to return the default theme

Return type:

Union[Error, Ok]

Returns:

Ok

async setChatTitle(chat_id=0, title='')[source]

Changes the chat title. Supported only for basic groups, supergroups and channels. Requires can_change_info member right

Parameters:
  • chat_id (int) – Chat identifier

  • title (str) – New title of the chat; 1-128 characters

Return type:

Union[Error, Ok]

Returns:

Ok

async setCloseFriends(user_ids=None)[source]

Changes the list of close friends of the current user

Parameters:

user_ids (List[int]) – User identifiers of close friends; the users must be contacts of the current user

Return type:

Union[Error, Ok]

Returns:

Ok

async setCommands(scope=None, language_code='', commands=None)[source]

Sets the list of commands supported by the bot for the given user scope and language; for bots only

Parameters:
  • scope ("types.BotCommandScope") – The scope to which the commands are relevant; pass null to change commands in the default bot command scope

  • language_code (str) – A two-letter ISO 639-1 language code. If empty, the commands will be applied to all users from the given scope, for which language there are no dedicated commands

  • commands (List["types.BotCommand"]) – List of the bot’s commands

Return type:

Union[Error, Ok]

Returns:

Ok

async setCustomEmojiStickerSetThumbnail(name='', custom_emoji_id=0)[source]

Sets a custom emoji sticker set thumbnail

Parameters:
  • name (str) – Sticker set name. The sticker set must be owned by the current user

  • custom_emoji_id (int) – Identifier of the custom emoji from the sticker set, which will be set as sticker set thumbnail; pass 0 to remove the sticker set thumbnail

Return type:

Union[Error, Ok]

Returns:

Ok

async setCustomLanguagePack(info=None, strings=None)[source]

Adds or changes a custom local language pack to the current localization target

Parameters:
  • info ("types.LanguagePackInfo") – Information about the language pack. Language pack identifier must start with ‘X’, consist only of English letters, digits and hyphens, and must not exceed 64 characters. Can be called before authorization

  • strings (List["types.LanguagePackString"]) – Strings of the new language pack

Return type:

Union[Error, Ok]

Returns:

Ok

async setCustomLanguagePackString(language_pack_id='', new_string=None)[source]

Adds, edits or deletes a string in a custom local language pack. Can be called before authorization

Parameters:
  • language_pack_id (str) – Identifier of a previously added custom local language pack in the current localization target

  • new_string ("types.LanguagePackString") – New language pack string

Return type:

Union[Error, Ok]

Returns:

Ok

async setDatabaseEncryptionKey(new_encryption_key=b'')[source]

Changes the database encryption key. Usually the encryption key is never changed and is stored in some OS keychain

Parameters:

new_encryption_key (bytes) – New encryption key

Return type:

Union[Error, Ok]

Returns:

Ok

async setDefaultBackground(background=None, type=None, for_dark_theme=False)[source]

Sets default background for chats; adds the background to the list of installed backgrounds

Parameters:
  • background ("types.InputBackground") – The input background to use; pass null to create a new filled background

  • type ("types.BackgroundType") – Background type; pass null to use the default type of the remote background; backgroundTypeChatTheme isn’t supported

  • for_dark_theme (bool) – Pass true if the background is set for a dark theme

Return type:

Union[Error, Background]

Returns:

Background

async setDefaultChannelAdministratorRights(default_channel_administrator_rights=None)[source]

Sets default administrator rights for adding the bot to channel chats; for bots only

Parameters:

default_channel_administrator_rights ("types.ChatAdministratorRights") – Default administrator rights for adding the bot to channels; pass null to remove default rights

Return type:

Union[Error, Ok]

Returns:

Ok

async setDefaultGroupAdministratorRights(default_group_administrator_rights=None)[source]

Sets default administrator rights for adding the bot to basic group and supergroup chats; for bots only

Parameters:

default_group_administrator_rights ("types.ChatAdministratorRights") – Default administrator rights for adding the bot to basic group and supergroup chats; pass null to remove default rights

Return type:

Union[Error, Ok]

Returns:

Ok

async setDefaultMessageAutoDeleteTime(message_auto_delete_time=None)[source]

Changes the default message auto-delete time for new chats

Parameters:

message_auto_delete_time ("types.MessageAutoDeleteTime") – New default message auto-delete time; must be from 0 up to 365 * 86400 and be divisible by 86400. If 0, then messages aren’t deleted automatically

Return type:

Union[Error, Ok]

Returns:

Ok

async setDefaultReactionType(reaction_type=None)[source]

Changes type of default reaction for the current user

Parameters:

reaction_type ("types.ReactionType") – New type of the default reaction. The paid reaction can’t be set as default

Return type:

Union[Error, Ok]

Returns:

Ok

async setDirectMessagesChatTopicDraftMessage(chat_id=0, topic_id=0, draft_message=None)[source]

Changes the draft message in the topic in a channel direct messages chat administered by the current user

Parameters:
  • chat_id (int) – Chat identifier

  • topic_id (int) – Topic identifier

  • draft_message ("types.DraftMessage") – New draft message; pass null to remove the draft. All files in draft message content must be of the type inputFileLocal. Media thumbnails and captions are ignored

Return type:

Union[Error, Ok]

Returns:

Ok

async setDirectMessagesChatTopicIsMarkedAsUnread(chat_id=0, topic_id=0, is_marked_as_unread=False)[source]

Changes the marked as unread state of the topic in a channel direct messages chat administered by the current user

Parameters:
  • chat_id (int) – Chat identifier of the channel direct messages chat

  • topic_id (int) – Topic identifier

  • is_marked_as_unread (bool) – New value of is_marked_as_unread

Return type:

Union[Error, Ok]

Returns:

Ok

async setEmojiStatus(emoji_status=None)[source]

Changes the emoji status of the current user; for Telegram Premium users only

Parameters:

emoji_status ("types.EmojiStatus") – New emoji status; pass null to switch to the default badge

Return type:

Union[Error, Ok]

Returns:

Ok

async setFileGenerationProgress(generation_id=0, expected_size=0, local_prefix_size=0)[source]

Informs TDLib on a file generation progress

Parameters:
  • generation_id (int) – The identifier of the generation process

  • expected_size (int) – Expected size of the generated file, in bytes; 0 if unknown

  • local_prefix_size (int) – The number of bytes already generated

Return type:

Union[Error, Ok]

Returns:

Ok

async setForumTopicNotificationSettings(chat_id=0, message_thread_id=0, notification_settings=None)[source]

Changes the notification settings of a forum topic

Parameters:
  • chat_id (int) – Chat identifier

  • message_thread_id (int) – Message thread identifier of the forum topic

  • notification_settings ("types.ChatNotificationSettings") – New notification settings for the forum topic. If the topic is muted for more than 366 days, it is considered to be muted forever

Return type:

Union[Error, Ok]

Returns:

Ok

async setGameScore(chat_id=0, message_id=0, edit_message=False, user_id=0, score=0, force=False)[source]

Updates the game score of the specified user in the game; for bots only

Parameters:
  • chat_id (int) – The chat to which the message with the game belongs

  • message_id (int) – Identifier of the message

  • edit_message (bool) – Pass true to edit the game message to include the current scoreboard

  • user_id (int) – User identifier

  • score (int) – The new score

  • force (bool) – Pass true to update the score even if it decreases. If the score is 0, the user will be deleted from the high score table

Return type:

Union[Error, Message]

Returns:

Message

async setGiftCollectionName(owner_id=None, collection_id=0, name='')[source]

Changes name of a gift collection. If the collection is owned by a channel chat, then requires can_post_messages administrator right in the channel chat. Returns the changed collection

Parameters:
  • owner_id ("types.MessageSender") – Identifier of the user or the channel chat that owns the collection

  • collection_id (int) – Identifier of the gift collection

  • name (str) – New name of the collection; 1-12 characters

Return type:

Union[Error, GiftCollection]

Returns:

GiftCollection

async setGiftResalePrice(received_gift_id='', price=None)[source]

Changes resale price of a unique gift owned by the current user

Parameters:
  • received_gift_id (str) – Identifier of the unique gift

  • price ("types.GiftResalePrice") – The new price for the unique gift; pass null to disallow gift resale. The current user will receive getOption("gift_resale_star_earnings_per_mille") Telegram Stars for each 1000 Telegram Stars paid for the gift if the gift price is in Telegram Stars or getOption("gift_resale_ton_earnings_per_mille") Toncoins for each 1000 Toncoins paid for the gift if the gift price is in Toncoins

Return type:

Union[Error, Ok]

Returns:

Ok

async setGiftSettings(settings=None)[source]

Changes settings for gift receiving for the current user

Parameters:

settings ("types.GiftSettings") – The new settings

Return type:

Union[Error, Ok]

Returns:

Ok

async setGroupCallParticipantIsSpeaking(group_call_id=0, audio_source=0, is_speaking=False)[source]

Informs TDLib that speaking state of a participant of an active group call has changed. Returns identifier of the participant if it is found

Parameters:
  • group_call_id (int) – Group call identifier

  • audio_source (int) – Group call participant’s synchronization audio source identifier, or 0 for the current user

  • is_speaking (bool) – Pass true if the user is speaking

Return type:

Union[Error, MessageSender]

Returns:

MessageSender

async setGroupCallParticipantVolumeLevel(group_call_id=0, participant_id=None, volume_level=0)[source]

Changes volume level of a participant of an active group call. If the current user can manage the group call or is the owner of the group call, then the participant’s volume level will be changed for all users with the default volume level

Parameters:
  • group_call_id (int) – Group call identifier

  • participant_id ("types.MessageSender") – Participant identifier

  • volume_level (int) – New participant’s volume level; 1-20000 in hundreds of percents

Return type:

Union[Error, Ok]

Returns:

Ok

async setInactiveSessionTtl(inactive_session_ttl_days=0)[source]

Changes the period of inactivity after which sessions will automatically be terminated

Parameters:

inactive_session_ttl_days (int) – New number of days of inactivity before sessions will be automatically terminated; 1-366 days

Return type:

Union[Error, Ok]

Returns:

Ok

async setInlineGameScore(inline_message_id='', edit_message=False, user_id=0, score=0, force=False)[source]

Updates the game score of the specified user in a game; for bots only

Parameters:
  • inline_message_id (str) – Inline message identifier

  • edit_message (bool) – Pass true to edit the game message to include the current scoreboard

  • user_id (int) – User identifier

  • score (int) – The new score

  • force (bool) – Pass true to update the score even if it decreases. If the score is 0, the user will be deleted from the high score table

Return type:

Union[Error, Ok]

Returns:

Ok

async setLogStream(log_stream=None)[source]

Sets new log stream for internal logging of TDLib. Can be called synchronously

Parameters:

log_stream ("types.LogStream") – New log stream

Return type:

Union[Error, Ok]

Returns:

Ok

async setLogTagVerbosityLevel(tag='', new_verbosity_level=0)[source]

Sets the verbosity level for a specified TDLib internal log tag. Can be called synchronously

Parameters:
  • tag (str) – Logging tag to change verbosity level

  • new_verbosity_level (int) – New verbosity level; 1-1024

Return type:

Union[Error, Ok]

Returns:

Ok

async setLogVerbosityLevel(new_verbosity_level=0)[source]

Sets the verbosity level of the internal logging of TDLib. Can be called synchronously

Parameters:

new_verbosity_level (int) – New value of the verbosity level for logging. Value 0 corresponds to fatal errors, value 1 corresponds to errors, value 2 corresponds to warnings and debug warnings, value 3 corresponds to informational, value 4 corresponds to debug, value 5 corresponds to verbose debug, value greater than 5 and up to 1023 can be used to enable even more logging

Return type:

Union[Error, Ok]

Returns:

Ok

async setLoginEmailAddress(new_login_email_address='')[source]

Changes the login email address of the user. The email address can be changed only if the current user already has login email and passwordState.login_email_address_pattern is non-empty. The change will not be applied until the new login email address is confirmed with checkLoginEmailAddressCode. To use Apple ID/Google ID instead of an email address, call checkLoginEmailAddressCode directly

Parameters:

new_login_email_address (str) – New login email address

Return type:

Union[Error, EmailAddressAuthenticationCodeInfo]

Returns:

EmailAddressAuthenticationCodeInfo

async setMainProfileTab(main_profile_tab=None)[source]

Changes the main profile tab of the current user

Parameters:

main_profile_tab ("types.ProfileTab") – The new value of the main profile tab

Return type:

Union[Error, Ok]

Returns:

Ok

async setMenuButton(user_id=0, menu_button=None)[source]

Sets menu button for the given user or for all users; for bots only

Parameters:
  • user_id (int) – Identifier of the user or 0 to set menu button for all users

  • menu_button ("types.BotMenuButton") – New menu button

Return type:

Union[Error, Ok]

Returns:

Ok

async setMessageFactCheck(chat_id=0, message_id=0, text=None)[source]

Changes the fact-check of a message. Can be only used if messageProperties.can_set_fact_check == true

Parameters:
  • chat_id (int) – The channel chat the message belongs to

  • message_id (int) – Identifier of the message

  • text ("types.FormattedText") – New text of the fact-check; 0-getOption("fact_check_length_max") characters; pass null to remove it. Only Bold, Italic, and TextUrl entities with https://t.me/ links are supported

Return type:

Union[Error, Ok]

Returns:

Ok

async setMessageReactions(chat_id=0, message_id=0, reaction_types=None, is_big=False)[source]

Sets reactions on a message; for bots only

Parameters:
  • chat_id (int) – Identifier of the chat to which the message belongs

  • message_id (int) – Identifier of the message

  • reaction_types (List["types.ReactionType"]) – Types of the reaction to set; pass an empty list to remove the reactions

  • is_big (bool) – Pass true if the reactions are added with a big animation

Return type:

Union[Error, Ok]

Returns:

Ok

async setMessageSenderBlockList(sender_id=None, block_list=None)[source]

Changes the block list of a message sender. Currently, only users and supergroup chats can be blocked

Parameters:
  • sender_id ("types.MessageSender") – Identifier of a message sender to block/unblock

  • block_list ("types.BlockList") – New block list for the message sender; pass null to unblock the message sender

Return type:

Union[Error, Ok]

Returns:

Ok

async setMessageSenderBotVerification(bot_user_id=0, verified_id=None, custom_description='')[source]

Changes the verification status of a user or a chat by an owned bot

Parameters:
  • bot_user_id (int) – Identifier of the owned bot, which will verify the user or the chat

  • verified_id ("types.MessageSender") – Identifier of the user or the supergroup or channel chat, which will be verified by the bot

  • custom_description (str) – Custom description of verification reason; 0-getOption("bot_verification_custom_description_length_max"). If empty, then "was verified by organization "organization_name"" will be used as description. Can be specified only if the bot is allowed to provide custom description

Return type:

Union[Error, Ok]

Returns:

Ok

async setName(first_name='', last_name='')[source]

Changes the first and last name of the current user

Parameters:
  • first_name (str) – The new value of the first name for the current user; 1-64 characters

  • last_name (str) – The new value of the optional last name for the current user; 0-64 characters

Return type:

Union[Error, Ok]

Returns:

Ok

async setNetworkType(type=None)[source]

Sets the current network type. Can be called before authorization. Calling this method forces all network connections to reopen, mitigating the delay in switching between different networks, so it must be called whenever the network is changed, even if the network type remains the same. Network type is used to check whether the library can use the network at all and also for collecting detailed network data usage statistics

Parameters:

type ("types.NetworkType") – The new network type; pass null to set network type to networkTypeOther

Return type:

Union[Error, Ok]

Returns:

Ok

async setNewChatPrivacySettings(settings=None)[source]

Changes privacy settings for new chat creation; can be used only if getOption("can_set_new_chat_privacy_settings")

Parameters:

settings ("types.NewChatPrivacySettings") – New settings

Return type:

Union[Error, Ok]

Returns:

Ok

async setOption(name='', value=None)[source]

Sets the value of an option. (Check the list of available options on https://core.telegram.org/tdlib/options.) Only writable options can be set. Can be called before authorization

Parameters:
  • name (str) – The name of the option

  • value ("types.OptionValue") – The new value of the option; pass null to reset option value to a default value

Return type:

Union[Error, Ok]

Returns:

Ok

async setPaidMessageReactionType(chat_id=0, message_id=0, type=None)[source]

Changes type of paid message reaction of the current user on a message. The message must have paid reaction added by the current user

Parameters:
  • chat_id (int) – Identifier of the chat to which the message belongs

  • message_id (int) – Identifier of the message

  • type ("types.PaidReactionType") – New type of the paid reaction

Return type:

Union[Error, Ok]

Returns:

Ok

async setPassportElement(element=None, password='')[source]

Adds an element to the user’s Telegram Passport. May return an error with a message "PHONE_VERIFICATION_NEEDED" or "EMAIL_VERIFICATION_NEEDED" if the chosen phone number or the chosen email address must be verified first

Parameters:
  • element ("types.InputPassportElement") – Input Telegram Passport element

  • password (str) – The 2-step verification password of the current user

Return type:

Union[Error, PassportElement]

Returns:

PassportElement

async setPassportElementErrors(user_id=0, errors=None)[source]

Informs the user that some of the elements in their Telegram Passport contain errors; for bots only. The user will not be able to resend the elements, until the errors are fixed

Parameters:
  • user_id (int) – User identifier

  • errors (List["types.InputPassportElementError"]) – The errors

Return type:

Union[Error, Ok]

Returns:

Ok

async setPassword(old_password='', new_password='', new_hint='', set_recovery_email_address=False, new_recovery_email_address='')[source]

Changes the 2-step verification password for the current user. If a new recovery email address is specified, then the change will not be applied until the new recovery email address is confirmed

Parameters:
  • old_password (str) – Previous 2-step verification password of the user

  • new_password (str) – New 2-step verification password of the user; may be empty to remove the password

  • new_hint (str) – New password hint; may be empty

  • set_recovery_email_address (bool) – Pass true to change also the recovery email address

  • new_recovery_email_address (str) – New recovery email address; may be empty

Return type:

Union[Error, PasswordState]

Returns:

PasswordState

async setPersonalChat(chat_id=0)[source]

Changes the personal chat of the current user

Parameters:

chat_id (int) – Identifier of the new personal chat; pass 0 to remove the chat. Use getSuitablePersonalChats to get suitable chats

Return type:

Union[Error, Ok]

Returns:

Ok

async setPinnedChats(chat_list=None, chat_ids=None)[source]

Changes the order of pinned chats

Parameters:
  • chat_list ("types.ChatList") – Chat list in which to change the order of pinned chats

  • chat_ids (List[int]) – The new list of pinned chats

Return type:

Union[Error, Ok]

Returns:

Ok

async setPinnedForumTopics(chat_id=0, message_thread_ids=None)[source]

Changes the order of pinned forum topics; requires can_manage_topics administrator right in the supergroup

Parameters:
  • chat_id (int) – Chat identifier

  • message_thread_ids (List[int]) – The new list of pinned forum topics

Return type:

Union[Error, Ok]

Returns:

Ok

async setPinnedGifts(owner_id=None, received_gift_ids=None)[source]

Changes the list of pinned gifts on the current user’s or the channel’s profile page; requires can_post_messages administrator right in the channel chat

Parameters:
  • owner_id ("types.MessageSender") – Identifier of the user or the channel chat that received the gifts

  • received_gift_ids (List[str]) – New list of pinned gifts. All gifts must be upgraded and saved on the profile page first. There can be up to getOption("pinned_gift_count_max") pinned gifts

Return type:

Union[Error, Ok]

Returns:

Ok

async setPinnedSavedMessagesTopics(saved_messages_topic_ids=None)[source]

Changes the order of pinned Saved Messages topics

Parameters:

saved_messages_topic_ids (List[int]) – Identifiers of the new pinned Saved Messages topics

Return type:

Union[Error, Ok]

Returns:

Ok

async setPollAnswer(chat_id=0, message_id=0, option_ids=None)[source]

Changes the user answer to a poll. A poll in quiz mode can be answered only once

Parameters:
  • chat_id (int) – Identifier of the chat to which the poll belongs

  • message_id (int) – Identifier of the message containing the poll

  • option_ids (List[int]) – 0-based identifiers of answer options, chosen by the user. User can choose more than 1 answer option only is the poll allows multiple answers

Return type:

Union[Error, Ok]

Returns:

Ok

async setProfileAccentColor(profile_accent_color_id=0, profile_background_custom_emoji_id=0)[source]

Changes accent color and background custom emoji for profile of the current user; for Telegram Premium users only

Parameters:
  • profile_accent_color_id (int) – Identifier of the accent color to use for profile; pass -1 if none

  • profile_background_custom_emoji_id (int) – Identifier of a custom emoji to be shown on the user’s profile photo background; 0 if none

Return type:

Union[Error, Ok]

Returns:

Ok

async setProfileAudioPosition(file_id=0, after_file_id=0)[source]

Changes position of an audio file in the profile audio files of the current user

Parameters:
  • file_id (int) – Identifier of the file from profile audio files, which position will be changed

  • after_file_id (int) – Identifier of the file from profile audio files after which the file will be positioned; pass 0 to move the file to the beginning of the list

Return type:

Union[Error, Ok]

Returns:

Ok

async setProfilePhoto(photo=None, is_public=False)[source]

Changes a profile photo for the current user

Parameters:
  • photo ("types.InputChatPhoto") – Profile photo to set

  • is_public (bool) – Pass true to set the public photo, which will be visible even if the main photo is hidden by privacy settings

Return type:

Union[Error, Ok]

Returns:

Ok

async setQuickReplyShortcutName(shortcut_id=0, name='')[source]

Changes name of a quick reply shortcut

Parameters:
  • shortcut_id (int) – Unique identifier of the quick reply shortcut

  • name (str) – New name for the shortcut. Use checkQuickReplyShortcutName to check its validness

Return type:

Union[Error, Ok]

Returns:

Ok

async setReactionNotificationSettings(notification_settings=None)[source]

Changes notification settings for reactions

Parameters:

notification_settings ("types.ReactionNotificationSettings") – The new notification settings for reactions

Return type:

Union[Error, Ok]

Returns:

Ok

async setReadDatePrivacySettings(settings=None)[source]

Changes privacy settings for message read date

Parameters:

settings ("types.ReadDatePrivacySettings") – New settings

Return type:

Union[Error, Ok]

Returns:

Ok

async setRecoveryEmailAddress(password='', new_recovery_email_address='')[source]

Changes the 2-step verification recovery email address of the user. If a new recovery email address is specified, then the change will not be applied until the new recovery email address is confirmed. If new_recovery_email_address is the same as the email address that is currently set up, this call succeeds immediately and aborts all other requests waiting for an email confirmation

Parameters:
  • password (str) – The 2-step verification password of the current user

  • new_recovery_email_address (str) – New recovery email address

Return type:

Union[Error, PasswordState]

Returns:

PasswordState

async setSavedMessagesTagLabel(tag=None, label='')[source]

Changes label of a Saved Messages tag; for Telegram Premium users only

Parameters:
  • tag ("types.ReactionType") – The tag which label will be changed

  • label (str) – New label for the tag; 0-12 characters

Return type:

Union[Error, Ok]

Returns:

Ok

async setScopeNotificationSettings(scope=None, notification_settings=None)[source]

Changes notification settings for chats of a given type

Parameters:
  • scope ("types.NotificationSettingsScope") – Types of chats for which to change the notification settings

  • notification_settings ("types.ScopeNotificationSettings") – The new notification settings for the given scope

Return type:

Union[Error, Ok]

Returns:

Ok

async setStickerEmojis(sticker=None, emojis='')[source]

Changes the list of emojis corresponding to a sticker. The sticker must belong to a regular or custom emoji sticker set that is owned by the current user

Parameters:
  • sticker ("types.InputFile") – Sticker

  • emojis (str) – New string with 1-20 emoji corresponding to the sticker

Return type:

Union[Error, Ok]

Returns:

Ok

async setStickerKeywords(sticker=None, keywords=None)[source]

Changes the list of keywords of a sticker. The sticker must belong to a regular or custom emoji sticker set that is owned by the current user

Parameters:
  • sticker ("types.InputFile") – Sticker

  • keywords (List[str]) – List of up to 20 keywords with total length up to 64 characters, which can be used to find the sticker

Return type:

Union[Error, Ok]

Returns:

Ok

async setStickerMaskPosition(sticker=None, mask_position=None)[source]

Changes the mask position of a mask sticker. The sticker must belong to a mask sticker set that is owned by the current user

Parameters:
  • sticker ("types.InputFile") – Sticker

  • mask_position ("types.MaskPosition") – Position where the mask is placed; pass null to remove mask position

Return type:

Union[Error, Ok]

Returns:

Ok

async setStickerPositionInSet(sticker=None, position=0)[source]

Changes the position of a sticker in the set to which it belongs. The sticker set must be owned by the current user

Parameters:
  • sticker ("types.InputFile") – Sticker

  • position (int) – New position of the sticker in the set, 0-based

Return type:

Union[Error, Ok]

Returns:

Ok

async setStickerSetThumbnail(user_id=0, name='', thumbnail=None, format=None)[source]

Sets a sticker set thumbnail

Parameters:
  • user_id (int) – Sticker set owner; ignored for regular users

  • name (str) – Sticker set name. The sticker set must be owned by the current user

  • thumbnail ("types.InputFile") – Thumbnail to set; pass null to remove the sticker set thumbnail

  • format ("types.StickerFormat") – Format of the thumbnail; pass null if thumbnail is removed

Return type:

Union[Error, Ok]

Returns:

Ok

async setStickerSetTitle(name='', title='')[source]

Sets a sticker set title

Parameters:
  • name (str) – Sticker set name. The sticker set must be owned by the current user

  • title (str) – New sticker set title

Return type:

Union[Error, Ok]

Returns:

Ok

async setStoryAlbumName(chat_id=0, story_album_id=0, name='')[source]

Changes name of an album of stories. If the album is owned by a supergroup or a channel chat, then requires can_edit_stories administrator right in the chat. Returns the changed album

Parameters:
  • chat_id (int) – Identifier of the chat that owns the stories

  • story_album_id (int) – Identifier of the story album

  • name (str) – New name of the album; 1-12 characters

Return type:

Union[Error, StoryAlbum]

Returns:

StoryAlbum

async setStoryPrivacySettings(story_id=0, privacy_settings=None)[source]

Changes privacy settings of a story. The method can be called only for stories posted on behalf of the current user and if story.can_be_edited == true

Parameters:
  • story_id (int) – Identifier of the story

  • privacy_settings ("types.StoryPrivacySettings") – The new privacy settings for the story

Return type:

Union[Error, Ok]

Returns:

Ok

async setStoryReaction(story_poster_chat_id=0, story_id=0, reaction_type=None, update_recent_reactions=False)[source]

Changes chosen reaction on a story that has already been sent

Parameters:
  • story_poster_chat_id (int) – The identifier of the poster of the story

  • story_id (int) – The identifier of the story

  • reaction_type ("types.ReactionType") – Type of the reaction to set; pass null to remove the reaction. Custom emoji reactions can be used only by Telegram Premium users. Paid reactions can’t be set

  • update_recent_reactions (bool) – Pass true if the reaction needs to be added to recent reactions

Return type:

Union[Error, Ok]

Returns:

Ok

async setSupergroupCustomEmojiStickerSet(supergroup_id=0, custom_emoji_sticker_set_id=0)[source]

Changes the custom emoji sticker set of a supergroup; requires can_change_info administrator right. The chat must have at least chatBoostFeatures.min_custom_emoji_sticker_set_boost_level boost level to pass the corresponding color

Parameters:
  • supergroup_id (int) – Identifier of the supergroup

  • custom_emoji_sticker_set_id (int) – New value of the custom emoji sticker set identifier for the supergroup. Use 0 to remove the custom emoji sticker set in the supergroup

Return type:

Union[Error, Ok]

Returns:

Ok

async setSupergroupMainProfileTab(supergroup_id=0, main_profile_tab=None)[source]

Changes the main profile tab of the channel; requires can_change_info administrator right

Parameters:
  • supergroup_id (int) – Identifier of the channel

  • main_profile_tab ("types.ProfileTab") – The new value of the main profile tab

Return type:

Union[Error, Ok]

Returns:

Ok

async setSupergroupStickerSet(supergroup_id=0, sticker_set_id=0)[source]

Changes the sticker set of a supergroup; requires can_change_info administrator right

Parameters:
  • supergroup_id (int) – Identifier of the supergroup

  • sticker_set_id (int) – New value of the supergroup sticker set identifier. Use 0 to remove the supergroup sticker set

Return type:

Union[Error, Ok]

Returns:

Ok

async setSupergroupUnrestrictBoostCount(supergroup_id=0, unrestrict_boost_count=0)[source]

Changes the number of times the supergroup must be boosted by a user to ignore slow mode and chat permission restrictions; requires can_restrict_members administrator right

Parameters:
  • supergroup_id (int) – Identifier of the supergroup

  • unrestrict_boost_count (int) – New value of the unrestrict_boost_count supergroup setting; 0-8. Use 0 to remove the setting

Return type:

Union[Error, Ok]

Returns:

Ok

async setSupergroupUsername(supergroup_id=0, username='')[source]

Changes the editable username of a supergroup or channel, requires owner privileges in the supergroup or channel

Parameters:
  • supergroup_id (int) – Identifier of the supergroup or channel

  • username (str) – New value of the username. Use an empty string to remove the username. The username can’t be completely removed if there is another active or disabled username

Return type:

Union[Error, Ok]

Returns:

Ok

async setTdlibParameters(use_test_dc=False, database_directory='', files_directory='', database_encryption_key=b'', use_file_database=False, use_chat_info_database=False, use_message_database=False, use_secret_chats=False, api_id=0, api_hash='', system_language_code='', device_model='', system_version='', application_version='')[source]

Sets the parameters for TDLib initialization. Works only when the current authorization state is authorizationStateWaitTdlibParameters

Parameters:
  • use_test_dc (bool) – Pass true to use Telegram test environment instead of the production environment

  • database_directory (str) – The path to the directory for the persistent database; if empty, the current working directory will be used

  • files_directory (str) – The path to the directory for storing files; if empty, database_directory will be used

  • database_encryption_key (bytes) – Encryption key for the database. If the encryption key is invalid, then an error with code 401 will be returned

  • use_file_database (bool) – Pass true to keep information about downloaded and uploaded files between application restarts

  • use_chat_info_database (bool) – Pass true to keep cache of users, basic groups, supergroups, channels and secret chats between restarts. Implies use_file_database

  • use_message_database (bool) – Pass true to keep cache of chats and messages between restarts. Implies use_chat_info_database

  • use_secret_chats (bool) – Pass true to enable support for secret chats

  • api_id (int) – Application identifier for Telegram API access, which can be obtained at https://my.telegram.org

  • api_hash (str) – Application identifier hash for Telegram API access, which can be obtained at https://my.telegram.org

  • system_language_code (str) – IETF language tag of the user’s operating system language; must be non-empty

  • device_model (str) – Model of the device the application is being run on; must be non-empty

  • system_version (str) – Version of the operating system the application is being run on. If empty, the version is automatically detected by TDLib

  • application_version (str) – Application version; must be non-empty

Return type:

Union[Error, Ok]

Returns:

Ok

async setUserEmojiStatus(user_id=0, emoji_status=None)[source]

Changes the emoji status of a user; for bots only

Parameters:
  • user_id (int) – Identifier of the user

  • emoji_status ("types.EmojiStatus") – New emoji status; pass null to switch to the default badge

Return type:

Union[Error, Ok]

Returns:

Ok

async setUserPersonalProfilePhoto(user_id=0, photo=None)[source]

Changes a personal profile photo of a contact user

Parameters:
  • user_id (int) – User identifier

  • photo ("types.InputChatPhoto") – Profile photo to set; pass null to delete the photo; inputChatPhotoPrevious isn’t supported in this function

Return type:

Union[Error, Ok]

Returns:

Ok

async setUserPrivacySettingRules(setting=None, rules=None)[source]

Changes user privacy settings

Parameters:
  • setting ("types.UserPrivacySetting") – The privacy setting

  • rules ("types.UserPrivacySettingRules") – The new privacy rules

Return type:

Union[Error, Ok]

Returns:

Ok

async setUserSupportInfo(user_id=0, message=None)[source]

Sets support information for the given user; for Telegram support only

Parameters:
  • user_id (int) – User identifier

  • message ("types.FormattedText") – New information message

Return type:

Union[Error, UserSupportInfo]

Returns:

UserSupportInfo

async setUsername(username='')[source]

Changes the editable username of the current user

Parameters:

username (str) – The new value of the username. Use an empty string to remove the username. The username can’t be completely removed if there is another active or disabled username

Return type:

Union[Error, Ok]

Returns:

Ok

async setVideoChatDefaultParticipant(chat_id=0, default_participant_id=None)[source]

Changes default participant identifier, on whose behalf a video chat in the chat will be joined

Parameters:
  • chat_id (int) – Chat identifier

  • default_participant_id ("types.MessageSender") – Default group call participant identifier to join the video chats

Return type:

Union[Error, Ok]

Returns:

Ok

async setVideoChatTitle(group_call_id=0, title='')[source]

Sets title of a video chat; requires groupCall.can_be_managed right

Parameters:
  • group_call_id (int) – Group call identifier

  • title (str) – New group call title; 1-64 characters

Return type:

Union[Error, Ok]

Returns:

Ok

async shareChatWithBot(chat_id=0, message_id=0, button_id=0, shared_chat_id=0, only_check=False)[source]

Shares a chat after pressing a keyboardButtonTypeRequestChat button with the bot

Parameters:
  • chat_id (int) – Identifier of the chat with the bot

  • message_id (int) – Identifier of the message with the button

  • button_id (int) – Identifier of the button

  • shared_chat_id (int) – Identifier of the shared chat

  • only_check (bool) – Pass true to check that the chat can be shared by the button instead of actually sharing it. Doesn’t check bot_is_member and bot_administrator_rights restrictions. If the bot must be a member, then all chats from getGroupsInCommon and all chats, where the user can add the bot, are suitable. In the latter case the bot will be automatically added to the chat. If the bot must be an administrator, then all chats, where the bot already has requested rights or can be added to administrators by the user, are suitable. In the latter case the bot will be automatically granted requested rights

Return type:

Union[Error, Ok]

Returns:

Ok

async sharePhoneNumber(user_id=0)[source]

Shares the phone number of the current user with a mutual contact. Supposed to be called when the user clicks on chatActionBarSharePhoneNumber

Parameters:

user_id (int) – Identifier of the user with whom to share the phone number. The user must be a mutual contact

Return type:

Union[Error, Ok]

Returns:

Ok

async shareUsersWithBot(chat_id=0, message_id=0, button_id=0, shared_user_ids=None, only_check=False)[source]

Shares users after pressing a keyboardButtonTypeRequestUsers button with the bot

Parameters:
  • chat_id (int) – Identifier of the chat with the bot

  • message_id (int) – Identifier of the message with the button

  • button_id (int) – Identifier of the button

  • shared_user_ids (List[int]) – Identifiers of the shared users

  • only_check (bool) – Pass true to check that the users can be shared by the button instead of actually sharing them

Return type:

Union[Error, Ok]

Returns:

Ok

async startGroupCallRecording(group_call_id=0, title='', record_video=False, use_portrait_orientation=False)[source]

Starts recording of an active group call; for video chats only. Requires groupCall.can_be_managed right

Parameters:
  • group_call_id (int) – Group call identifier

  • title (str) – Group call recording title; 0-64 characters

  • record_video (bool) – Pass true to record a video file instead of an audio file

  • use_portrait_orientation (bool) – Pass true to use portrait orientation for video instead of landscape one

Return type:

Union[Error, Ok]

Returns:

Ok

async startGroupCallScreenSharing(group_call_id=0, audio_source_id=0, payload='')[source]

Starts screen sharing in a joined group call. Returns join response payload for tgcalls

Parameters:
  • group_call_id (int) – Group call identifier

  • audio_source_id (int) – Screen sharing audio channel synchronization source identifier; received from tgcalls

  • payload (str) – Group call join payload; received from tgcalls

Return type:

Union[Error, Text]

Returns:

Text

async startScheduledVideoChat(group_call_id=0)[source]

Starts a scheduled video chat

Parameters:

group_call_id (int) – Group call identifier of the video chat

Return type:

Union[Error, Ok]

Returns:

Ok

async stopBusinessPoll(business_connection_id='', chat_id=0, message_id=0, reply_markup=None)[source]

Stops a poll sent on behalf of a business account; for bots only

Parameters:
  • business_connection_id (str) – Unique identifier of business connection on behalf of which the message with the poll was sent

  • chat_id (int) – The chat the message belongs to

  • message_id (int) – Identifier of the message containing the poll

  • reply_markup ("types.ReplyMarkup") – The new message reply markup; pass null if none

Return type:

Union[Error, BusinessMessage]

Returns:

BusinessMessage

async stopPoll(chat_id=0, message_id=0, reply_markup=None)[source]

Stops a poll

Parameters:
  • chat_id (int) – Identifier of the chat to which the poll belongs

  • message_id (int) – Identifier of the message containing the poll. Use messageProperties.can_be_edited to check whether the poll can be stopped

  • reply_markup ("types.ReplyMarkup") – The new message reply markup; pass null if none; for bots only

Return type:

Union[Error, Ok]

Returns:

Ok

async suggestUserProfilePhoto(user_id=0, photo=None)[source]

Suggests a profile photo to another regular user with common messages and allowing non-paid messages

Parameters:
  • user_id (int) – User identifier

  • photo ("types.InputChatPhoto") – Profile photo to suggest; inputChatPhotoPrevious isn’t supported in this function

Return type:

Union[Error, Ok]

Returns:

Ok

async synchronizeLanguagePack(language_pack_id='')[source]

Fetches the latest versions of all strings from a language pack in the current localization target from the server. This method doesn’t need to be called explicitly for the current used/base language packs. Can be called before authorization

Parameters:

language_pack_id (str) – Language pack identifier

Return type:

Union[Error, Ok]

Returns:

Ok

async terminateAllOtherSessions()[source]

Terminates all other sessions of the current user

Return type:

Union[Error, Ok]

Returns:

Ok

async terminateSession(session_id=0)[source]

Terminates a session of the current user

Parameters:

session_id (int) – Session identifier

Return type:

Union[Error, Ok]

Returns:

Ok

async testCallBytes(x=b'')[source]

Returns the received bytes; for testing only. This is an offline method. Can be called before authorization

Parameters:

x (bytes) – Bytes to return

Return type:

Union[Error, TestBytes]

Returns:

TestBytes

async testCallEmpty()[source]

Does nothing; for testing only. This is an offline method. Can be called before authorization

Return type:

Union[Error, Ok]

Returns:

Ok

async testCallString(x='')[source]

Returns the received string; for testing only. This is an offline method. Can be called before authorization

Parameters:

x (str) – String to return

Return type:

Union[Error, TestString]

Returns:

TestString

async testCallVectorInt(x=None)[source]

Returns the received vector of numbers; for testing only. This is an offline method. Can be called before authorization

Parameters:

x (List[int]) – Vector of numbers to return

Return type:

Union[Error, TestVectorInt]

Returns:

TestVectorInt

async testCallVectorIntObject(x=None)[source]

Returns the received vector of objects containing a number; for testing only. This is an offline method. Can be called before authorization

Parameters:

x (List["types.TestInt"]) – Vector of objects to return

Return type:

Union[Error, TestVectorIntObject]

Returns:

TestVectorIntObject

async testCallVectorString(x=None)[source]

Returns the received vector of strings; for testing only. This is an offline method. Can be called before authorization

Parameters:

x (List[str]) – Vector of strings to return

Return type:

Union[Error, TestVectorString]

Returns:

TestVectorString

async testCallVectorStringObject(x=None)[source]

Returns the received vector of objects containing a string; for testing only. This is an offline method. Can be called before authorization

Parameters:

x (List["types.TestString"]) – Vector of objects to return

Return type:

Union[Error, TestVectorStringObject]

Returns:

TestVectorStringObject

async testGetDifference()[source]

Forces an updates.getDifference call to the Telegram servers; for testing only

Return type:

Union[Error, Ok]

Returns:

Ok

async testNetwork()[source]

Sends a simple network request to the Telegram servers; for testing only. Can be called before authorization

Return type:

Union[Error, Ok]

Returns:

Ok

async testProxy(server='', port=0, type=None, dc_id=0, timeout=0.0)[source]

Sends a simple network request to the Telegram servers via proxy; for testing only. Can be called before authorization

Parameters:
  • server (str) – Proxy server domain or IP address

  • port (int) – Proxy server port

  • type ("types.ProxyType") – Proxy type

  • dc_id (int) – Identifier of a datacenter with which to test connection

  • timeout (float) – The maximum overall timeout for the request

Return type:

Union[Error, Ok]

Returns:

Ok

async testReturnError(error=None)[source]

Returns the specified error and ensures that the Error object is used; for testing only. Can be called synchronously

Parameters:

error ("types.Error") – The error to be returned

Return type:

Error

Returns:

Error

async testSquareInt(x=0)[source]

Returns the squared received number; for testing only. This is an offline method. Can be called before authorization

Parameters:

x (int) – Number to square

Return type:

Union[Error, TestInt]

Returns:

TestInt

async testUseUpdate()[source]

Does nothing and ensures that the Update object is used; for testing only. This is an offline method. Can be called before authorization

Return type:

Union[Error, Update]

Returns:

Update

async toggleAllDownloadsArePaused(are_paused=False)[source]

Changes pause state of all files in the file download list

Parameters:

are_paused (bool) – Pass true to pause all downloads; pass false to unpause them

Return type:

Union[Error, Ok]

Returns:

Ok

async toggleBotCanManageEmojiStatus(bot_user_id=0, can_manage_emoji_status=False)[source]

Toggles whether the bot can manage emoji status of the current user

Parameters:
  • bot_user_id (int) – User identifier of the bot

  • can_manage_emoji_status (bool) – Pass true if the bot is allowed to change emoji status of the user; pass false otherwise

Return type:

Union[Error, Ok]

Returns:

Ok

async toggleBotIsAddedToAttachmentMenu(bot_user_id=0, is_added=False, allow_write_access=False)[source]

Adds or removes a bot to attachment and side menu. Bot can be added to the menu, only if userTypeBot.can_be_added_to_attachment_menu == true

Parameters:
  • bot_user_id (int) – Bot’s user identifier

  • is_added (bool) – Pass true to add the bot to attachment menu; pass false to remove the bot from attachment menu

  • allow_write_access (bool) – Pass true if the current user allowed the bot to send them messages. Ignored if is_added is false

Return type:

Union[Error, Ok]

Returns:

Ok

async toggleBotUsernameIsActive(bot_user_id=0, username='', is_active=False)[source]

Changes active state for a username of a bot. The editable username can’t be disabled. May return an error with a message "USERNAMES_ACTIVE_TOO_MUCH" if the maximum number of active usernames has been reached. Can be called only if userTypeBot.can_be_edited == true

Parameters:
  • bot_user_id (int) – Identifier of the target bot

  • username (str) – The username to change

  • is_active (bool) – Pass true to activate the username; pass false to disable it

Return type:

Union[Error, Ok]

Returns:

Ok

async toggleBusinessConnectedBotChatIsPaused(chat_id=0, is_paused=False)[source]

Pauses or resumes the connected business bot in a specific chat

Parameters:
  • chat_id (int) – Chat identifier

  • is_paused (bool) – Pass true to pause the connected bot in the chat; pass false to resume the bot

Return type:

Union[Error, Ok]

Returns:

Ok

async toggleChatDefaultDisableNotification(chat_id=0, default_disable_notification=False)[source]

Changes the value of the default disable_notification parameter, used when a message is sent to a chat

Parameters:
  • chat_id (int) – Chat identifier

  • default_disable_notification (bool) – New value of default_disable_notification

Return type:

Union[Error, Ok]

Returns:

Ok

async toggleChatFolderTags(are_tags_enabled=False)[source]

Toggles whether chat folder tags are enabled

Parameters:

are_tags_enabled (bool) – Pass true to enable folder tags; pass false to disable them

Return type:

Union[Error, Ok]

Returns:

Ok

async toggleChatGiftNotifications(chat_id=0, are_enabled=False)[source]

Toggles whether notifications for new gifts received by a channel chat are sent to the current user; requires can_post_messages administrator right in the chat

Parameters:
  • chat_id (int) – Identifier of the channel chat

  • are_enabled (bool) – Pass true to enable notifications about new gifts owned by the channel chat; pass false to disable the notifications

Return type:

Union[Error, Ok]

Returns:

Ok

async toggleChatHasProtectedContent(chat_id=0, has_protected_content=False)[source]

Changes the ability of users to save, forward, or copy chat content. Supported only for basic groups, supergroups and channels. Requires owner privileges

Parameters:
  • chat_id (int) – Chat identifier

  • has_protected_content (bool) – New value of has_protected_content

Return type:

Union[Error, Ok]

Returns:

Ok

async toggleChatIsMarkedAsUnread(chat_id=0, is_marked_as_unread=False)[source]

Changes the marked as unread state of a chat

Parameters:
  • chat_id (int) – Chat identifier

  • is_marked_as_unread (bool) – New value of is_marked_as_unread

Return type:

Union[Error, Ok]

Returns:

Ok

async toggleChatIsPinned(chat_list=None, chat_id=0, is_pinned=False)[source]

Changes the pinned state of a chat. There can be up to getOption("pinned_chat_count_max")/getOption("pinned_archived_chat_count_max") pinned non-secret chats and the same number of secret chats in the main/archive chat list. The limit can be increased with Telegram Premium

Parameters:
  • chat_list ("types.ChatList") – Chat list in which to change the pinned state of the chat

  • chat_id (int) – Chat identifier

  • is_pinned (bool) – Pass true to pin the chat; pass false to unpin it

Return type:

Union[Error, Ok]

Returns:

Ok

async toggleChatIsTranslatable(chat_id=0, is_translatable=False)[source]

Changes the translatable state of a chat

Parameters:
  • chat_id (int) – Chat identifier

  • is_translatable (bool) – New value of is_translatable

Return type:

Union[Error, Ok]

Returns:

Ok

async toggleChatViewAsTopics(chat_id=0, view_as_topics=False)[source]

Changes the view_as_topics setting of a forum chat or Saved Messages

Parameters:
  • chat_id (int) – Chat identifier

  • view_as_topics (bool) – New value of view_as_topics

Return type:

Union[Error, Ok]

Returns:

Ok

async toggleDirectMessagesChatTopicCanSendUnpaidMessages(chat_id=0, topic_id=0, can_send_unpaid_messages=False, refund_payments=False)[source]

Allows to send unpaid messages to the given topic of the channel direct messages chat administered by the current user

Parameters:
  • chat_id (int) – Chat identifier

  • topic_id (int) – Identifier of the topic

  • can_send_unpaid_messages (bool) – Pass true to allow unpaid messages; pass false to disallow unpaid messages

  • refund_payments (bool) – Pass true to refund the user previously paid messages

Return type:

Union[Error, Ok]

Returns:

Ok

async toggleDownloadIsPaused(file_id=0, is_paused=False)[source]

Changes pause state of a file in the file download list

Parameters:
  • file_id (int) – Identifier of the downloaded file

  • is_paused (bool) – Pass true if the download is paused

Return type:

Union[Error, Ok]

Returns:

Ok

async toggleForumTopicIsClosed(chat_id=0, message_thread_id=0, is_closed=False)[source]

Toggles whether a topic is closed in a forum supergroup chat; requires can_manage_topics administrator right in the supergroup unless the user is creator of the topic

Parameters:
  • chat_id (int) – Identifier of the chat

  • message_thread_id (int) – Message thread identifier of the forum topic

  • is_closed (bool) – Pass true to close the topic; pass false to reopen it

Return type:

Union[Error, Ok]

Returns:

Ok

async toggleForumTopicIsPinned(chat_id=0, message_thread_id=0, is_pinned=False)[source]

Changes the pinned state of a forum topic; requires can_manage_topics administrator right in the supergroup. There can be up to getOption("pinned_forum_topic_count_max") pinned forum topics

Parameters:
  • chat_id (int) – Chat identifier

  • message_thread_id (int) – Message thread identifier of the forum topic

  • is_pinned (bool) – Pass true to pin the topic; pass false to unpin it

Return type:

Union[Error, Ok]

Returns:

Ok

async toggleGeneralForumTopicIsHidden(chat_id=0, is_hidden=False)[source]

Toggles whether a General topic is hidden in a forum supergroup chat; requires can_manage_topics administrator right in the supergroup

Parameters:
  • chat_id (int) – Identifier of the chat

  • is_hidden (bool) – Pass true to hide and close the General topic; pass false to unhide it

Return type:

Union[Error, Ok]

Returns:

Ok

async toggleGiftIsSaved(received_gift_id='', is_saved=False)[source]

Toggles whether a gift is shown on the current user’s or the channel’s profile page; requires can_post_messages administrator right in the channel chat

Parameters:
  • received_gift_id (str) – Identifier of the gift

  • is_saved (bool) – Pass true to display the gift on the user’s or the channel’s profile page; pass false to remove it from the profile page

Return type:

Union[Error, Ok]

Returns:

Ok

async toggleGroupCallIsMyVideoEnabled(group_call_id=0, is_my_video_enabled=False)[source]

Toggles whether current user’s video is enabled

Parameters:
  • group_call_id (int) – Group call identifier

  • is_my_video_enabled (bool) – Pass true if the current user’s video is enabled

Return type:

Union[Error, Ok]

Returns:

Ok

async toggleGroupCallIsMyVideoPaused(group_call_id=0, is_my_video_paused=False)[source]

Toggles whether current user’s video is paused

Parameters:
  • group_call_id (int) – Group call identifier

  • is_my_video_paused (bool) – Pass true if the current user’s video is paused

Return type:

Union[Error, Ok]

Returns:

Ok

async toggleGroupCallParticipantIsHandRaised(group_call_id=0, participant_id=None, is_hand_raised=False)[source]

Toggles whether a group call participant hand is rased; for video chats only

Parameters:
  • group_call_id (int) – Group call identifier

  • participant_id ("types.MessageSender") – Participant identifier

  • is_hand_raised (bool) – Pass true if the user’s hand needs to be raised. Only self hand can be raised. Requires groupCall.can_be_managed right to lower other’s hand

Return type:

Union[Error, Ok]

Returns:

Ok

async toggleGroupCallParticipantIsMuted(group_call_id=0, participant_id=None, is_muted=False)[source]

Toggles whether a participant of an active group call is muted, unmuted, or allowed to unmute themselves

Parameters:
  • group_call_id (int) – Group call identifier

  • participant_id ("types.MessageSender") – Participant identifier

  • is_muted (bool) – Pass true to mute the user; pass false to unmute them

Return type:

Union[Error, Ok]

Returns:

Ok

async toggleGroupCallScreenSharingIsPaused(group_call_id=0, is_paused=False)[source]

Pauses or unpauses screen sharing in a joined group call

Parameters:
  • group_call_id (int) – Group call identifier

  • is_paused (bool) – Pass true to pause screen sharing; pass false to unpause it

Return type:

Union[Error, Ok]

Returns:

Ok

async toggleHasSponsoredMessagesEnabled(has_sponsored_messages_enabled=False)[source]

Toggles whether the current user has sponsored messages enabled. The setting has no effect for users without Telegram Premium for which sponsored messages are always enabled

Parameters:

has_sponsored_messages_enabled (bool) – Pass true to enable sponsored messages for the current user; false to disable them

Return type:

Union[Error, Ok]

Returns:

Ok

async toggleSavedMessagesTopicIsPinned(saved_messages_topic_id=0, is_pinned=False)[source]

Changes the pinned state of a Saved Messages topic. There can be up to getOption("pinned_saved_messages_topic_count_max") pinned topics. The limit can be increased with Telegram Premium

Parameters:
  • saved_messages_topic_id (int) – Identifier of Saved Messages topic to pin or unpin

  • is_pinned (bool) – Pass true to pin the topic; pass false to unpin it

Return type:

Union[Error, Ok]

Returns:

Ok

async toggleSessionCanAcceptCalls(session_id=0, can_accept_calls=False)[source]

Toggles whether a session can accept incoming calls

Parameters:
  • session_id (int) – Session identifier

  • can_accept_calls (bool) – Pass true to allow accepting incoming calls by the session; pass false otherwise

Return type:

Union[Error, Ok]

Returns:

Ok

async toggleSessionCanAcceptSecretChats(session_id=0, can_accept_secret_chats=False)[source]

Toggles whether a session can accept incoming secret chats

Parameters:
  • session_id (int) – Session identifier

  • can_accept_secret_chats (bool) – Pass true to allow accepting secret chats by the session; pass false otherwise

Return type:

Union[Error, Ok]

Returns:

Ok

async toggleStoryIsPostedToChatPage(story_poster_chat_id=0, story_id=0, is_posted_to_chat_page=False)[source]

Toggles whether a story is accessible after expiration. Can be called only if story.can_toggle_is_posted_to_chat_page == true

Parameters:
  • story_poster_chat_id (int) – Identifier of the chat that posted the story

  • story_id (int) – Identifier of the story

  • is_posted_to_chat_page (bool) – Pass true to make the story accessible after expiration; pass false to make it private

Return type:

Union[Error, Ok]

Returns:

Ok

async toggleSupergroupCanHaveSponsoredMessages(supergroup_id=0, can_have_sponsored_messages=False)[source]

Toggles whether sponsored messages are shown in the channel chat; requires owner privileges in the channel. The chat must have at least chatBoostFeatures.min_sponsored_message_disable_boost_level boost level to disable sponsored messages

Parameters:
  • supergroup_id (int) – The identifier of the channel

  • can_have_sponsored_messages (bool) – The new value of can_have_sponsored_messages

Return type:

Union[Error, Ok]

Returns:

Ok

async toggleSupergroupHasAggressiveAntiSpamEnabled(supergroup_id=0, has_aggressive_anti_spam_enabled=False)[source]

Toggles whether aggressive anti-spam checks are enabled in the supergroup. Can be called only if supergroupFullInfo.can_toggle_aggressive_anti_spam == true

Parameters:
  • supergroup_id (int) – The identifier of the supergroup, which isn’t a broadcast group

  • has_aggressive_anti_spam_enabled (bool) – The new value of has_aggressive_anti_spam_enabled

Return type:

Union[Error, Ok]

Returns:

Ok

async toggleSupergroupHasAutomaticTranslation(supergroup_id=0, has_automatic_translation=False)[source]

Toggles whether messages are automatically translated in the channel chat; requires can_change_info administrator right in the channel. The chat must have at least chatBoostFeatures.min_automatic_translation_boost_level boost level to enable automatic translation

Parameters:
  • supergroup_id (int) – The identifier of the channel

  • has_automatic_translation (bool) – The new value of has_automatic_translation

Return type:

Union[Error, Ok]

Returns:

Ok

async toggleSupergroupHasHiddenMembers(supergroup_id=0, has_hidden_members=False)[source]

Toggles whether non-administrators can receive only administrators and bots using getSupergroupMembers or searchChatMembers. Can be called only if supergroupFullInfo.can_hide_members == true

Parameters:
  • supergroup_id (int) – Identifier of the supergroup

  • has_hidden_members (bool) – New value of has_hidden_members

Return type:

Union[Error, Ok]

Returns:

Ok

async toggleSupergroupIsAllHistoryAvailable(supergroup_id=0, is_all_history_available=False)[source]

Toggles whether the message history of a supergroup is available to new members; requires can_change_info member right

Parameters:
  • supergroup_id (int) – The identifier of the supergroup

  • is_all_history_available (bool) – The new value of is_all_history_available

Return type:

Union[Error, Ok]

Returns:

Ok

async toggleSupergroupIsBroadcastGroup(supergroup_id=0)[source]

Upgrades supergroup to a broadcast group; requires owner privileges in the supergroup

Parameters:

supergroup_id (int) – Identifier of the supergroup

Return type:

Union[Error, Ok]

Returns:

Ok

async toggleSupergroupIsForum(supergroup_id=0, is_forum=False, has_forum_tabs=False)[source]

Toggles whether the supergroup is a forum; requires owner privileges in the supergroup. Discussion supergroups can’t be converted to forums

Parameters:
  • supergroup_id (int) – Identifier of the supergroup

  • is_forum (bool) – New value of is_forum

  • has_forum_tabs (bool) – New value of has_forum_tabs; ignored if is_forum is false

Return type:

Union[Error, Ok]

Returns:

Ok

async toggleSupergroupJoinByRequest(supergroup_id=0, join_by_request=False)[source]

Toggles whether all users directly joining the supergroup need to be approved by supergroup administrators; requires can_restrict_members administrator right

Parameters:
  • supergroup_id (int) – Identifier of the supergroup that isn’t a broadcast group

  • join_by_request (bool) – New value of join_by_request

Return type:

Union[Error, Ok]

Returns:

Ok

async toggleSupergroupJoinToSendMessages(supergroup_id=0, join_to_send_messages=False)[source]

Toggles whether joining is mandatory to send messages to a discussion supergroup; requires can_restrict_members administrator right

Parameters:
  • supergroup_id (int) – Identifier of the supergroup that isn’t a broadcast group

  • join_to_send_messages (bool) – New value of join_to_send_messages

Return type:

Union[Error, Ok]

Returns:

Ok

async toggleSupergroupSignMessages(supergroup_id=0, sign_messages=False, show_message_sender=False)[source]

Toggles whether sender signature or link to the account is added to sent messages in a channel; requires can_change_info member right

Parameters:
  • supergroup_id (int) – Identifier of the channel

  • sign_messages (bool) – New value of sign_messages

  • show_message_sender (bool) – New value of show_message_sender

Return type:

Union[Error, Ok]

Returns:

Ok

async toggleSupergroupUsernameIsActive(supergroup_id=0, username='', is_active=False)[source]

Changes active state for a username of a supergroup or channel, requires owner privileges in the supergroup or channel. The editable username can’t be disabled. May return an error with a message "USERNAMES_ACTIVE_TOO_MUCH" if the maximum number of active usernames has been reached

Parameters:
  • supergroup_id (int) – Identifier of the supergroup or channel

  • username (str) – The username to change

  • is_active (bool) – Pass true to activate the username; pass false to disable it

Return type:

Union[Error, Ok]

Returns:

Ok

async toggleUsernameIsActive(username='', is_active=False)[source]

Changes active state for a username of the current user. The editable username can’t be disabled. May return an error with a message "USERNAMES_ACTIVE_TOO_MUCH" if the maximum number of active usernames has been reached

Parameters:
  • username (str) – The username to change

  • is_active (bool) – Pass true to activate the username; pass false to disable it

Return type:

Union[Error, Ok]

Returns:

Ok

async toggleVideoChatEnabledStartNotification(group_call_id=0, enabled_start_notification=False)[source]

Toggles whether the current user will receive a notification when the video chat starts; for scheduled video chats only

Parameters:
  • group_call_id (int) – Group call identifier

  • enabled_start_notification (bool) – New value of the enabled_start_notification setting

Return type:

Union[Error, Ok]

Returns:

Ok

async toggleVideoChatMuteNewParticipants(group_call_id=0, mute_new_participants=False)[source]

Toggles whether new participants of a video chat can be unmuted only by administrators of the video chat. Requires groupCall.can_toggle_mute_new_participants right

Parameters:
  • group_call_id (int) – Group call identifier

  • mute_new_participants (bool) – New value of the mute_new_participants setting

Return type:

Union[Error, Ok]

Returns:

Ok

async transferBusinessAccountStars(business_connection_id='', star_count=0)[source]

Transfer Telegram Stars from the business account to the business bot; for bots only

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

  • star_count (int) – Number of Telegram Stars to transfer

Return type:

Union[Error, Ok]

Returns:

Ok

async transferChatOwnership(chat_id=0, user_id=0, password='')[source]

Changes the owner of a chat; requires owner privileges in the chat. Use the method canTransferOwnership to check whether the ownership can be transferred from the current session. Available only for supergroups and channel chats

Parameters:
  • chat_id (int) – Chat identifier

  • user_id (int) – Identifier of the user to which transfer the ownership. The ownership can’t be transferred to a bot or to a deleted user

  • password (str) – The 2-step verification password of the current user

Return type:

Union[Error, Ok]

Returns:

Ok

async transferGift(business_connection_id='', received_gift_id='', new_owner_id=None, star_count=0)[source]

Sends an upgraded gift to another user or channel chat

Parameters:
  • business_connection_id (str) – Unique identifier of business connection on behalf of which to send the request; for bots only

  • received_gift_id (str) – Identifier of the gift

  • new_owner_id ("types.MessageSender") – Identifier of the user or the channel chat that will receive the gift

  • star_count (int) – The amount of Telegram Stars required to pay for the transfer

Return type:

Union[Error, Ok]

Returns:

Ok

async translateMessageText(chat_id=0, message_id=0, to_language_code='')[source]

Extracts text or caption of the given message and translates it to the given language. If the current user is a Telegram Premium user, then text formatting is preserved

Parameters:
  • chat_id (int) – Identifier of the chat to which the message belongs

  • message_id (int) – Identifier of the message

  • to_language_code (str) – Language code of the language to which the message is translated. Must be one of "af", "sq", "am", "ar", "hy", "az", "eu", "be", "bn", "bs", "bg", "ca", "ceb", "zh-CN", "zh", "zh-Hans", "zh-TW", "zh-Hant", "co", "hr", "cs", "da", "nl", "en", "eo", "et", "fi", "fr", "fy", "gl", "ka", "de", "el", "gu", "ht", "ha", "haw", "he", "iw", "hi", "hmn", "hu", "is", "ig", "id", "in", "ga", "it", "ja", "jv", "kn", "kk", "km", "rw", "ko", "ku", "ky", "lo", "la", "lv", "lt", "lb", "mk", "mg", "ms", "ml", "mt", "mi", "mr", "mn", "my", "ne", "no", "ny", "or", "ps", "fa", "pl", "pt", "pa", "ro", "ru", "sm", "gd", "sr", "st", "sn", "sd", "si", "sk", "sl", "so", "es", "su", "sw", "sv", "tl", "tg", "ta", "tt", "te", "th", "tr", "tk", "uk", "ur", "ug", "uz", "vi", "cy", "xh", "yi", "ji", "yo", "zu"

Return type:

Union[Error, FormattedText]

Returns:

FormattedText

async translateText(text=None, to_language_code='')[source]

Translates a text to the given language. If the current user is a Telegram Premium user, then text formatting is preserved

Parameters:
  • text ("types.FormattedText") – Text to translate

  • to_language_code (str) – Language code of the language to which the message is translated. Must be one of "af", "sq", "am", "ar", "hy", "az", "eu", "be", "bn", "bs", "bg", "ca", "ceb", "zh-CN", "zh", "zh-Hans", "zh-TW", "zh-Hant", "co", "hr", "cs", "da", "nl", "en", "eo", "et", "fi", "fr", "fy", "gl", "ka", "de", "el", "gu", "ht", "ha", "haw", "he", "iw", "hi", "hmn", "hu", "is", "ig", "id", "in", "ga", "it", "ja", "jv", "kn", "kk", "km", "rw", "ko", "ku", "ky", "lo", "la", "lv", "lt", "lb", "mk", "mg", "ms", "ml", "mt", "mi", "mr", "mn", "my", "ne", "no", "ny", "or", "ps", "fa", "pl", "pt", "pa", "ro", "ru", "sm", "gd", "sr", "st", "sn", "sd", "si", "sk", "sl", "so", "es", "su", "sw", "sv", "tl", "tg", "ta", "tt", "te", "th", "tr", "tk", "uk", "ur", "ug", "uz", "vi", "cy", "xh", "yi", "ji", "yo", "zu"

Return type:

Union[Error, FormattedText]

Returns:

FormattedText

async unpinAllChatMessages(chat_id=0)[source]

Removes all pinned messages from a chat; requires can_pin_messages member right if the chat is a basic group or supergroup, or can_edit_messages administrator right if the chat is a channel

Parameters:

chat_id (int) – Identifier of the chat

Return type:

Union[Error, Ok]

Returns:

Ok

async unpinAllDirectMessagesChatTopicMessages(chat_id=0, topic_id=0)[source]

Removes all pinned messages from the topic in a channel direct messages chat administered by the current user

Parameters:
  • chat_id (int) – Identifier of the chat

  • topic_id (int) – Topic identifier

Return type:

Union[Error, Ok]

Returns:

Ok

async unpinAllMessageThreadMessages(chat_id=0, message_thread_id=0)[source]

Removes all pinned messages from a forum topic; requires can_pin_messages member right in the supergroup

Parameters:
  • chat_id (int) – Identifier of the chat

  • message_thread_id (int) – Message thread identifier in which messages will be unpinned

Return type:

Union[Error, Ok]

Returns:

Ok

async unpinChatMessage(chat_id=0, message_id=0)[source]

Removes a pinned message from a chat; requires can_pin_messages member right if the chat is a basic group or supergroup, or can_edit_messages administrator right if the chat is a channel

Parameters:
  • chat_id (int) – Identifier of the chat

  • message_id (int) – Identifier of the removed pinned message

Return type:

Union[Error, Ok]

Returns:

Ok

async upgradeBasicGroupChatToSupergroupChat(chat_id=0)[source]

Creates a new supergroup from an existing basic group and sends a corresponding messageChatUpgradeTo and messageChatUpgradeFrom; requires owner privileges. Deactivates the original basic group

Parameters:

chat_id (int) – Identifier of the chat to upgrade

Return type:

Union[Error, Chat]

Returns:

Chat

async upgradeGift(business_connection_id='', received_gift_id='', keep_original_details=False, star_count=0)[source]

Upgrades a regular gift

Parameters:
  • business_connection_id (str) – Unique identifier of business connection on behalf of which to send the request; for bots only

  • received_gift_id (str) – Identifier of the gift

  • keep_original_details (bool) – Pass true to keep the original gift text, sender and receiver in the upgraded gift

  • star_count (int) – The amount of Telegram Stars required to pay for the upgrade. It the gift has prepaid_upgrade_star_count > 0, then pass 0, otherwise, pass gift.upgrade_star_count

Return type:

Union[Error, UpgradeGiftResult]

Returns:

UpgradeGiftResult

async uploadStickerFile(user_id=0, sticker_format=None, sticker=None)[source]

Uploads a file with a sticker; returns the uploaded file

Parameters:
  • user_id (int) – Sticker file owner; ignored for regular users

  • sticker_format ("types.StickerFormat") – Sticker format

  • sticker ("types.InputFile") – File file to upload; must fit in a 512x512 square. For WEBP stickers the file must be in WEBP or PNG format, which will be converted to WEBP server-side. See https://core.telegram.org/animated_stickers#technical-requirements for technical requirements

Return type:

Union[Error, File]

Returns:

File

async validateOrderInfo(input_invoice=None, order_info=None, allow_save=False)[source]

Validates the order information provided by a user and returns the available shipping options for a flexible invoice

Parameters:
  • input_invoice ("types.InputInvoice") – The invoice

  • order_info ("types.OrderInfo") – The order information, provided by the user; pass null if empty

  • allow_save (bool) – Pass true to save the order information

Return type:

Union[Error, ValidatedOrderInfo]

Returns:

ValidatedOrderInfo

async viewMessages(chat_id=0, message_ids=None, source=None, force_read=False)[source]

Informs TDLib that messages are being viewed by the user. Sponsored messages must be marked as viewed only when the entire text of the message is shown on the screen (excluding the button). Many useful activities depend on whether the messages are currently being viewed or not (e.g., marking messages as read, incrementing a view counter, updating a view counter, removing deleted messages in supergroups and channels)

Parameters:
  • chat_id (int) – Chat identifier

  • message_ids (List[int]) – The identifiers of the messages being viewed

  • source ("types.MessageSource") – Source of the message view; pass null to guess the source based on chat open state

  • force_read (bool) – Pass true to mark as read the specified messages even if the chat is closed

Return type:

Union[Error, Ok]

Returns:

Ok

async viewPremiumFeature(feature=None)[source]

Informs TDLib that the user viewed detailed information about a Premium feature on the Premium features screen

Parameters:

feature ("types.PremiumFeature") – The viewed premium feature

Return type:

Union[Error, Ok]

Returns:

Ok

async viewSponsoredChat(sponsored_chat_unique_id=0)[source]

Informs TDLib that the user fully viewed a sponsored chat

Parameters:

sponsored_chat_unique_id (int) – Unique identifier of the sponsored chat

Return type:

Union[Error, Ok]

Returns:

Ok

async viewTrendingStickerSets(sticker_set_ids=None)[source]

Informs the server that some trending sticker sets have been viewed by the user

Parameters:

sticker_set_ids (List[int]) – Identifiers of viewed trending sticker sets

Return type:

Union[Error, Ok]

Returns:

Ok

async viewVideoMessageAdvertisement(advertisement_unique_id=0)[source]

Informs TDLib that the user viewed a video message advertisement

Parameters:

advertisement_unique_id (int) – Unique identifier of the advertisement

Return type:

Union[Error, Ok]

Returns:

Ok

async writeGeneratedFilePart(generation_id=0, offset=0, data=b'')[source]

Writes a part of a generated file. This method is intended to be used only if the application has no direct access to TDLib’s file system, because it is usually slower than a direct write to the destination file

Parameters:
  • generation_id (int) – The identifier of the generation process

  • offset (int) – The offset from which to write the data to the file

  • data (bytes) – The data to write

Return type:

Union[Error, Ok]

Returns:

Ok