pytdbot.methods.td_functions
- class pytdbot.methods.td_functions.TDLibFunctions[source]
Bases:
object
A class that include all TDLib functions
- 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
- 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 Applanguage_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 getLocalizationTargetInfocontent (
"types.InputStoryContent"
) – Content of the added preview
- Return type:
Union
[Error
,BotMediaPreview
]- Returns:
- async addChatFolderByInviteLink(invite_link='', chat_ids=None)[source]
Adds a chat folder by an invite link
- 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 identifieruser_id (
int
) – Identifier of the userforward_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:
- 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 identifieruser_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:
- 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
- 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 messagemessage_id (
int
) – Identifier of the message containing the checklist. Use messageProperties.can_add_tasks to check whether the tasks can be addedtasks (
List["types.InputChecklistTask"]
) – List of added tasks
- Return type:
- Returns:
- 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 ignoredshare_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:
- Returns:
- 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
- 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
- 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 downloadchat_id (
int
) – Chat identifier of the message with the filemessage_id (
int
) – Message identifierpriority (
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:
- Returns:
- 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 collectioncollection_id (
int
) – Identifier of the gift collectionreceived_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:
- 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 supportedsender_id (
"types.MessageSender"
) – Identifier of the sender of the messagereply_to (
"types.InputMessageReplyTo"
) – Information about the message or story to be replied; pass null if nonedisable_notification (
bool
) – Pass true to disable notification for the messageinput_message_content (
"types.InputMessageContent"
) – The content of the message to be added
- Return type:
- Returns:
- async addLogMessage(verbosity_level=0, text='')[source]
Adds a message to TDLib internal log. Can be called synchronously
- 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 belongsmessage_id (
int
) – Identifier of the messagereaction_type (
"types.ReactionType"
) – Type of the reaction to add. Use addPendingPaidMessageReaction instead to add the paid reactionis_big (
bool
) – Pass true if the reaction is added with a big animationupdate_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:
- Returns:
- async addNetworkStatistics(entry=None)[source]
Adds the specified data to data usage statistics. Can be called before authorization
- 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 chatmessage_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 changedoptions (
"types.MessageSendOptions"
) – Options to be used to send the message. New information about the suggested post must always be specified
- Return type:
- Returns:
- 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 belongsmessage_id (
int
) – Identifier of the messagestar_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:
- Returns:
- async addProfileAudio(file_id=0)[source]
Adds an audio file to the beginning of the profile audio files of the current user
- async addProxy(server='', port=0, enable=False, type=None)[source]
Adds a proxy server for network requests. Can be called before authorization
- 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 shortcutreply_to_message_id (
int
) – Identifier of a quick reply message in the same shortcut to be replied; pass 0 if nonequery_id (
int
) – Identifier of the inline queryresult_id (
str
) – Identifier of the inline query resulthide_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:
- 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 shortcutreply_to_message_id (
int
) – Identifier of a quick reply message in the same shortcut to be replied; pass 0 if noneinput_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:
- 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 shortcutreply_to_message_id (
int
) – Identifier of a quick reply message in the same shortcut to be replied; pass 0 if noneinput_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:
- 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 stickerssticker (
"types.InputFile"
) – Sticker file to add
- Return type:
- Returns:
- 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
- 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
- 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:
- 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 usersname (
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 otherwisesticker (
"types.InputSticker"
) – Sticker to add to the set
- Return type:
- Returns:
- 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 storiesstory_album_id (
int
) – Identifier of the story albumstory_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:
- async allowBotToSendMessages(bot_user_id=0)[source]
Allows the specified bot to send messages to the user
- 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
- 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 querytext (
str
) – Text of the answershow_alert (
bool
) – Pass true to show an alert to the user instead of a toast notificationurl (
str
) – URL to be openedcache_time (
int
) – Time during which the result of the query can be cached, in seconds
- Return type:
- Returns:
- 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 queryis_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 querybutton (
"types.InlineQueryResultsButton"
) – Button to be shown above inline query results; pass null if noneresults (
List["types.InputInlineQueryResult"]
) – The results of the querycache_time (
int
) – Allowed time to cache the results of the query, in secondsnext_offset (
str
) – Offset for the next inline query; pass an empty string if there are no more results
- Return type:
- Returns:
- async answerPreCheckoutQuery(pre_checkout_query_id=0, error_message='')[source]
Sets the result of a pre-checkout query; for bots only
- async answerShippingQuery(shipping_query_id=0, shipping_options=None, error_message='')[source]
Sets the result of a shipping query; for bots only
- 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 queryresult (
"types.InputInlineQueryResult"
) – The result of the query
- Return type:
Union
[Error
,SentWebAppMessage
]- Returns:
- 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 chatmessage_id (
int
) – Identifier of the message with the suggested post. Use messageProperties.can_be_approved to check whether the suggested post can be approvedsend_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:
- Returns:
- async assignStoreTransaction(transaction=None, purpose=None)[source]
Informs server about an in-store purchase. For official applications only
- 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 identifiermember_id (
"types.MessageSender"
) – Member identifierbanned_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 bannedrevoke_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:
- Returns:
- 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
- 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 chatdelete_message (
bool
) – Pass true to delete the messagedelete_all_messages (
bool
) – Pass true to delete all messages from the same senderreport_spam (
bool
) – Pass true to report the sender to the Telegram moderators
- Return type:
- Returns:
- 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 chatslot_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:
- 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 giftprepaid_upgrade_hash (
str
) – Prepaid upgrade hash as received along with the giftstar_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:
- Returns:
- 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
- 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:
- 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
- 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:
- 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 useronly_local (
bool
) – Pass true to get only locally available information without sending network requests
- Return type:
Union
[Error
,CanSendMessageToUserResult
]- Returns:
- 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:
- 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
- async cancelPasswordReset()[source]
Cancels reset of 2-step verification password. The method can be called if passwordState.pending_reset_date > 0
- async cancelPreliminaryUploadFile(file_id=0)[source]
Stops the preliminary uploading of a file. Supported only for files uploaded by using preliminaryUploadFile
- async cancelRecoveryEmailAddressVerification()[source]
Cancels verification of the 2-step verification recovery email address
- Return type:
Union
[Error
,PasswordState
]- Returns:
- 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:
- async changeStickerSet(set_id=0, is_installed=False, is_archived=False)[source]
Installs/uninstalls or activates/archives a sticker set
- 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
- async checkAuthenticationCode(code='')[source]
Checks the authentication code. Works only when the current authorization state is authorizationStateWaitCode
- async checkAuthenticationEmailCode(code=None)[source]
Checks the authentication of an email address. Works only when the current authorization state is authorizationStateWaitEmailCode
- async checkAuthenticationPassword(password='')[source]
Checks the 2-step verification password for correctness. Works only when the current authorization state is authorizationStateWaitPassword
- 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
- 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
- async checkChatFolderInviteLink(invite_link='')[source]
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:
- async checkChatInviteLink(invite_link='')[source]
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:
- 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 createdusername (
str
) – Username to be checked
- Return type:
Union
[Error
,CheckChatUsernameResult
]- Returns:
- 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
- async checkEmailAddressVerificationCode(code='')[source]
Checks the email address verification code for Telegram Passport
- async checkPasswordRecoveryCode(recovery_code='')[source]
Checks whether a 2-step verification password recovery code sent to an email address is valid
- async checkPhoneNumberCode(code='')[source]
Check the authentication code and completes the request for which the code was sent if appropriate
- 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:
- async checkQuickReplyShortcutName(name='')[source]
Checks validness of a name for a quick reply shortcut. Can be called synchronously
- 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:
- 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:
- async checkWebAppFileDownload(bot_user_id=0, file_name='', url='')[source]
Checks whether a file can be downloaded and saved locally by Web App request
- 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
- 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
- async clearRecentEmojiStatuses()[source]
Clears the list of recently used emoji statuses for self status
- async clearSearchedForTags(clear_cashtags=False)[source]
Clears the list of recently searched for hashtags or cashtags
- 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
- 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 messagemessage_id (
int
) – Identifier of the sponsored messageis_media_click (
bool
) – Pass true if the media was clicked in the sponsored messagefrom_fullscreen (
bool
) – Pass true if the user expanded the video from the sponsored message fullscreen before the click
- Return type:
- Returns:
- async clickPremiumSubscriptionButton()[source]
Informs TDLib that the user clicked Premium subscription button on the Premium features screen
- async clickVideoMessageAdvertisement(advertisement_unique_id=0)[source]
Informs TDLib that the user clicked a video message advertisement
- 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
- 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
- async closeSecretChat(secret_chat_id=0)[source]
Closes a secret chat, effectively transferring its state to secretChatStateClosed
- async closeStory(story_poster_chat_id=0, story_id=0)[source]
Informs TDLib that a story is closed by the user
- async closeWebApp(web_app_launch_id=0)[source]
Informs TDLib that a previously opened Web App was closed
- async commitPendingPaidMessageReactions(chat_id=0, message_id=0)[source]
Applies all pending paid reactions on a message
- async confirmQrCodeAuthentication(link='')[source]
Confirms QR code authentication on another device. Returns created session on success
- async confirmSession(session_id=0)[source]
Confirms an unconfirmed session of the current user from another device
- 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 connectedbot_user_id (
int
) – Identifier of the bot, which affiliate program is connected
- Return type:
Union
[Error
,ConnectedAffiliateProgram
]- Returns:
- async createBasicGroupChat(basic_group_id=0, force=False)[source]
Returns an existing chat corresponding to a known basic group
- async createBusinessChatLink(link_info=None)[source]
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:
- 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:
- async createChatFolderInviteLink(chat_folder_id=0, name='', chat_ids=None)[source]
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 identifiername (
str
) – Name of the link; 0-32 characterschat_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:
- async createChatInviteLink(chat_id=0, name='', expiration_date=0, member_limit=0, creates_join_request=False)[source]
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 identifiername (
str
) – Invite link name; 0-32 charactersexpiration_date (
int
) – Point in time (Unix timestamp) when the link will expire; pass 0 if nevermember_limit (
int
) – The maximum number of chat members that can join the chat via the link simultaneously; 0-99999; pass 0 if not limitedcreates_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:
- async createChatSubscriptionInviteLink(chat_id=0, name='', subscription_pricing=None)[source]
Creates a new subscription invite link for a channel chat. Requires can_invite_users right in the chat
- Parameters:
chat_id (
int
) – Chat identifiername (
str
) – Invite link name; 0-32 characterssubscription_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:
- 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 chatname (
str
) – Name of the topic; 1-128 charactersicon (
"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:
- 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 giftsname (
str
) – Name of the collection; 1-12 charactersreceived_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:
- 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:
- async createInvoiceLink(business_connection_id='', invoice=None)[source]
Creates a link for the given invoice; for bots only
- 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 memberstitle (
str
) – Title of the new basic group; 1-128 charactersmessage_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:
- async createNewSecretChat(user_id=0)[source]
Creates a new secret chat. Returns the newly created 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 userstitle (
str
) – Sticker set title; 1-64 charactersname (
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 automaticallysticker_type (
"types.StickerType"
) – Type of the stickers in the setneeds_repainting (
bool
) – Pass true if stickers in the sticker set must be repainted; for custom emoji sticker sets onlystickers (
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 shownsource (
str
) – Source of the sticker set; may be empty if unknown
- Return type:
Union
[Error
,StickerSet
]- Returns:
- 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 charactersis_forum (
bool
) – Pass true to create a forum supergroup chatis_channel (
bool
) – Pass true to create a channel chat; ignored if a forum is createddescription (
str
) – Chat description; 0-255 characterslocation (
"types.ChatLocation"
) – Chat location if a location-based supergroup is being created; pass null to create an ordinary supergroup chatmessage_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 automaticallyfor_import (
bool
) – Pass true to create a supergroup for importing messages using importMessages
- Return type:
- Returns:
- async createPrivateChat(user_id=0, force=False)[source]
Returns an existing chat corresponding to a given user
- async createSecretChat(secret_chat_id=0)[source]
Returns an existing chat corresponding to a known secret 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 storiesname (
str
) – Name of the album; 1-12 charactersstory_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:
- async createSupergroupChat(supergroup_id=0, force=False)[source]
Returns an existing chat corresponding to a known supergroup or channel
- 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 uservalid_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:
- 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 createdtitle (
str
) – Group call title; if empty, chat title will be usedstart_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 futureis_rtmp_stream (
bool
) – Pass true to create an RTMP stream instead of an ordinary video chat
- Return type:
Union
[Error
,GroupCallId
]- Returns:
- 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
- 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 chatmessage_id (
int
) – Identifier of the message with the suggested post. Use messageProperties.can_be_declined to check whether the suggested post can be declinedcomment (
str
) – Comment for the creator of the suggested post; 0-128 characters
- Return type:
- Returns:
- 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 chatparticipant_id (
"types.MessageSender"
) – Identifier of the group call participant, which sent the datadata_channel (
"types.GroupCallDataChannel"
) – Data channel for which data was encrypted; pass null if unknowndata (
bytes
) – Data to decrypt
- Return type:
- Returns:
- 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; optionalpassword (
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:
- Returns:
- async deleteAllRevokedChatInviteLinks(chat_id=0, creator_user_id=0)[source]
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
- async deleteBotMediaPreviews(bot_user_id=0, language_code='', file_ids=None)[source]
Delete media previews from the list of media previews of a bot
- async deleteBusinessConnectedBot(bot_user_id=0)[source]
Deletes the business bot that is connected to the current user account
- async deleteBusinessMessages(business_connection_id='', message_ids=None)[source]
Deletes messages on behalf of a business account; for bots only
- 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
- 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
- async deleteChatBackground(chat_id=0, restore_previous=False)[source]
Deletes background in a specific chat
- Parameters:
chat_id (
int
) – Chat identifierrestore_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:
- Returns:
- async deleteChatFolderInviteLink(chat_folder_id=0, invite_link='')[source]
Deletes an invite link for a chat folder
- 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
- 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
- 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
- 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
- async deleteCommands(scope=None, language_code='')[source]
Deletes commands supported by the bot for the given user scope and language; for bots only
- 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
- 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 chattopic_id (
int
) – Identifier of the topic which messages will be deletedmin_date (
int
) – The minimum date of the messages to deletemax_date (
int
) – The maximum date of the messages to delete
- Return type:
- Returns:
- 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
- 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
- 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
- async deleteMessages(chat_id=0, message_ids=None, revoke=False)[source]
Deletes messages
- Parameters:
chat_id (
int
) – Chat identifiermessage_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 messagesrevoke (
bool
) – Pass true to delete messages for all chat members. Always true for supergroups, channels and secret chats
- Return type:
- Returns:
- async deleteQuickReplyShortcutMessages(shortcut_id=0, message_ids=None)[source]
Deletes specified quick reply messages
- async deleteRevokedChatInviteLink(chat_id=0, invite_link='')[source]
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
- async deleteSavedMessagesTopicHistory(saved_messages_topic_id=0)[source]
Deletes all messages in a Saved Messages topic
- 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
- 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
- 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
- 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
- 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
- async disableProxy()[source]
Disables the currently enabled proxy. Can be called before authorization
- 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 identifieris_disconnected (
bool
) – Pass true if the user was disconnectedinvite_link (
str
) – If the call was upgraded to a group call, pass invite link to the group callduration (
int
) – The call duration, in secondsis_video (
bool
) – Pass true if the call was a video callconnection_id (
int
) – Identifier of the connection used during the call
- Return type:
- Returns:
- 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 connectedurl (
str
) – The referral link of the affiliate program
- Return type:
Union
[Error
,ConnectedAffiliateProgram
]- Returns:
- async disconnectAllWebsites()[source]
Disconnects all websites from the current user’s Telegram account
- async disconnectWebsite(website_id=0)[source]
Disconnects website from the current user’s Telegram account
- 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 downloadpriority (
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 firstoffset (
int
) – The starting position from which the file needs to be downloadedlimit (
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 limitsynchronous (
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:
- Returns:
- 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 Applanguage_code (
str
) – Language code of the media preview to editfile_id (
int
) – File identifier of the media to replacecontent (
"types.InputStoryContent"
) – Content of the new preview
- Return type:
Union
[Error
,BotMediaPreview
]- Returns:
- async editBusinessChatLink(link='', link_info=None)[source]
Edits a business chat link of the current account. Requires Telegram Business subscription. Returns the edited link
- Parameters:
link (
str
) – The link to editlink_info (
"types.InputBusinessChatLink"
) – New description of the link
- Return type:
Union
[Error
,BusinessChatLink
]- Returns:
- 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 sentchat_id (
int
) – The chat the message belongs tomessage_id (
int
) – Identifier of the messagereply_markup (
"types.ReplyMarkup"
) – The new message reply markup; pass null if nonecaption (
"types.FormattedText"
) – New message content caption; pass null to remove caption; 0-getOption("message_caption_length_max") charactersshow_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:
- 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 sentchat_id (
int
) – The chat the message belongs tomessage_id (
int
) – Identifier of the messagereply_markup (
"types.ReplyMarkup"
) – The new message reply markup; pass null if nonechecklist (
"types.InputChecklist"
) – The new checklist. If some tasks were completed, this information will be kept
- Return type:
Union
[Error
,BusinessMessage
]- Returns:
- 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 sentchat_id (
int
) – The chat the message belongs tomessage_id (
int
) – Identifier of the messagereply_markup (
"types.ReplyMarkup"
) – The new message reply markup; pass null if nonelocation (
"types.Location"
) – New location content of the message; pass null to stop sharing the live locationlive_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_periodheading (
int
) – The new direction in which the location moves, in degrees; 1-360. Pass 0 if unknownproximity_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:
- 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 sentchat_id (
int
) – The chat the message belongs tomessage_id (
int
) – Identifier of the messagereply_markup (
"types.ReplyMarkup"
) – The new message reply markup; pass null if none; for bots onlyinput_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:
- 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 sentchat_id (
int
) – The chat the message belongs tomessage_id (
int
) – Identifier of the messagereply_markup (
"types.ReplyMarkup"
) – The new message reply markup; pass null if none
- Return type:
Union
[Error
,BusinessMessage
]- Returns:
- 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 sentchat_id (
int
) – The chat the message belongs tomessage_id (
int
) – Identifier of the messagereply_markup (
"types.ReplyMarkup"
) – The new message reply markup; pass null if noneinput_message_content (
"types.InputMessageContent"
) – New text content of the message. Must be of type inputMessageText
- Return type:
Union
[Error
,BusinessMessage
]- Returns:
- 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 storystory_id (
int
) – Identifier of the story to editcontent (
"types.InputStoryContent"
) – New content of the storyareas (
"types.InputStoryAreas"
) – New clickable rectangle areas to be shown on the story mediacaption (
"types.FormattedText"
) – New story captionprivacy_settings (
"types.StoryPrivacySettings"
) – The new privacy settings for the story
- Return type:
- Returns:
- 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 identifierfolder (
"types.ChatFolder"
) – The edited chat folder
- Return type:
Union
[Error
,ChatFolderInfo
]- Returns:
- async editChatFolderInviteLink(chat_folder_id=0, invite_link='', name='', chat_ids=None)[source]
Edits an invite link for a chat folder
- Parameters:
chat_folder_id (
int
) – Chat folder identifierinvite_link (
str
) – Invite link to be editedname (
str
) – New name of the link; 0-32 characterschat_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:
- async editChatInviteLink(chat_id=0, invite_link='', name='', expiration_date=0, member_limit=0, creates_join_request=False)[source]
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 identifierinvite_link (
str
) – Invite link to be editedname (
str
) – Invite link name; 0-32 charactersexpiration_date (
int
) – Point in time (Unix timestamp) when the link will expire; pass 0 if nevermember_limit (
int
) – The maximum number of chat members that can join the chat via the link simultaneously; 0-99999; pass 0 if not limitedcreates_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:
- async editChatSubscriptionInviteLink(chat_id=0, invite_link='', name='')[source]
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 identifierinvite_link (
str
) – Invite link to be editedname (
str
) – Invite link name; 0-32 characters
- Return type:
Union
[Error
,ChatInviteLink
]- Returns:
- async editCustomLanguagePackInfo(info=None)[source]
Edits information about a custom local language pack in the current localization target. Can be called before authorization
- 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 chatmessage_thread_id (
int
) – Message thread identifier of the forum topicname (
str
) – New name of the topic; 0-128 characters. If empty, the previous topic name is keptedit_icon_custom_emoji (
bool
) – Pass true to edit the icon of the topic. Icon of the General topic can’t be editedicon_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:
- Returns:
- 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 identifierreply_markup (
"types.ReplyMarkup"
) – The new message reply markup; pass null if nonecaption (
"types.FormattedText"
) – New message content caption; pass null to remove caption; 0-getOption("message_caption_length_max") charactersshow_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:
- Returns:
- 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 identifierreply_markup (
"types.ReplyMarkup"
) – The new message reply markup; pass null if nonelocation (
"types.Location"
) – New location content of the message; pass null to stop sharing the live locationlive_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_periodheading (
int
) – The new direction in which the location moves, in degrees; 1-360. Pass 0 if unknownproximity_alert_radius (
int
) – The new maximum distance for proximity alerts, in meters (0-100000). Pass 0 if the notification is disabled
- Return type:
- Returns:
- 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 identifierreply_markup (
"types.ReplyMarkup"
) – The new message reply markup; pass null if none; for bots onlyinput_message_content (
"types.InputMessageContent"
) – New content of the message. Must be one of the following types: inputMessageAnimation, inputMessageAudio, inputMessageDocument, inputMessagePhoto or inputMessageVideo
- Return type:
- Returns:
- async editInlineMessageReplyMarkup(inline_message_id='', reply_markup=None)[source]
Edits the reply markup of an inline message sent via a bot; for bots only
- 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 identifierreply_markup (
"types.ReplyMarkup"
) – The new message reply markup; pass null if noneinput_message_content (
"types.InputMessageContent"
) – New text content of the message. Must be of type inputMessageText
- Return type:
- Returns:
- 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 tomessage_id (
int
) – Identifier of the message. Use messageProperties.can_be_edited to check whether the message can be editedreply_markup (
"types.ReplyMarkup"
) – The new message reply markup; pass null if none; for bots onlycaption (
"types.FormattedText"
) – New message content caption; 0-getOption("message_caption_length_max") characters; pass null to remove captionshow_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:
- Returns:
- 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 tomessage_id (
int
) – Identifier of the message. Use messageProperties.can_be_edited to check whether the message can be editedreply_markup (
"types.ReplyMarkup"
) – The new message reply markup; pass null if none; for bots onlychecklist (
"types.InputChecklist"
) – The new checklist. If some tasks were completed, this information will be kept
- Return type:
- Returns:
- 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 tomessage_id (
int
) – Identifier of the message. Use messageProperties.can_be_edited to check whether the message can be editedreply_markup (
"types.ReplyMarkup"
) – The new message reply markup; pass null if none; for bots onlylocation (
"types.Location"
) – New location content of the message; pass null to stop sharing the live locationlive_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_periodheading (
int
) – The new direction in which the location moves, in degrees; 1-360. Pass 0 if unknownproximity_alert_radius (
int
) – The new maximum distance for proximity alerts, in meters (0-100000). Pass 0 if the notification is disabled
- Return type:
- Returns:
- 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 tomessage_id (
int
) – Identifier of the message. Use messageProperties.can_edit_media to check whether the message can be editedreply_markup (
"types.ReplyMarkup"
) – The new message reply markup; pass null if none; for bots onlyinput_message_content (
"types.InputMessageContent"
) – New content of the message. Must be one of the following types: inputMessageAnimation, inputMessageAudio, inputMessageDocument, inputMessagePhoto or inputMessageVideo
- Return type:
- Returns:
- 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 tomessage_id (
int
) – Identifier of the message. Use messageProperties.can_be_edited to check whether the message can be editedreply_markup (
"types.ReplyMarkup"
) – The new message reply markup; pass null if none
- Return type:
- Returns:
- 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 tomessage_id (
int
) – Identifier of the message. Use messageProperties.can_edit_scheduling_state to check whether the message is suitablescheduling_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:
- Returns:
- 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 tomessage_id (
int
) – Identifier of the message. Use messageProperties.can_be_edited to check whether the message can be editedreply_markup (
"types.ReplyMarkup"
) – The new message reply markup; pass null if none; for bots onlyinput_message_content (
"types.InputMessageContent"
) – New text content of the message. Must be of type inputMessageText
- Return type:
- Returns:
- 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
- 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 messagemessage_id (
int
) – Identifier of the messageinput_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:
- Returns:
- async editStarSubscription(subscription_id='', is_canceled=False)[source]
Cancels or re-enables Telegram Star subscription
- 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 storystory_id (
int
) – Identifier of the story to editcontent (
"types.InputStoryContent"
) – New content of the story; pass null to keep the current contentareas (
"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 changedcaption (
"types.FormattedText"
) – New story caption; pass null to keep the current caption
- Return type:
- Returns:
- 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
- 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
- async enableProxy(proxy_id=0)[source]
Enables a proxy. Only one proxy can be enabled at a time. Can be called before authorization
- 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 chatdata_channel (
"types.GroupCallDataChannel"
) – Data channel for which data is encrypteddata (
bytes
) – Data to encryptunencrypted_prefix_size (
int
) – Size of data prefix that must be kept unencrypted
- Return type:
- Returns:
- 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
- async endGroupCallRecording(group_call_id=0)[source]
Ends recording of an active group call; for video chats only. Requires groupCall.can_be_managed right
- async endGroupCallScreenSharing(group_call_id=0)[source]
Ends screen sharing in a joined group call
- 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 messagesmessage_thread_id (
int
) – If not 0, the message thread identifier in which the message will be sent; for forum threads onlyfrom_chat_id (
int
) – Identifier of the chat from which to forward messagesmessage_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_forwardedoptions (
"types.MessageSendOptions"
) – Options to be used to send the messages; pass null to use default optionssend_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 suitableremove_caption (
bool
) – Pass true to remove media captions of message copies. Ignored if send_copy is false
- Return type:
- Returns:
- 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:
- 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:
- 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 forquery (
str
) – Search querychat_id (
int
) – Chat identifier for which to find stickersreturn_only_main_emoji (
bool
) – Pass true if only main emoji for each found sticker must be included in the result
- Return type:
- Returns:
- 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:
- async getApplicationConfig()[source]
Returns application config, provided by the server. Can be called before authorization
- async getApplicationDownloadLink()[source]
Returns the link for downloading official Telegram application to be used when the current user invites friends to Telegram
- async getArchiveChatListSettings()[source]
Returns settings for automatic moving of chats to and from the Archive chat lists
- Return type:
Union
[Error
,ArchiveChatListSettings
]- Returns:
- 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 returnoffset_sticker_set_id (
int
) – Identifier of the sticker set from which to return the result; use 0 to get results from the beginninglimit (
int
) – The maximum number of sticker sets to return; up to 100
- Return type:
Union
[Error
,StickerSets
]- Returns:
- 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:
- 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:
- 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:
- async getAutoDownloadSettingsPresets()[source]
Returns auto-download settings presets for the current user
- Return type:
Union
[Error
,AutoDownloadSettingsPresets
]- Returns:
- async getAutosaveSettings()[source]
Returns autosave settings for the current user
- Return type:
Union
[Error
,AutosaveSettings
]- Returns:
- async getAvailableChatBoostSlots()[source]
Returns the list of available chat boost slots for the current user
- Return type:
Union
[Error
,ChatBoostSlots
]- Returns:
- async getAvailableGifts()[source]
Returns gifts that can be sent to other users and channel chats
- Return type:
Union
[Error
,AvailableGifts
]- Returns:
- async getBackgroundUrl(name='', type=None)[source]
Constructs a persistent HTTP URL for a background
- 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:
- 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:
- 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:
- 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 usersoffset (
int
) – Number of users and chats to skip in the result; must be non-negativelimit (
int
) – The maximum number of users and chats to return; up to 100
- Return type:
Union
[Error
,MessageSenders
]- Returns:
- 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
- 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
- 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 Applanguage_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:
- 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:
- 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
- async getBotSimilarBotCount(bot_user_id=0, return_local=False)[source]
Returns approximate number of bots similar to the given bot
- 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:
- 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:
- async getBusinessChatLinks()[source]
Returns business chat links created for the current account
- Return type:
Union
[Error
,BusinessChatLinks
]- Returns:
- 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:
- 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:
- 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:
- 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 messagemessage_id (
int
) – Identifier of the message from which the query originated. The message must not be scheduledpayload (
"types.CallbackQueryPayload"
) – Query payload
- Return type:
Union
[Error
,CallbackQueryAnswer
]- Returns:
- 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
- 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
- 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:
- 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:
- 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 identifierfrom_story_id (
int
) – Identifier of the story starting from which stories must be returned; use 0 to get results from the last storylimit (
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:
- Returns:
- 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:
- 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:
- 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:
- 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 supergroupslevel (
int
) – Chat boost level
- Return type:
Union
[Error
,ChatBoostLevelFeatures
]- Returns:
- async getChatBoostLink(chat_id=0)[source]
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:
- 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:
- 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:
- 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 chatonly_gift_codes (
bool
) – Pass true to receive only boosts received from gift codes and giveaways created by the chatoffset (
str
) – Offset of the first entry to return as received from the previous request; use empty string to get the first chunk of resultslimit (
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:
- 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 identifierquery (
str
) – Search query by which to filter eventsfrom_event_id (
int
) – Identifier of an event from which to return results. Use 0 to get results from the latest eventslimit (
int
) – The maximum number of events to return; up to 100filters (
"types.ChatEventLogFilters"
) – The types of events to return; pass null to get chat events of all typesuser_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:
- 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:
- 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
- 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
- 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:
- async getChatFolderInviteLinks(chat_folder_id=0)[source]
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:
- 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
- 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 identifierfrom_message_id (
int
) – Identifier of the message starting from which history must be fetched; use 0 to get results from the last messageoffset (
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 messageslimit (
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 limitonly_local (
bool
) – Pass true to get only messages that are available without sending network requests
- Return type:
- Returns:
- async getChatInviteLink(chat_id=0, invite_link='')[source]
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 identifierinvite_link (
str
) – Invite link to get
- Return type:
Union
[Error
,ChatInviteLink
]- Returns:
- 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:
- 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 identifierinvite_link (
str
) – Invite link for which to return chat membersonly_with_expired_subscription (
bool
) – Pass true if the link is a subscription link and only members with expired subscription must be returnedoffset_member (
"types.ChatInviteLinkMember"
) – A chat member from which to return next chat members; pass null to get results from the beginninglimit (
int
) – The maximum number of chat members to return; up to 100
- Return type:
Union
[Error
,ChatInviteLinkMembers
]- Returns:
- async getChatInviteLinks(chat_id=0, creator_user_id=0, is_revoked=False, offset_date=0, offset_invite_link='', limit=0)[source]
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 identifiercreator_user_id (
int
) – User identifier of a chat administrator. Must be an identifier of the current user for non-owneris_revoked (
bool
) – Pass true if revoked links needs to be returned instead of active or expiredoffset_date (
int
) – Creation date of an invite link starting after which to return invite links; use 0 to get results from the beginningoffset_invite_link (
str
) – Invite link starting after which to return invite links; use empty string to get results from the beginninglimit (
int
) – The maximum number of invite links to return; up to 100
- Return type:
Union
[Error
,ChatInviteLinks
]- Returns:
- 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 identifierinvite_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 linksquery (
str
) – A query to search for in the first names, last names and usernames of the users to returnoffset_request (
"types.ChatJoinRequest"
) – A chat join request from which to return next requests; pass null to get results from the beginninglimit (
int
) – The maximum number of requests to join the chat to return
- Return type:
Union
[Error
,ChatJoinRequests
]- Returns:
- async getChatListsToAddChat(chat_id=0)[source]
Returns chat lists to which the chat can be added. This is an offline method
- async getChatMember(chat_id=0, member_id=None)[source]
Returns information about a single member of a chat
- Parameters:
chat_id (
int
) – Chat identifiermember_id (
"types.MessageSender"
) – Member identifier
- Return type:
Union
[Error
,ChatMember
]- Returns:
- 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
- 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 messagestopic_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 supportedfilter (
"types.SearchMessagesFilter"
) – Filter for message content. Filters searchMessagesFilterEmpty, searchMessagesFilterMention, searchMessagesFilterUnreadMention, and searchMessagesFilterUnreadReaction are unsupported in this functionfrom_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:
- 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 messagestopic_id (
"types.MessageTopic"
) – Pass topic identifier to get number of messages only in specific topic; pass null to get number of messages in all topicsfilter (
"types.SearchMessagesFilter"
) – Filter for message content; searchMessagesFilterEmpty is unsupported in this functionreturn_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:
- Returns:
- 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 positiontopic_id (
"types.MessageTopic"
) – Pass topic identifier to get position among messages only in specific topic; pass null to get position among all chat messagesfilter (
"types.SearchMessagesFilter"
) – Filter for message content; searchMessagesFilterEmpty, searchMessagesFilterUnreadMention, searchMessagesFilterUnreadReaction, and searchMessagesFilterFailedToSend are unsupported in this functionmessage_id (
int
) – Message identifier
- Return type:
- Returns:
- async getChatNotificationSettingsExceptions(scope=None, compare_sound=False)[source]
Returns the list of chats with non-default notification settings for new messages
- 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
- 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 identifierfrom_story_id (
int
) – Identifier of the story starting from which stories must be returned; use 0 to get results from pinned and the newest storylimit (
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:
- Returns:
- 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 identifieris_dark (
bool
) – Pass true if a dark theme is used by the application
- Return type:
Union
[Error
,ChatRevenueStatistics
]- Returns:
- 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 identifieroffset (
str
) – Offset of the first transaction to return as received from the previous request; use empty string to get the first chunk of resultslimit (
int
) – The maximum number of transactions to be returned; up to 100
- Return type:
Union
[Error
,ChatRevenueTransactions
]- Returns:
- 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
- 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)
- async getChatSimilarChatCount(chat_id=0, return_local=False)[source]
Returns approximate number of chats similar to the given chat
- 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 positionsfilter (
"types.SearchMessagesFilter"
) – Filter for message content. Filters searchMessagesFilterEmpty, searchMessagesFilterMention, searchMessagesFilterUnreadMention, and searchMessagesFilterUnreadReaction are unsupported in this functionfrom_message_id (
int
) – The message identifier from which to return information about message positionslimit (
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 messagessaved_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:
- 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:
- 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 identifieris_dark (
bool
) – Pass true if a dark theme is used by the application
- Return type:
Union
[Error
,ChatStatistics
]- Returns:
- 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:
- 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 storystory_id (
int
) – Story identifierreaction_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 supportedprefer_forwards (
bool
) – Pass true to get forwards and reposts first, then reactions, then other views; pass false to get interactions sorted just by interaction dateoffset (
str
) – Offset of the first entry to return as received from the previous request; use empty string to get the first chunk of resultslimit (
int
) – The maximum number of story interactions to return
- Return type:
Union
[Error
,StoryInteractions
]- Returns:
- 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
- async getChatsForChatFolderInviteLink(chat_folder_id=0)[source]
Returns identifiers of chats from a chat folder, suitable for adding to a chat folder invite link
- 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
- 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:
- 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 scopelanguage_code (
str
) – A two-letter ISO 639-1 language code or an empty string
- Return type:
Union
[Error
,BotCommands
]- Returns:
- 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 connectedbot_user_id (
int
) – Identifier of the bot that created the program
- Return type:
Union
[Error
,ConnectedAffiliateProgram
]- Returns:
- 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 connectedoffset (
str
) – Offset of the first affiliate program to return as received from the previous request; use empty string to get the first chunk of resultslimit (
int
) – The maximum number of affiliate programs to return
- Return type:
Union
[Error
,ConnectedAffiliatePrograms
]- Returns:
- async getConnectedWebsites()[source]
Returns all website where the current user used Telegram to log in
- Return type:
Union
[Error
,ConnectedWebsites
]- Returns:
- async getCountries()[source]
Returns information about existing countries. Can be called before authorization
- 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
- async getCountryFlagEmoji(country_code='')[source]
Returns an emoji for the given country. Returns an empty string on failure. Can be called synchronously
- async getCreatedPublicChats(type=None)[source]
Returns a list of public chats of the specified type, owned by the user
- 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
- 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:
- async getCustomEmojiReactionAnimations()[source]
Returns TGS stickers with generic animations for custom emoji reactions
- 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
- async getDatabaseStatistics()[source]
Returns database statistics
- Return type:
Union
[Error
,DatabaseStatistics
]- Returns:
- 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:
- async getDefaultBackgroundCustomEmojiStickers()[source]
Returns default list of custom emoji stickers for reply background
- async getDefaultChatEmojiStatuses()[source]
Returns default emoji statuses for chats
- Return type:
Union
[Error
,EmojiStatusCustomEmojis
]- Returns:
- async getDefaultChatPhotoCustomEmojiStickers()[source]
Returns default list of custom emoji stickers for placing on a chat photo
- async getDefaultEmojiStatuses()[source]
Returns default emoji statuses for self status
- Return type:
Union
[Error
,EmojiStatusCustomEmojis
]- Returns:
- async getDefaultMessageAutoDeleteTime()[source]
Returns default message auto-delete time setting for new chats
- Return type:
Union
[Error
,MessageAutoDeleteTime
]- Returns:
- async getDefaultProfilePhotoCustomEmojiStickers()[source]
Returns default list of custom emoji stickers for placing on a profile photo
- 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 chattopic_id (
int
) – Identifier of the topic to get
- Return type:
Union
[Error
,DirectMessagesChatTopic
]- Returns:
- 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 chattopic_id (
int
) – Identifier of the topic which messages will be fetchedfrom_message_id (
int
) – Identifier of the message starting from which messages must be fetched; use 0 to get results from the last messageoffset (
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 messageslimit (
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:
- Returns:
- 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
- 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
- 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:
- 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:
- 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:
- 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
- async getExternalLink(link='', allow_write_access=False)[source]
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
- 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:
- 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 fileoffset (
int
) – Offset from which downloaded prefix size needs to be calculated
- Return type:
Union
[Error
,FileDownloadedPrefixSize
]- Returns:
- 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
- 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
- async getForumTopic(chat_id=0, message_thread_id=0)[source]
Returns information about a forum topic
- Parameters:
chat_id (
int
) – Identifier of the chatmessage_thread_id (
int
) – Message thread identifier of the forum topic
- Return type:
Union
[Error
,ForumTopic
]- Returns:
- async getForumTopicDefaultIcons()[source]
Returns the list of custom emoji, which can be used as forum topic icon by all users
- async getForumTopicLink(chat_id=0, message_thread_id=0)[source]
Returns an HTTPS link to a topic in a forum chat. This is an offline method
- Parameters:
chat_id (
int
) – Identifier of the chatmessage_thread_id (
int
) – Message thread identifier of the forum topic
- Return type:
Union
[Error
,MessageLink
]- Returns:
- 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 chatquery (
str
) – Query to search for in the forum topic’s nameoffset_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 topicoffset_message_id (
int
) – The message identifier of the last message in the last found topic, or 0 for the first requestoffset_message_thread_id (
int
) – The message thread identifier of the last found topic, or 0 for the first requestlimit (
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:
- 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 gamemessage_id (
int
) – Identifier of the messageuser_id (
int
) – User identifier
- Return type:
Union
[Error
,GameHighScores
]- Returns:
- 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 resultslimit (
int
) – The maximum number of chat themes to return
- Return type:
Union
[Error
,GiftChatThemes
]- Returns:
- 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:
- 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:
- 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 giveawaymessage_id (
int
) – Identifier of the giveaway or a giveaway winners message in the chat
- Return type:
Union
[Error
,GiveawayInfo
]- Returns:
- async getGreetingStickers()[source]
Returns greeting stickers from regular sticker sets that can be used for the start page of other users
- 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 resultslimit (
int
) – The maximum number of bots to be returned; up to 100
- Return type:
Union
[Error
,FoundUsers
]- Returns:
- 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 returnedlimit (
int
) – The maximum number of participants to return; must be positive
- Return type:
Union
[Error
,GroupCallParticipants
]- Returns:
- 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
- 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
- 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 identifieruser_id (
int
) – User identifier
- Return type:
Union
[Error
,GameHighScores
]- Returns:
- 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 botchat_id (
int
) – Identifier of the chat where the query was sentuser_location (
"types.Location"
) – Location of the user; pass null if unknown or the bot doesn’t need user’s locationquery (
str
) – Text of the queryoffset (
str
) – Offset of the first entry to return; use empty string to get the first chunk of results
- Return type:
Union
[Error
,InlineQueryResults
]- Returns:
- 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:
- 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:
- async getInternalLink(type=None, is_http=False)[source]
Returns an HTTPS or a tg: link with the given type. Can be called before authorization
- 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:
- async getJsonString(json_value=None)[source]
Converts a JsonValue object to corresponding JSON-serialized string. Can be called synchronously
- async getJsonValue(json='')[source]
Converts a JSON-serialized string to corresponding JsonValue object. Can be called synchronously
- 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
- 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:
- 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 storedlocalization_target (
str
) – Localization target to which the language pack belongslanguage_pack_id (
str
) – Language pack identifierkey (
str
) – Language pack key of the string to be returned
- Return type:
Union
[Error
,LanguagePackStringValue
]- Returns:
- 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 returnedkeys (
List[str]
) – Language pack keys of the strings to be returned; leave empty to request all available strings
- Return type:
Union
[Error
,LanguagePackStrings
]- Returns:
- 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 formattinglink_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:
- 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:
- async getLogStream()[source]
Returns information about currently used log stream for internal logging of TDLib. Can be called synchronously
- 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:
- async getLogTags()[source]
Returns the list of available TDLib internal log tags, for example, ["actor", "binlog", "connections", "notifications", "proxy"]. Can be called synchronously
- async getLogVerbosityLevel()[source]
Returns current verbosity level of the internal logging of TDLib. Can be called synchronously
- Return type:
Union
[Error
,LogVerbosityLevel
]- Returns:
- 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 buttonmessage_id (
int
) – Message identifier of the message with the buttonbutton_id (
int
) – Button identifierallow_write_access (
bool
) – Pass true to allow the bot to send messages to the current user
- Return type:
- Returns:
- 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 buttonmessage_id (
int
) – Message identifier of the message with the button. The message must not be scheduledbutton_id (
int
) – Button identifier
- Return type:
Union
[Error
,LoginUrlInfo
]- Returns:
- 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 nonebot_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 methodstart_parameter (
str
) – Start parameter from internalLinkTypeMainWebAppparameters (
"types.WebAppOpenParameters"
) – Parameters to use to open the Web App
- Return type:
Union
[Error
,MainWebApp
]- Returns:
- 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 centerzoom (
int
) – Map zoom level; 13-20width (
int
) – Map width in pixels before applying scale; 16-1024height (
int
) – Map height in pixels before applying scale; 16-1024scale (
int
) – Map scale; 1-3chat_id (
int
) – Identifier of a chat in which the thumbnail will be shown. Use 0 if unknown
- Return type:
- Returns:
- 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:
- 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:
- async getMessage(chat_id=0, message_id=0)[source]
Returns information about a message. Returns a 404 error if the message doesn’t exist
- 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 belongsmessage_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 messagereaction_type (
"types.ReactionType"
) – Type of the reactions to return; pass null to return all added reactions; reactionTypePaid isn’t supportedoffset (
str
) – Offset of the first entry to return as received from the previous request; use empty string to get the first chunk of resultslimit (
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:
- 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
- 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 belongsmessage_id (
int
) – Identifier of the messagerow_size (
int
) – Number of reaction per row, 5-25
- Return type:
Union
[Error
,AvailableReactions
]- Returns:
- 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:
- 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
- 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:
- async getMessageImportConfirmationText(chat_id=0)[source]
Returns a confirmation text to be shown to the user before starting message import
- async getMessageLink(chat_id=0, message_id=0, media_timestamp=0, for_album=False, in_message_thread=False)[source]
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 belongsmessage_id (
int
) – Identifier of the messagemedia_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 previewfor_album (
bool
) – Pass true to create a link for the whole media albumin_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:
- 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:
- 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
- async getMessageProperties(chat_id=0, message_id=0)[source]
Returns properties of a message. This is an offline method
- Parameters:
chat_id (
int
) – Chat identifiermessage_id (
int
) – Identifier of the message
- Return type:
Union
[Error
,MessageProperties
]- Returns:
- 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 messagemessage_id (
int
) – Message identifieroffset (
str
) – Offset of the first entry to return as received from the previous request; use empty string to get the first chunk of resultslimit (
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:
- 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 identifiermessage_id (
int
) – Identifier of the message
- Return type:
Union
[Error
,MessageReadDate
]- Returns:
- 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 identifiermessage_id (
int
) – Message identifieris_dark (
bool
) – Pass true if a dark theme is used by the application
- Return type:
Union
[Error
,MessageStatistics
]- Returns:
- 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 identifiermessage_id (
int
) – Identifier of the message
- Return type:
Union
[Error
,MessageThreadInfo
]- Returns:
- 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 identifiermessage_id (
int
) – Message identifier, which thread history needs to be returnedfrom_message_id (
int
) – Identifier of the message starting from which history must be fetched; use 0 to get results from the last messageoffset (
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 messageslimit (
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:
- Returns:
- 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 identifiermessage_id (
int
) – Identifier of the message
- Return type:
Union
[Error
,MessageViewers
]- Returns:
- 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
- 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:
- async getNewChatPrivacySettings()[source]
Returns privacy settings for new chat creation
- Return type:
Union
[Error
,NewChatPrivacySettings
]- Returns:
- 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:
- 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 beginninglimit (
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:
- 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
- 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 botscope (
str
) – Telegram Passport element types requested by the servicepublic_key (
str
) – Service’s public keynonce (
str
) – Unique request identifier provided by the service
- Return type:
Union
[Error
,PassportAuthorizationForm
]- Returns:
- 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 identifierpassword (
str
) – The 2-step verification password of the current user
- Return type:
Union
[Error
,PassportElementsWithErrors
]- Returns:
- async getPassportElement(type=None, password='')[source]
Returns one of the available Telegram Passport elements
- Parameters:
type (
"types.PassportElementType"
) – Telegram Passport element typepassword (
str
) – The 2-step verification password of the current user
- Return type:
Union
[Error
,PassportElement
]- Returns:
- async getPasswordState()[source]
Returns the current state of 2-step verification
- Return type:
Union
[Error
,PasswordState
]- Returns:
- 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 invoicetheme (
"types.ThemeParameters"
) – Preferred payment form theme; pass null to use the default theme
- Return type:
Union
[Error
,PaymentForm
]- Returns:
- async getPaymentReceipt(chat_id=0, message_id=0)[source]
Returns information about a successful payment
- Parameters:
chat_id (
int
) – Chat identifier of the messagePaymentSuccessful messagemessage_id (
int
) – Message identifier
- Return type:
Union
[Error
,PaymentReceipt
]- Returns:
- 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:
- 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 localizationphone_number_prefix (
str
) – The phone number prefix
- Return type:
Union
[Error
,PhoneNumberInfo
]- Returns:
- 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 belongsmessage_id (
int
) – Identifier of the message containing the polloption_id (
int
) – 0-based identifier of the answer optionoffset (
int
) – Number of voters to skip in the result; must be non-negativelimit (
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:
- 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
- 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:
- async getPremiumGiftPaymentOptions()[source]
Returns available options for gifting Telegram Premium to a user
- Return type:
Union
[Error
,PremiumGiftPaymentOptions
]- Returns:
- 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:
- async getPremiumInfoSticker(month_count=0)[source]
Returns the sticker to be used as representation of the Telegram Premium subscription
- 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:
- async getPremiumState()[source]
Returns state of Telegram Premium subscription and promotion videos for Premium features
- Return type:
Union
[Error
,PremiumState
]- Returns:
- async getPremiumStickerExamples()[source]
Returns examples of premium stickers for demonstration purposes
- 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 messageprepared_message_id (
str
) – Identifier of the prepared message
- Return type:
Union
[Error
,PreparedInlineMessage
]- Returns:
- async getProxies()[source]
Returns the list of proxies that are currently set up. Can be called before authorization
- async getProxyLink(proxy_id=0)[source]
Returns an HTTPS link, which can be used to add a proxy. Available only for SOCKS5 and MTProto proxies. Can be called before authorization
- 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:
- 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:
- async getReadDatePrivacySettings()[source]
Returns privacy settings for message read date
- Return type:
Union
[Error
,ReadDatePrivacySettings
]- Returns:
- 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:
- 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 onlyowner_id (
"types.MessageSender"
) – Identifier of the gift receivercollection_id (
int
) – Pass collection identifier to get gifts only from the specified collection; pass 0 to get gifts regardless of collectionsexclude_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 rightexclude_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 rightexclude_unlimited (
bool
) – Pass true to exclude gifts that can be purchased unlimited number of timesexclude_upgradable (
bool
) – Pass true to exclude gifts that can be purchased limited number of times and can be upgradedexclude_non_upgradable (
bool
) – Pass true to exclude gifts that can be purchased limited number of times and can’t be upgradedexclude_upgraded (
bool
) – Pass true to exclude upgraded giftssort_by_price (
bool
) – Pass true to sort results by gift price instead of send dateoffset (
str
) – Offset of the first entry to return as received from the previous request; use empty string to get the first chunk of resultslimit (
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:
- async getRecentEmojiStatuses()[source]
Returns recent emoji statuses for self status
- Return type:
Union
[Error
,EmojiStatuses
]- Returns:
- async getRecentInlineBots()[source]
Returns up to 20 recently used inline bots in the order of their last usage
- async getRecentlyOpenedChats(limit=0)[source]
Returns recently opened chats. This is an offline method. Returns chats in the order of last opening
- async getRecentlyVisitedTMeUrls(referrer='')[source]
Returns t.me URLs recently visited by a newly registered user
- async getRecommendedChatFolders()[source]
Returns recommended chat folders for the current user
- Return type:
Union
[Error
,RecommendedChatFolders
]- Returns:
- async getRecommendedChats()[source]
Returns a list of channel chats recommended to the current user
- 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:
- 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
- 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
- async getSavedAnimations()[source]
Returns saved animations
- Return type:
Union
[Error
,Animations
]- Returns:
- 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:
- 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 fetchedfrom_message_id (
int
) – Identifier of the message starting from which messages must be fetched; use 0 to get results from the last messageoffset (
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 messageslimit (
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:
- Returns:
- 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
- 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:
- 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:
- async getSavedOrderInfo()[source]
Returns saved order information. Returns a 404 error if there is no saved order information
- 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:
- 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:
- async getSearchedForTags(tag_prefix='', limit=0)[source]
Returns recently searched for hashtags or cashtags by their prefix
- 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:
- 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
- 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:
- async getStarGiveawayPaymentOptions()[source]
Returns available options for Telegram Star giveaway creation
- Return type:
Union
[Error
,StarGiveawayPaymentOptions
]- Returns:
- async getStarPaymentOptions()[source]
Returns available options for Telegram Stars purchase
- Return type:
Union
[Error
,StarPaymentOptions
]- Returns:
- 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 == trueis_dark (
bool
) – Pass true if a dark theme is used by the application
- Return type:
Union
[Error
,StarRevenueStatistics
]- Returns:
- 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 extendoffset (
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:
- 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 == truesubscription_id (
str
) – If non-empty, only transactions related to the Star Subscription will be returneddirection (
"types.TransactionDirection"
) – Direction of the transactions to receive; pass null to get all transactionsoffset (
str
) – Offset of the first transaction to return as received from the previous request; use empty string to get the first chunk of resultslimit (
int
) – The maximum number of transactions to return
- Return type:
Union
[Error
,StarTransactions
]- Returns:
- 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 chatstar_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:
- Returns:
- async getStatisticalGraph(chat_id=0, token='', x=0)[source]
Loads an asynchronous or a zoomed in statistical graph
- Parameters:
chat_id (
int
) – Chat identifiertoken (
str
) – The token for graph loadingx (
int
) – X-value for zoomed in graph or 0 otherwise
- Return type:
Union
[Error
,StatisticalGraph
]- Returns:
- 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
- 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 stickerfor_animated_emoji (
bool
) – Pass true to get the outline scaled for animated emojifor_clicked_animated_emoji_message (
bool
) – Pass true to get the outline scaled for clicked animated emoji message
- Return type:
- Returns:
- 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:
- 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 returnquery (
str
) – Search query; a space-separated list of emojis or a keyword prefix. If empty, returns all known installed stickerslimit (
int
) – The maximum number of stickers to be returnedchat_id (
int
) – Chat identifier for which to return stickers. Available custom emoji stickers may be different for different chats
- Return type:
- Returns:
- 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:
- async getStorageStatisticsFast()[source]
Quickly returns approximate storage usage statistics. Can be called before authorization
- Return type:
Union
[Error
,StorageStatisticsFast
]- Returns:
- 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 identifierstory_album_id (
int
) – Story album identifieroffset (
int
) – Offset of the first entry to return; use 0 to get results from the first album storylimit (
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:
- Returns:
- 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:
- 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 identifierquery (
str
) – Query to search for in names, usernames and titles; may be empty to get all relevant interactionsonly_contacts (
bool
) – Pass true to get only interactions by contacts; pass false to get all relevant interactionsprefer_forwards (
bool
) – Pass true to get forwards and reposts first, then reactions, then other views; pass false to get interactions sorted just by interaction dateprefer_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 == trueoffset (
str
) – Offset of the first entry to return as received from the previous request; use empty string to get the first chunk of resultslimit (
int
) – The maximum number of story interactions to return
- Return type:
Union
[Error
,StoryInteractions
]- Returns:
- async getStoryNotificationSettingsExceptions()[source]
Returns the list of chats with non-default notification settings for stories
- 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 storystory_id (
int
) – The identifier of the storyoffset (
str
) – Offset of the first entry to return as received from the previous request; use empty string to get the first chunk of resultslimit (
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:
- 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 identifierstory_id (
int
) – Story identifieris_dark (
bool
) – Pass true if a dark theme is used by the application
- Return type:
Union
[Error
,StoryStatistics
]- Returns:
- async getSuggestedFileName(file_id=0, directory='')[source]
Returns suggested name for saving a file in a given directory
- async getSuggestedStickerSetName(title='')[source]
Returns a suggested name for a new sticker set with a given title
- 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
- async getSuitablePersonalChats()[source]
Returns a list of channel chats, which can be used as a personal chat
- 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:
- 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:
- 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 channelfilter (
"types.SupergroupMembersFilter"
) – The type of users to return; pass null to use supergroupMembersFilterRecentoffset (
int
) – Number of users to skiplimit (
int
) – The maximum number of users to be returned; up to 200
- Return type:
Union
[Error
,ChatMembers
]- Returns:
- async getSupportName()[source]
Returns localized name of the Telegram support user; for Telegram support only
- async getTemporaryPasswordState()[source]
Returns information about the current temporary password
- Return type:
Union
[Error
,TemporaryPasswordState
]- Returns:
- 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:
- async getThemeParametersJsonString(theme=None)[source]
Converts a themeParameters object to corresponding JSON-serialized string. Can be called synchronously
- 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:
- 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:
- 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:
- 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 transactionsoffset (
str
) – Offset of the first transaction to return as received from the previous request; use empty string to get the first chunk of resultslimit (
int
) – The maximum number of transactions to return
- Return type:
Union
[Error
,TonTransactions
]- Returns:
- 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
- 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 returnoffset (
int
) – The offset from which to return the sticker sets; must be non-negativelimit (
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:
- 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:
- async getUpgradedGiftEmojiStatuses()[source]
Returns available upgraded gift emoji statuses for self status
- Return type:
Union
[Error
,EmojiStatuses
]- Returns:
- 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:
- 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
- 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
- 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 chatuser_id (
int
) – Identifier of the user
- Return type:
Union
[Error
,FoundChatBoosts
]- Returns:
- 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:
- async getUserLink()[source]
Returns an HTTPS link, which can be used to get information about the current user
- async getUserPrivacySettingRules(setting=None)[source]
Returns the current privacy settings
- Parameters:
setting (
"types.UserPrivacySetting"
) – The privacy setting- Return type:
Union
[Error
,UserPrivacySettingRules
]- Returns:
- async getUserProfileAudios(user_id=0, offset=0, limit=0)[source]
Returns the list of profile audio files of a user
- 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 identifieroffset (
int
) – The number of photos to skip; must be non-negativelimit (
int
) – The maximum number of photos to be returned; up to 100
- Return type:
Union
[Error
,ChatPhotos
]- Returns:
- 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:
- 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:
- async getVideoChatInviteLink(group_call_id=0, can_self_unmute=False)[source]
Returns invite link to a video chat in a public chat
- Parameters:
group_call_id (
int
) – Group call identifiercan_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:
- Returns:
- 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
- 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 identifiertime_offset (
int
) – Point in time when the stream segment begins; Unix timestamp in millisecondsscale (
int
) – Segment duration scale; 0-1. Segment’s duration is 1000/(2**scale) millisecondschannel_id (
int
) – Identifier of an audio/video channel to get as received from tgcallsvideo_quality (
"types.GroupCallVideoQuality"
) – Video quality as received from tgcalls; pass null to get the worst available quality
- Return type:
- Returns:
- 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:
- 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 messagemessage_id (
int
) – Identifier of the message
- Return type:
Union
[Error
,VideoMessageAdvertisements
]- Returns:
- 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 nonebot_user_id (
int
) – Identifier of the target botweb_app_short_name (
str
) – Short name of the Web Appstart_parameter (
str
) – Start parameter from internalLinkTypeWebAppallow_write_access (
bool
) – Pass true if the current user allowed the bot to send them messagesparameters (
"types.WebAppOpenParameters"
) – Parameters to use to open the Web App
- Return type:
- Returns:
- 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
- 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 methodurl (
str
) – The URL from a keyboardButtonTypeWebApp button, inlineQueryResultsButtonTypeWebApp button, or an empty string when the bot is opened from the side menuparameters (
"types.WebAppOpenParameters"
) – Parameters to use to open the Web App
- Return type:
- Returns:
- 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 URLonly_local (
bool
) – Pass true to get only locally available information without sending network requests
- Return type:
Union
[Error
,WebPageInstantView
]- Returns:
- 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 Premiumstar_count (
int
) – The number of Telegram Stars to pay for subscriptionmonth_count (
int
) – Number of months the Telegram Premium subscription will be active for the usertext (
"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:
- Returns:
- async hideContactCloseBirthdays()[source]
Hides the list of contacts that have close birthdays for 24 hours
- 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:
- 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 rightmessage_file (
"types.InputFile"
) – File with messages to import. Only inputFileLocal and inputFileGenerated are supported. The file must not be previously uploadedattached_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:
- Returns:
- 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 identifieruser_id (
int
) – User identifieris_video (
bool
) – Pass true if the group call is a video call
- Return type:
- Returns:
- 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
- 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
- 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
- async joinChatByInviteLink(invite_link='')[source]
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
- 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 joinjoin_parameters (
"types.GroupCallJoinParameters"
) – Parameters to join the call
- Return type:
Union
[Error
,GroupCallInfo
]- Returns:
- 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 identifierparticipant_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 onlyjoin_parameters (
"types.GroupCallJoinParameters"
) – Parameters to join the callinvite_hash (
str
) – Invite hash as received from internalLinkTypeVideoChat
- Return type:
- Returns:
- 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 giveawayparameters (
"types.GiveawayParameters"
) – Giveaway parameterswinner_count (
int
) – The number of users to receive giveaway prizestar_count (
int
) – The number of Telegram Stars to be distributed through the giveaway; pass 0 for Telegram Premium giveaways
- Return type:
- Returns:
- async leaveChat(chat_id=0)[source]
Removes the current user from chat members. Private and secret chats can’t be left using this method
- 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
- 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 listlimit (
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:
- Returns:
- 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 chatlimit (
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:
- Returns:
- 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
- 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
- async loadQuickReplyShortcuts()[source]
Loads quick reply shortcuts created by the current user. The loaded data will be sent through updateQuickReplyShortcut and updateQuickReplyShortcuts
- 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
- 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
- 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 messagemessage_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 donemarked_as_done_task_ids (
List[int]
) – Identifiers of tasks that were marked as donemarked_as_not_done_task_ids (
List[int]
) – Identifiers of tasks that were marked as not done
- Return type:
- Returns:
- 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
- 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)
- 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
- 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
- async openSponsoredChat(sponsored_chat_unique_id=0)[source]
Informs TDLib that the user opened a sponsored chat
- 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
- 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 chatsbot_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 methodurl (
str
) – The URL from an inlineKeyboardButtonTypeWebApp button, a botMenuButton button, an internalLinkTypeAttachmentMenuBot link, or an empty string otherwisemessage_thread_id (
int
) – If not 0, the message thread identifier to which the message will be sentdirect_messages_chat_topic_id (
int
) – If not 0, unique identifier of the topic of channel direct messages chat to which the message will be sentreply_to (
"types.InputMessageReplyTo"
) – Information about the message or story to be replied in the message sent by the Web App; pass null if noneparameters (
"types.WebAppOpenParameters"
) – Parameters to use to open the Web App
- Return type:
Union
[Error
,WebAppInfo
]- Returns:
- 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 limitttl (
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 limitcount (
int
) – Limit on the total number of files after deletion. Pass -1 to use the default limitimmunity_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 valuefile_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 deletedchat_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 statisticschat_limit (
int
) – Same as in getStorageStatistics. Affects only returned statistics
- Return type:
Union
[Error
,StorageStatistics
]- Returns:
- 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:
- 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 parseparse_mode (
"types.TextParseMode"
) – Text parse mode
- Return type:
Union
[Error
,FormattedText
]- Returns:
- 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 chatmessage_id (
int
) – Identifier of the new pinned messagedisable_notification (
bool
) – Pass true to disable notification about the pinned message. Notifications are always disabled in channels and private chatsonly_for_self (
bool
) – Pass true to pin the message only for self; private chats only
- Return type:
- Returns:
- 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
- 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 usercontent (
"types.InputStoryContent"
) – Content of the storyareas (
"types.InputStoryAreas"
) – Clickable rectangle areas to be shown on the story media; pass null if nonecaption (
"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 chatsalbum_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 otherwisefrom_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 storyis_posted_to_chat_page (
bool
) – Pass true to keep the story accessible after expirationprotect_content (
bool
) – Pass true if the content of the story must be protected from forwarding and screenshotting
- Return type:
- Returns:
- 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 uploadfile_type (
"types.FileType"
) – File type; pass null if unknownpriority (
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:
- Returns:
- async processChatFolderNewChats(chat_folder_id=0, added_chat_ids=None)[source]
Process new chats added to a shareable chat folder by its owner
- async processChatJoinRequest(chat_id=0, user_id=0, approve=False)[source]
Handles a pending join request in a chat
- 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 identifierinvite_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 linksapprove (
bool
) – Pass true to approve all requests; pass false to decline them
- Return type:
- Returns:
- 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
- async rateSpeechRecognition(chat_id=0, message_id=0, is_good=False)[source]
Rates recognized speech in a video note or a voice note message
- async readAllChatReactions(chat_id=0)[source]
Marks all reactions in a chat or a forum topic as read
- 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
- async readAllMessageThreadMentions(chat_id=0, message_thread_id=0)[source]
Marks all mentions in a forum topic as read
- async readAllMessageThreadReactions(chat_id=0, message_thread_id=0)[source]
Marks all reactions in a forum topic as read
- async readBusinessMessage(business_connection_id='', chat_id=0, message_id=0)[source]
Reads a message on behalf of a business account; for bots only
- async readChatList(chat_list=None)[source]
Traverse all chats in a chat list and marks all messages in the chats as read
- 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 cacheoffset (
int
) – The offset from which to read the filecount (
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:
- Returns:
- 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 shortcutmessage_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:
- async recognizeSpeech(chat_id=0, message_id=0)[source]
Recognizes speech in a video note or a voice note message
- 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
- 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 checknew_password (
str
) – New 2-step verification password of the user; may be empty to remove the passwordnew_hint (
str
) – New password hint; may be empty
- Return type:
Union
[Error
,PasswordState
]- Returns:
- async refundStarPayment(user_id=0, telegram_payment_charge_id='')[source]
Refunds a previously done payment in Telegram Stars; for bots only
- 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 tokenother_user_ids (
List[int]
) – List of user identifiers of other users currently using the application
- Return type:
Union
[Error
,PushReceiverId
]- Returns:
- 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 characterslast_name (
str
) – The last name of the user; 0-64 charactersdisable_notification (
bool
) – Pass true to disable notification about the current user joining Telegram for other users that added them to contact list
- Return type:
- Returns:
- async removeAllFilesFromDownloads(only_active=False, only_completed=False, delete_from_cache=False)[source]
Removes all files from the file download list
- async removeBusinessConnectedBotFromChat(chat_id=0)[source]
Removes the connected business bot from a specific chat by adding the chat to businessRecipients.excluded_chat_ids
- async removeFavoriteSticker(sticker=None)[source]
Removes a sticker from the list of favorite stickers
- async removeFileFromDownloads(file_id=0, delete_from_cache=False)[source]
Removes a file from the file download list
- 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 collectioncollection_id (
int
) – Identifier of the gift collectionreceived_gift_ids (
List[str]
) – Identifier of the gifts to remove from the collection
- Return type:
Union
[Error
,GiftCollection
]- Returns:
- async removeInstalledBackground(background_id=0)[source]
Removes background from the list of installed backgrounds
- 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
- async removeMessageSenderBotVerification(bot_user_id=0, verified_id=None)[source]
Removes the verification status of a user or a chat by an owned bot
- 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
- 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
- async removePendingPaidMessageReactions(chat_id=0, message_id=0)[source]
Removes all pending paid reactions on a message
- async removeProfileAudio(file_id=0)[source]
Removes an audio file from the profile audio files of the current user
- async removeRecentHashtag(hashtag='')[source]
Removes a hashtag from the list of recently used hashtags
- 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 stickerssticker (
"types.InputFile"
) – Sticker file to delete
- Return type:
- Returns:
- async removeRecentlyFoundChat(chat_id=0)[source]
Removes a chat from the list of recently found chats
- async removeSavedAnimation(animation=None)[source]
Removes an animation from the list of saved animations
- async removeSavedNotificationSound(notification_sound_id=0)[source]
Removes a notification sound from the list of saved notification sounds
- async removeSearchedForTag(tag='')[source]
Removes a hashtag or a cashtag from the list of recently searched for hashtags or cashtags
- 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
- 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 storiesstory_album_id (
int
) – Identifier of the story albumstory_ids (
List[int]
) – Identifier of the stories to remove from the album
- Return type:
Union
[Error
,StoryAlbum
]- Returns:
- 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
- async reorderActiveUsernames(usernames=None)[source]
Changes order of active usernames of the current user
- 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
- 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
- async reorderChatFolders(chat_folder_ids=None, main_chat_list_position=0)[source]
Changes the order of chat folders
- 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 collectioncollection_id (
int
) – Identifier of the gift collectionreceived_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:
- 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
- async reorderInstalledStickerSets(sticker_type=None, sticker_set_ids=None)[source]
Changes the order of installed sticker sets
- async reorderQuickReplyShortcuts(shortcut_ids=None)[source]
Changes the order of quick reply shortcuts
- 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 storiesstory_album_id (
int
) – Identifier of the story albumstory_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:
- 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
- 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
- async replacePrimaryChatInviteLink(chat_id=0)[source]
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:
- 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 usersname (
str
) – Sticker set name. The sticker set must be owned by the current userold_sticker (
"types.InputFile"
) – Sticker to remove from the setnew_sticker (
"types.InputSticker"
) – Sticker to add to the set
- Return type:
- Returns:
- 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
- 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
- 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 identifieroption_id (
bytes
) – Option identifier chosen by the user; leave empty for the initial requestmessage_ids (
List[int]
) – Identifiers of reported messages. Use messageProperties.can_report_chat to check whether the message can be reportedtext (
str
) – Additional report details if asked by the server; 0-1024 characters; leave empty for the initial request
- Return type:
Union
[Error
,ReportChatResult
]- Returns:
- 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 identifierfile_id (
int
) – Identifier of the photo to report. Only full photos from chatPhoto can be reportedreason (
"types.ReportReason"
) – The reason for reporting the chat phototext (
str
) – Additional report details; 0-1024 characters
- Return type:
- Returns:
- 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 messagemessage_id (
int
) – Identifier of the sponsored messageoption_id (
bytes
) – Option identifier chosen by the user; leave empty for the initial request
- Return type:
Union
[Error
,ReportSponsoredResult
]- Returns:
- 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
- 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
- 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 chatoption_id (
bytes
) – Option identifier chosen by the user; leave empty for the initial request
- Return type:
Union
[Error
,ReportSponsoredResult
]- Returns:
- 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 reportstory_id (
int
) – The identifier of the story to reportoption_id (
bytes
) – Option identifier chosen by the user; leave empty for the initial requesttext (
str
) – Additional report details; 0-1024 characters; leave empty for the initial request
- Return type:
Union
[Error
,ReportStoryResult
]- Returns:
- 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
- async reportSupergroupSpam(supergroup_id=0, message_ids=None)[source]
Reports messages in a supergroup as spam; requires administrator rights in the supergroup
- 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 advertisementoption_id (
bytes
) – Option identifier chosen by the user; leave empty for the initial request
- Return type:
Union
[Error
,ReportSponsoredResult
]- Returns:
- 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
- async requestPasswordRecovery()[source]
Requests to send a 2-step verification password recovery code to an email address that was previously set up
- Return type:
- Returns:
- 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
- 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
- async resendEmailAddressVerificationCode()[source]
Resends the code to verify an email address to be added to a user’s Telegram Passport
- Return type:
- Returns:
- async resendLoginEmailAddressCode()[source]
Resends the login email address verification code
- Return type:
- Returns:
- 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 messagesmessage_ids (
List[int]
) – Identifiers of the messages to resend. Message identifiers must be in a strictly increasing orderquote (
"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 == falsepaid_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:
- Returns:
- 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:
- async resendRecoveryEmailAddressCode()[source]
Resends the 2-step verification recovery email address verification code
- Return type:
Union
[Error
,PasswordState
]- Returns:
- 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
- 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
- async resetInstalledBackgrounds()[source]
Resets list of installed backgrounds to its default value
- async resetNetworkStatistics()[source]
Resets all network data usage statistics to zero. Can be called before authorization
- 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:
- async reuseStarSubscription(subscription_id='')[source]
Reuses an active Telegram Star subscription to a channel chat and joins the chat again
- async revokeChatInviteLink(chat_id=0, invite_link='')[source]
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 identifierinvite_link (
str
) – Invite link to be revoked
- Return type:
Union
[Error
,ChatInviteLinks
]- Returns:
- async revokeGroupCallInviteLink(group_call_id=0)[source]
Revokes invite link for a group call. Requires groupCall.can_be_managed right for video chats or groupCall.is_owned otherwise
- async saveApplicationLogEvent(type='', chat_id=0, data=None)[source]
Saves application log event on the server. Can be called before authorization
- 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 userresult (
"types.InputInlineQueryResult"
) – The description of the messagechat_types (
"types.TargetChatTypes"
) – Types of the chats to which the message can be sent
- Return type:
Union
[Error
,PreparedInlineMessageId
]- Returns:
- 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 forsort_order (
"types.AffiliateProgramSortOrder"
) – Sort order for the resultsoffset (
str
) – Offset of the first affiliate program to return as received from the previous request; use empty string to get the first chunk of resultslimit (
int
) – The maximum number of affiliate programs to return
- Return type:
Union
[Error
,FoundAffiliatePrograms
]- Returns:
- 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:
- 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 resultslimit (
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 limitonly_missed (
bool
) – Pass true to search only for messages with missed/declined calls
- Return type:
Union
[Error
,FoundMessages
]- Returns:
- async searchChatAffiliateProgram(username='', referrer='')[source]
Searches a chat with an affiliate program. Returns the chat if found and the program is active
- 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 identifierquery (
str
) – Query to search forlimit (
int
) – The maximum number of users to be returned; up to 200filter (
"types.ChatMembersFilter"
) – The type of users to search for; pass null to search among all chat members
- Return type:
Union
[Error
,ChatMembers
]- Returns:
- 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 messagestopic_id (
"types.MessageTopic"
) – Pass topic identifier to search messages only in specific topic; pass null to search for messages in all topicsquery (
str
) – Query to search forsender_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 chatsfrom_message_id (
int
) – Identifier of the message starting from which history must be fetched; use 0 to get results from the last messageoffset (
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 messageslimit (
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 limitfilter (
"types.SearchMessagesFilter"
) – Additional filter for messages to search; pass null to search for all messages
- Return type:
Union
[Error
,FoundChatMessages
]- Returns:
- 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
- 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
- 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
- async searchContacts(query='', limit=0)[source]
Searches for the specified query in the first names, last names and usernames of the known user contacts
- 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 forinput_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:
- 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 filesonly_active (
bool
) – Pass true to search only for active downloads, including pausedonly_completed (
bool
) – Pass true to search only for completed downloadsoffset (
str
) – Offset of the first entry to return as received from the previous request; use empty string to get the first chunk of resultslimit (
int
) – The maximum number of files to be returned
- Return type:
Union
[Error
,FoundFileDownloads
]- Returns:
- 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 giftorder (
"types.GiftForResaleOrder"
) – Order in which the results will be sortedattributes (
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 allowedoffset (
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 resultslimit (
int
) – The maximum number of gifts to return
- Return type:
Union
[Error
,GiftsForResale
]- Returns:
- async searchHashtags(prefix='', limit=0)[source]
Searches for recently used hashtags by their prefix
- 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 forquery (
str
) – Query to search forlimit (
int
) – The maximum number of sticker sets to return
- Return type:
Union
[Error
,StickerSets
]- Returns:
- 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 supportedquery (
str
) – Query to search foroffset (
str
) – Offset of the first entry to return as received from the previous request; use empty string to get the first chunk of resultslimit (
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 limitfilter (
"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 functionchat_type_filter (
"types.SearchMessagesChatTypeFilter"
) – Additional filter for type of the chat of the searched messages; pass null to search for messages in all chatsmin_date (
int
) – If not 0, the minimum date of the messages to returnmax_date (
int
) – If not 0, the maximum date of the messages to return
- Return type:
Union
[Error
,FoundMessages
]- Returns:
- 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 captionlimit (
int
) – The maximum number of messages to be returned; up to 100
- Return type:
Union
[Error
,FoundMessages
]- Returns:
- 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
- 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
- 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 foroffset (
str
) – Offset of the first entry to return as received from the previous request; use empty string to get the first chunk of resultslimit (
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:
- 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 foroffset (
str
) – Offset of the first entry to return as received from the previous request; use empty string to get the first chunk of resultslimit (
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 limitstar_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:
- 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 locationoffset (
str
) – Offset of the first entry to return as received from the previous request; use empty string to get the first chunk of resultslimit (
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:
- 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 chatstag (
str
) – Hashtag or cashtag to search foroffset (
str
) – Offset of the first entry to return as received from the previous request; use empty string to get the first chunk of resultslimit (
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:
- 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 venuevenue_id (
str
) – Identifier of the venue in the provider databaseoffset (
str
) – Offset of the first entry to return as received from the previous request; use empty string to get the first chunk of resultslimit (
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:
- 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 quotequote (
"types.FormattedText"
) – Quote to search forquote_position (
int
) – Approximate quote position in UTF-16 code units
- Return type:
Union
[Error
,FoundPosition
]- Returns:
- 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
- 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 messagestag (
"types.ReactionType"
) – Tag to search for; pass null to return all suitable messagesquery (
str
) – Query to search forfrom_message_id (
int
) – Identifier of the message starting from which messages must be fetched; use 0 to get results from the last messageoffset (
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 messageslimit (
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:
- 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 chatsquery (
str
) – Query to search for. If empty, searchChatMessages must be used insteadoffset (
str
) – Offset of the first entry to return as received from the previous request; use empty string to get the first chunk of resultslimit (
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 limitfilter (
"types.SearchMessagesFilter"
) – Additional filter for messages to search; pass null to search for all messages
- Return type:
Union
[Error
,FoundMessages
]- Returns:
- async searchStickerSet(name='', ignore_cache=False)[source]
Searches for a sticker set by its name
- Parameters:
name (
str
) – Name of the sticker setignore_cache (
bool
) – Pass true to ignore local cache of sticker sets and always send a network request
- Return type:
Union
[Error
,StickerSet
]- Returns:
- 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 returnquery (
str
) – Query to search for
- Return type:
Union
[Error
,StickerSets
]- Returns:
- 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 returnemojis (
str
) – Space-separated list of emojis to search forquery (
str
) – Query to search for; may be empty to search for emoji onlyinput_language_codes (
List[str]
) – List of possible IETF language tags of the user’s input language; may be empty if unknownoffset (
int
) – The offset from which to return the stickers; must be non-negativelimit (
int
) – The maximum number of stickers to be returned; 0-100
- Return type:
- Returns:
- 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 queryquery (
str
) – Query to search forlimit (
int
) – The maximum number of objects to returnreturn_none_for_empty_query (
bool
) – Pass true to receive no results for an empty query
- Return type:
Union
[Error
,FoundPositions
]- Returns:
- 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
- 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 botweb_app_short_name (
str
) – Short name of the Web App
- Return type:
Union
[Error
,FoundWebApp
]- Returns:
- async sellGift(business_connection_id='', received_gift_id='')[source]
Sells a gift for Telegram Stars; requires owner privileges for gifts owned by a chat
- 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
- 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 botchat_id (
int
) – Identifier of the target chatparameter (
str
) – A hidden parameter sent to the bot for deep linking purposes (https://core.telegram.org/bots#deep-linking)
- Return type:
- Returns:
- 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 requestchat_id (
int
) – Target chatreply_to (
"types.InputMessageReplyTo"
) – Information about the message to be replied; pass null if nonedisable_notification (
bool
) – Pass true to disable notification for the messageprotect_content (
bool
) – Pass true if the content of the message must be protected from forwarding and savingeffect_id (
int
) – Identifier of the effect to apply to the messagereply_markup (
"types.ReplyMarkup"
) – Markup for replying to the message; pass null if noneinput_message_content (
"types.InputMessageContent"
) – The content of the message to be sent
- Return type:
Union
[Error
,BusinessMessage
]- Returns:
- 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 requestchat_id (
int
) – Target chatreply_to (
"types.InputMessageReplyTo"
) – Information about the message to be replied; pass null if nonedisable_notification (
bool
) – Pass true to disable notification for the messageprotect_content (
bool
) – Pass true if the content of the message must be protected from forwarding and savingeffect_id (
int
) – Identifier of the effect to apply to the messageinput_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:
- async sendCallDebugInformation(call_id=0, debug_information='')[source]
Sends debug information for a call to Telegram servers
- 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 identifiermessage_thread_id (
int
) – If not 0, the message thread identifier in which the action was performedbusiness_connection_id (
str
) – Unique identifier of business connection on behalf of which to send the request; for bots onlyaction (
"types.ChatAction"
) – The action description; pass null to cancel the currently active action
- Return type:
- Returns:
- async sendCustomRequest(method='', parameters='')[source]
Sends a custom request; for bots only
- Parameters:
method (
str
) – The method nameparameters (
str
) – JSON-serialized method parameters
- Return type:
Union
[Error
,CustomRequestResult
]- Returns:
- 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:
- Returns:
- 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 sendowner_id (
"types.MessageSender"
) – Identifier of the user or the channel chat that will receive the gift; limited gifts can’t be sent to channel chatstext (
"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 messagesis_private (
bool
) – Pass true to show gift text and sender only to the gift receiver; otherwise, everyone will be able to see thempay_for_upgrade (
bool
) – Pass true to additionally pay for the gift upgrade and allow the receiver to upgrade it for free
- Return type:
- Returns:
- 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 chatmessage_thread_id (
int
) – If not 0, the message thread identifier in which the message will be sentreply_to (
"types.InputMessageReplyTo"
) – Information about the message or story to be replied; pass null if noneoptions (
"types.MessageSendOptions"
) – Options to be used to send the message; pass null to use default optionsquery_id (
int
) – Identifier of the inline queryresult_id (
str
) – Identifier of the inline query resulthide_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:
- Returns:
- 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 chatmessage_thread_id (
int
) – If not 0, the message thread identifier in which the message will be sentreply_to (
"types.InputMessageReplyTo"
) – Information about the message or story to be replied; pass null if noneoptions (
"types.MessageSendOptions"
) – Options to be used to send the message; pass null to use default optionsreply_markup (
"types.ReplyMarkup"
) – Markup for replying to the message; pass null if none; for bots onlyinput_message_content (
"types.InputMessageContent"
) – The content of the message to be sent
- Return type:
- Returns:
- 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 chatmessage_thread_id (
int
) – If not 0, the message thread identifier in which the messages will be sentreply_to (
"types.InputMessageReplyTo"
) – Information about the message or story to be replied; pass null if noneoptions (
"types.MessageSendOptions"
) – Options to be used to send the messages; pass null to use default optionsinput_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:
- Returns:
- 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
- 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 invoicepayment_form_id (
int
) – Payment form identifier returned by getPaymentFormorder_info_id (
str
) – Identifier returned by validateOrderInfo, or an empty stringshipping_option_id (
str
) – Identifier of a chosen shipping option, if applicablecredentials (
"types.InputCredentials"
) – The credentials chosen by user for payment; pass null for a payment in Telegram Starstip_amount (
int
) – Chosen by the user amount of tip in the smallest units of the currency
- Return type:
Union
[Error
,PaymentResult
]- Returns:
- 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 formatsettings (
"types.PhoneNumberAuthenticationSettings"
) – Settings for the authentication of the user’s phone number; pass null to use default settingstype (
"types.PhoneNumberCodeType"
) – Type of the request for which the code is sent
- Return type:
Union
[Error
,AuthenticationCodeInfo
]- Returns:
- 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
- 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 usershortcut_id (
int
) – Unique identifier of the quick reply shortcutsending_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:
- Returns:
- 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 sendowner_id (
"types.MessageSender"
) – Identifier of the user or the channel chat that will receive the giftprice (
"types.GiftResalePrice"
) – The price that the user agreed to pay for the gift
- Return type:
Union
[Error
,GiftResaleResult
]- Returns:
- 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 botmethod (
str
) – The method nameparameters (
str
) – JSON-serialized method parameters
- Return type:
Union
[Error
,CustomRequestResult
]- Returns:
- async sendWebAppData(bot_user_id=0, button_text='', data='')[source]
Sends data received from a keyboardButtonTypeWebApp Web App to a bot
- 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
- async setAccountTtl(ttl=None)[source]
Changes the period of inactivity after which the account of the current user will automatically be deleted
- async setAlarm(seconds=0.0)[source]
Succeeds after a specified amount of time has passed. Can be called before initialization
- 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 updateApplicationRecaptchaVerificationRequiredtoken (
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:
- Returns:
- async setArchiveChatListSettings(settings=None)[source]
Changes settings for automatic moving of chats to and from the Archive chat lists
- 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
- 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
- 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 transactionis_restore (
bool
) – Pass true if this is a restore of a Telegram Premium purchase; only for App Storecurrency (
str
) – ISO 4217 currency code of the payment currencyamount (
int
) – Paid amount, in the smallest units of the currency
- Return type:
- Returns:
- 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
- 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 botlanguage_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 descriptiondescription (
str
) – New bot’s description on the specified language
- Return type:
- Returns:
- 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 botlanguage_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 descriptionshort_description (
str
) – New bot’s short description on the specified language
- Return type:
- Returns:
- 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 botlanguage_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 namename (
str
) – New bot’s name on the specified language; 0-64 characters; must be non-empty if language code is empty
- Return type:
- Returns:
- 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
- async setBusinessAccountBio(business_connection_id='', bio='')[source]
Changes the bio of a business account; for bots only
- async setBusinessAccountGiftSettings(business_connection_id='', settings=None)[source]
Changes settings for gift receiving of a business account; for bots only
- 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 connectionfirst_name (
str
) – The new value of the first name for the business account; 1-64 characterslast_name (
str
) – The new value of the optional last name for the business account; 0-64 characters
- Return type:
- Returns:
- 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 connectionphoto (
"types.InputChatPhoto"
) – Profile photo to set; pass null to remove the photois_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:
- Returns:
- async setBusinessAccountUsername(business_connection_id='', username='')[source]
Changes the editable username of a business account; for bots only
- async setBusinessAwayMessageSettings(away_message_settings=None)[source]
Changes the business away message settings of the current user. Requires Telegram Business subscription
- async setBusinessConnectedBot(bot=None)[source]
Adds or changes business bot that is connected to the current user account
- async setBusinessGreetingMessageSettings(greeting_message_settings=None)[source]
Changes the business greeting message settings of the current user. Requires Telegram Business subscription
- async setBusinessLocation(location=None)[source]
Changes the business location of the current user. Requires Telegram Business subscription
- 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 sentchat_id (
int
) – The chat the message belongs tomessage_id (
int
) – Identifier of the messageis_pinned (
bool
) – Pass true to pin the message, pass false to unpin it
- Return type:
- Returns:
- async setBusinessOpeningHours(opening_hours=None)[source]
Changes the business opening hours of the current user. Requires Telegram Business subscription
- async setBusinessStartPage(start_page=None)[source]
Changes the business start page of the current user. Requires Telegram Business subscription
- 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 identifieraccent_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 colorbackground_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:
- Returns:
- async setChatActiveStoriesList(chat_id=0, story_list=None)[source]
Changes story list in which stories from the chat are shown
- 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 changedparameters (
"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:
- Returns:
- 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 chatavailable_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:
- Returns:
- 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 identifierbackground (
"types.InputBackground"
) – The input background to use; pass null to create a new filled or chat theme backgroundtype (
"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 chatdark_theme_dimming (
int
) – Dimming of the background in dark themes, as a percentage; 0-100. Applied only to Wallpaper and Fill types of backgroundonly_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:
- Returns:
- async setChatClientData(chat_id=0, client_data='')[source]
Changes application-specific data associated with a chat
- 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
- 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 chatis_enabled (
bool
) – Pass true if the direct messages group is enabled for the channel chat; pass false otherwisepaid_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:
- Returns:
- 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:
- Returns:
- 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 identifiermessage_thread_id (
int
) – If not 0, the message thread identifier in which the draft was changeddraft_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:
- Returns:
- 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
- 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
- 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
- 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).
- async setChatMessageSender(chat_id=0, message_sender_id=None)[source]
Selects a message sender to send messages in a chat
- 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
- 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 chatpaid_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:
- Returns:
- 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
- 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
- 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 storiesstory_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:
- Returns:
- 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 identifierprofile_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 colorprofile_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:
- Returns:
- 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
- async setChatTheme(chat_id=0, theme=None)[source]
Changes the chat theme. Supported only in private and secret chats
- 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
- 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 scopelanguage_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 commandscommands (
List["types.BotCommand"]
) – List of the bot’s commands
- Return type:
- Returns:
- async setCustomEmojiStickerSetThumbnail(name='', custom_emoji_id=0)[source]
Sets a custom emoji sticker set thumbnail
- 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 authorizationstrings (
List["types.LanguagePackString"]
) – Strings of the new language pack
- Return type:
- Returns:
- 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
- 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
- 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 backgroundtype (
"types.BackgroundType"
) – Background type; pass null to use the default type of the remote background; backgroundTypeChatTheme isn’t supportedfor_dark_theme (
bool
) – Pass true if the background is set for a dark theme
- Return type:
Union
[Error
,Background
]- Returns:
- async setDefaultChannelAdministratorRights(default_channel_administrator_rights=None)[source]
Sets default administrator rights for adding the bot to channel chats; for bots only
- 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
- async setDefaultMessageAutoDeleteTime(message_auto_delete_time=None)[source]
Changes the default message auto-delete time for new chats
- async setDefaultReactionType(reaction_type=None)[source]
Changes type of default reaction for the current user
- 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 identifiertopic_id (
int
) – Topic identifierdraft_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:
- Returns:
- 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
- async setEmojiStatus(emoji_status=None)[source]
Changes the emoji status of the current user; for Telegram Premium users only
- async setFileGenerationProgress(generation_id=0, expected_size=0, local_prefix_size=0)[source]
Informs TDLib on a file generation progress
- 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 identifiermessage_thread_id (
int
) – Message thread identifier of the forum topicnotification_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:
- Returns:
- 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 belongsmessage_id (
int
) – Identifier of the messageedit_message (
bool
) – Pass true to edit the game message to include the current scoreboarduser_id (
int
) – User identifierscore (
int
) – The new scoreforce (
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:
- Returns:
- 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 collectioncollection_id (
int
) – Identifier of the gift collectionname (
str
) – New name of the collection; 1-12 characters
- Return type:
Union
[Error
,GiftCollection
]- Returns:
- 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 giftprice (
"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:
- Returns:
- async setGiftSettings(settings=None)[source]
Changes settings for gift receiving for the current user
- 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 identifieraudio_source (
int
) – Group call participant’s synchronization audio source identifier, or 0 for the current useris_speaking (
bool
) – Pass true if the user is speaking
- Return type:
Union
[Error
,MessageSender
]- Returns:
- 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
- async setInactiveSessionTtl(inactive_session_ttl_days=0)[source]
Changes the period of inactivity after which sessions will automatically be terminated
- 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 identifieredit_message (
bool
) – Pass true to edit the game message to include the current scoreboarduser_id (
int
) – User identifierscore (
int
) – The new scoreforce (
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:
- Returns:
- async setLogStream(log_stream=None)[source]
Sets new log stream for internal logging of TDLib. Can be called synchronously
- async setLogTagVerbosityLevel(tag='', new_verbosity_level=0)[source]
Sets the verbosity level for a specified TDLib internal log tag. Can be called synchronously
- 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:
- Returns:
- 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:
- Returns:
- async setMainProfileTab(main_profile_tab=None)[source]
Changes the main profile tab of the current user
- async setMenuButton(user_id=0, menu_button=None)[source]
Sets menu button for the given user or for all users; for bots only
- 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 tomessage_id (
int
) – Identifier of the messagetext (
"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:
- Returns:
- 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 belongsmessage_id (
int
) – Identifier of the messagereaction_types (
List["types.ReactionType"]
) – Types of the reaction to set; pass an empty list to remove the reactionsis_big (
bool
) – Pass true if the reactions are added with a big animation
- Return type:
- Returns:
- 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
- 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 chatverified_id (
"types.MessageSender"
) – Identifier of the user or the supergroup or channel chat, which will be verified by the botcustom_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:
- Returns:
- async setName(first_name='', last_name='')[source]
Changes the first and last name of the current user
- 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
- async setNewChatPrivacySettings(settings=None)[source]
Changes privacy settings for new chat creation; can be used only if getOption("can_set_new_chat_privacy_settings")
- 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
- 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
- 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 elementpassword (
str
) – The 2-step verification password of the current user
- Return type:
Union
[Error
,PassportElement
]- Returns:
- 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
- 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 usernew_password (
str
) – New 2-step verification password of the user; may be empty to remove the passwordnew_hint (
str
) – New password hint; may be emptyset_recovery_email_address (
bool
) – Pass true to change also the recovery email addressnew_recovery_email_address (
str
) – New recovery email address; may be empty
- Return type:
Union
[Error
,PasswordState
]- Returns:
- 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
- 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 giftsreceived_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:
- Returns:
- async setPinnedSavedMessagesTopics(saved_messages_topic_ids=None)[source]
Changes the order of pinned Saved Messages topics
- 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 belongsmessage_id (
int
) – Identifier of the message containing the polloption_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:
- Returns:
- 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
- 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 changedafter_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:
- Returns:
- async setProfilePhoto(photo=None, is_public=False)[source]
Changes a profile photo for the current user
- async setQuickReplyShortcutName(shortcut_id=0, name='')[source]
Changes name of a quick reply shortcut
- async setReactionNotificationSettings(notification_settings=None)[source]
Changes notification settings for reactions
- async setReadDatePrivacySettings(settings=None)[source]
Changes privacy settings for message read date
- 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 usernew_recovery_email_address (
str
) – New recovery email address
- Return type:
Union
[Error
,PasswordState
]- Returns:
- async setSavedMessagesTagLabel(tag=None, label='')[source]
Changes label of a Saved Messages tag; for Telegram Premium users only
- async setScopeNotificationSettings(scope=None, notification_settings=None)[source]
Changes notification settings for chats of a given type
- 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
- 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
- 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
- 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
- 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 usersname (
str
) – Sticker set name. The sticker set must be owned by the current userthumbnail (
"types.InputFile"
) – Thumbnail to set; pass null to remove the sticker set thumbnailformat (
"types.StickerFormat"
) – Format of the thumbnail; pass null if thumbnail is removed
- Return type:
- Returns:
- 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 storiesstory_album_id (
int
) – Identifier of the story albumname (
str
) – New name of the album; 1-12 characters
- Return type:
Union
[Error
,StoryAlbum
]- Returns:
- 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
- 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 storystory_id (
int
) – The identifier of the storyreaction_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 setupdate_recent_reactions (
bool
) – Pass true if the reaction needs to be added to recent reactions
- Return type:
- Returns:
- 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
- async setSupergroupMainProfileTab(supergroup_id=0, main_profile_tab=None)[source]
Changes the main profile tab of the channel; requires can_change_info administrator right
- async setSupergroupStickerSet(supergroup_id=0, sticker_set_id=0)[source]
Changes the sticker set of a supergroup; requires can_change_info administrator right
- 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
- async setSupergroupUsername(supergroup_id=0, username='')[source]
Changes the editable username of a supergroup or channel, requires owner privileges in the supergroup or channel
- 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 environmentdatabase_directory (
str
) – The path to the directory for the persistent database; if empty, the current working directory will be usedfiles_directory (
str
) – The path to the directory for storing files; if empty, database_directory will be useddatabase_encryption_key (
bytes
) – Encryption key for the database. If the encryption key is invalid, then an error with code 401 will be returneduse_file_database (
bool
) – Pass true to keep information about downloaded and uploaded files between application restartsuse_chat_info_database (
bool
) – Pass true to keep cache of users, basic groups, supergroups, channels and secret chats between restarts. Implies use_file_databaseuse_message_database (
bool
) – Pass true to keep cache of chats and messages between restarts. Implies use_chat_info_databaseuse_secret_chats (
bool
) – Pass true to enable support for secret chatsapi_id (
int
) – Application identifier for Telegram API access, which can be obtained at https://my.telegram.orgapi_hash (
str
) – Application identifier hash for Telegram API access, which can be obtained at https://my.telegram.orgsystem_language_code (
str
) – IETF language tag of the user’s operating system language; must be non-emptydevice_model (
str
) – Model of the device the application is being run on; must be non-emptysystem_version (
str
) – Version of the operating system the application is being run on. If empty, the version is automatically detected by TDLibapplication_version (
str
) – Application version; must be non-empty
- Return type:
- Returns:
- async setUserEmojiStatus(user_id=0, emoji_status=None)[source]
Changes the emoji status of a user; for bots only
- async setUserPersonalProfilePhoto(user_id=0, photo=None)[source]
Changes a personal profile photo of a contact user
- async setUserSupportInfo(user_id=0, message=None)[source]
Sets support information for the given user; for Telegram support only
- Parameters:
user_id (
int
) – User identifiermessage (
"types.FormattedText"
) – New information message
- Return type:
Union
[Error
,UserSupportInfo
]- Returns:
- 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
- async setVideoChatTitle(group_call_id=0, title='')[source]
Sets title of a video chat; requires groupCall.can_be_managed right
Shares a chat after pressing a keyboardButtonTypeRequestChat button with the bot
- Parameters:
chat_id (
int
) – Identifier of the chat with the botmessage_id (
int
) – Identifier of the message with the buttonbutton_id (
int
) – Identifier of the buttonshared_chat_id (
int
) – Identifier of the shared chatonly_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:
- Returns:
Shares the phone number of the current user with a mutual contact. Supposed to be called when the user clicks on chatActionBarSharePhoneNumber
Shares users after pressing a keyboardButtonTypeRequestUsers button with the bot
- Parameters:
chat_id (
int
) – Identifier of the chat with the botmessage_id (
int
) – Identifier of the message with the buttonbutton_id (
int
) – Identifier of the buttonshared_user_ids (
List[int]
) – Identifiers of the shared usersonly_check (
bool
) – Pass true to check that the users can be shared by the button instead of actually sharing them
- Return type:
- Returns:
- 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 identifiertitle (
str
) – Group call recording title; 0-64 charactersrecord_video (
bool
) – Pass true to record a video file instead of an audio fileuse_portrait_orientation (
bool
) – Pass true to use portrait orientation for video instead of landscape one
- Return type:
- Returns:
- 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
- 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 sentchat_id (
int
) – The chat the message belongs tomessage_id (
int
) – Identifier of the message containing the pollreply_markup (
"types.ReplyMarkup"
) – The new message reply markup; pass null if none
- Return type:
Union
[Error
,BusinessMessage
]- Returns:
- 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 belongsmessage_id (
int
) – Identifier of the message containing the poll. Use messageProperties.can_be_edited to check whether the poll can be stoppedreply_markup (
"types.ReplyMarkup"
) – The new message reply markup; pass null if none; for bots only
- Return type:
- Returns:
- async suggestUserProfilePhoto(user_id=0, photo=None)[source]
Suggests a profile photo to another regular user with common messages and allowing non-paid messages
- 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
- async testCallBytes(x=b'')[source]
Returns the received bytes; for testing only. This is an offline method. Can be called before authorization
- async testCallEmpty()[source]
Does nothing; for testing only. This is an offline method. Can be called before authorization
- 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:
- 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:
- 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:
- 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:
- 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:
- async testGetDifference()[source]
Forces an updates.getDifference call to the Telegram servers; for testing only
- async testNetwork()[source]
Sends a simple network request to the Telegram servers; for testing only. Can be called before authorization
- 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 addressport (
int
) – Proxy server porttype (
"types.ProxyType"
) – Proxy typedc_id (
int
) – Identifier of a datacenter with which to test connectiontimeout (
float
) – The maximum overall timeout for the request
- Return type:
- Returns:
- async testReturnError(error=None)[source]
Returns the specified error and ensures that the Error object is used; for testing only. Can be called synchronously
- async testSquareInt(x=0)[source]
Returns the squared received number; for testing only. This is an offline method. Can be called before authorization
- 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
- async toggleAllDownloadsArePaused(are_paused=False)[source]
Changes pause state of all files in the file download list
- async toggleBotCanManageEmojiStatus(bot_user_id=0, can_manage_emoji_status=False)[source]
Toggles whether the bot can manage emoji status of the current user
- 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 identifieris_added (
bool
) – Pass true to add the bot to attachment menu; pass false to remove the bot from attachment menuallow_write_access (
bool
) – Pass true if the current user allowed the bot to send them messages. Ignored if is_added is false
- Return type:
- Returns:
- 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
- async toggleBusinessConnectedBotChatIsPaused(chat_id=0, is_paused=False)[source]
Pauses or resumes the connected business bot in a specific chat
- 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
- async toggleChatFolderTags(are_tags_enabled=False)[source]
Toggles whether chat folder tags are enabled
- 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
- 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
- async toggleChatIsMarkedAsUnread(chat_id=0, is_marked_as_unread=False)[source]
Changes the marked as unread state of a chat
- 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
- async toggleChatIsTranslatable(chat_id=0, is_translatable=False)[source]
Changes the translatable state of a chat
- async toggleChatViewAsTopics(chat_id=0, view_as_topics=False)[source]
Changes the view_as_topics setting of a forum chat or Saved Messages
- 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 identifiertopic_id (
int
) – Identifier of the topiccan_send_unpaid_messages (
bool
) – Pass true to allow unpaid messages; pass false to disallow unpaid messagesrefund_payments (
bool
) – Pass true to refund the user previously paid messages
- Return type:
- Returns:
- async toggleDownloadIsPaused(file_id=0, is_paused=False)[source]
Changes pause state of a file in the file download list
- 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
- 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
- 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
- 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
- async toggleGroupCallIsMyVideoEnabled(group_call_id=0, is_my_video_enabled=False)[source]
Toggles whether current user’s video is enabled
- async toggleGroupCallIsMyVideoPaused(group_call_id=0, is_my_video_paused=False)[source]
Toggles whether current user’s video is paused
- 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 identifierparticipant_id (
"types.MessageSender"
) – Participant identifieris_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:
- Returns:
- 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
- async toggleGroupCallScreenSharingIsPaused(group_call_id=0, is_paused=False)[source]
Pauses or unpauses screen sharing in a joined group call
- 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
- 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
- async toggleSessionCanAcceptCalls(session_id=0, can_accept_calls=False)[source]
Toggles whether a session can accept incoming calls
- async toggleSessionCanAcceptSecretChats(session_id=0, can_accept_secret_chats=False)[source]
Toggles whether a session can accept incoming secret chats
- 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
- 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
- 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
- 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
- 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
- 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
- async toggleSupergroupIsBroadcastGroup(supergroup_id=0)[source]
Upgrades supergroup to a broadcast group; requires owner privileges in the supergroup
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- async transferBusinessAccountStars(business_connection_id='', star_count=0)[source]
Transfer Telegram Stars from the business account to the business bot; for bots only
- 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
- 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 onlyreceived_gift_id (
str
) – Identifier of the giftnew_owner_id (
"types.MessageSender"
) – Identifier of the user or the channel chat that will receive the giftstar_count (
int
) – The amount of Telegram Stars required to pay for the transfer
- Return type:
- Returns:
- 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 belongsmessage_id (
int
) – Identifier of the messageto_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:
- 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 translateto_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:
- 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
- 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
- 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
- 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
- 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
- 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 onlyreceived_gift_id (
str
) – Identifier of the giftkeep_original_details (
bool
) – Pass true to keep the original gift text, sender and receiver in the upgraded giftstar_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:
- 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 userssticker_format (
"types.StickerFormat"
) – Sticker formatsticker (
"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:
- Returns:
- 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 invoiceorder_info (
"types.OrderInfo"
) – The order information, provided by the user; pass null if emptyallow_save (
bool
) – Pass true to save the order information
- Return type:
Union
[Error
,ValidatedOrderInfo
]- Returns:
- 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 identifiermessage_ids (
List[int]
) – The identifiers of the messages being viewedsource (
"types.MessageSource"
) – Source of the message view; pass null to guess the source based on chat open stateforce_read (
bool
) – Pass true to mark as read the specified messages even if the chat is closed
- Return type:
- Returns:
- async viewPremiumFeature(feature=None)[source]
Informs TDLib that the user viewed detailed information about a Premium feature on the Premium features screen
- async viewSponsoredChat(sponsored_chat_unique_id=0)[source]
Informs TDLib that the user fully viewed a sponsored chat
- async viewTrendingStickerSets(sticker_set_ids=None)[source]
Informs the server that some trending sticker sets have been viewed by the user
- async viewVideoMessageAdvertisement(advertisement_unique_id=0)[source]
Informs TDLib that the user viewed a video message advertisement