Client Reference¶
This page refers to the Client and all its methods, which are the same described in the
official documentation, changed from camelCase to snake_case.
E.g. sendMessage becomes send_message.
They are all asynchronous, so you must use them in await expression.
Note: Webhook has not been implemented yet.
- class apitele.Client(token, *, proxy=None, debug=None, deep_debug=None)[source]¶
Main class to communicate with the Telegram Bot API.
- Parameters:
token (
str) – Api token obtained from @BotFather.proxy (
str, optional) – Pass a proxy string to be used in the http requests.debug (
bool, optional) – PassTruefor some debug information.deep_debug (
bool, optional) – PassTruefor more debug information about http requests.
- async add_sticker_to_set(user_id, name, sticker)[source]¶
https://core.telegram.org/bots/api#addstickertoset
Use this method to add a new sticker to a set created by the bot. Emoji sticker sets can have up to 200 stickers. Other sticker sets can have up to 120 stickers. Returns
Trueon success.- Parameters:
user_id (
int) – User identifier of sticker set owner.name (
str) – Sticker set name.sticker (
InputSticker) – A JSON-serialized object with information about the added sticker. If exactly the same sticker had already been added to the set, then the set isn’t changed.
- Return type:
True
- async answer_callback_query(callback_query_id, text=None, show_alert=None, url=None, cache_time=None)[source]¶
https://core.telegram.org/bots/api#answercallbackquery
Use this method to send answers to callback queries sent from inline keyboards. The answer will be displayed to the user as a notification at the top of the chat screen or as an alert. On success,
Trueis returned.Alternatively, the user can be redirected to the specified Game URL. For this option to work, you must first create a game for your bot via @BotFather and accept the terms. Otherwise, you may use links like
t.me/your_bot?start=XXXXthat open your bot with a parameter.- Parameters:
callback_query_id (
str) – Unique identifier for the query to be answered.text (
str, optional) – Text of the notification. If not specified, nothing will be shown to the user, 0-200 characters.show_alert (
bool, optional) – IfTrue, an alert will be shown by the client instead of a notification at the top of the chat screen. Defaults toFalse.url (
str, optional) –URL that will be opened by the user’s client. If you have created a
Gameand accepted the conditions via @BotFather, specify the URL that opens your game - note that this will only work if the query comes from acallback_gamebutton.Otherwise, you may use links like
t.me/your_bot?start=XXXXthat open your bot with a parameter.cache_time (
int, optional) – The maximum amount of time in seconds that the result of the callback query may be cached client-side. Telegram apps will support caching starting in version 3.14. Defaults to0.
- Return type:
True
- async answer_inline_query(inline_query_id, results, cache_time=None, is_personal=None, next_offset=None, button=None)[source]¶
https://core.telegram.org/bots/api#answerinlinequery
Use this method to send answers to an inline query. On success,
Trueis returned. No more than 50 results per query are allowed.- Parameters:
inline_query_id (
str) – Unique identifier for the answered query.results (
listofInlineQueryResult) – A JSON-serialized array of results for the inline query.cache_time (
int, optional) – The maximum amount of time in seconds that the result of the inline query may be cached on the server. Defaults to300.is_personal (
bool, optional) – PassTrueif results may be cached on the server side only for the user that sent the query. By default, results may be returned to any user who sends the same query.next_offset (
str, optional) – Pass the offset that a client should send in the next query with the same text to receive more results. Pass an empty string if there are no more results or if you don’t support pagination. Offset length can’t exceed 64 bytes.button (
InlineQueryResultsButton, optional) – A JSON-serialized object describing a button to be shown above inline query results.
- Return type:
True
- async answer_pre_checkout_query(pre_checkout_query_id, ok, error_message=None)[source]¶
https://core.telegram.org/bots/api#answerprecheckoutquery
Once the user has confirmed their payment and shipping details, the Bot API sends the final confirmation in the form of an
Updatewith the field pre_checkout_query. Use this method to respond to such pre-checkout queries. On success,Trueis returned. Note: The Bot API must receive an answer within 10 seconds after the pre-checkout query was sent.- Parameters:
pre_checkout_query_id (
str) – Unique identifier for the query to be answered.ok (
bool) – SpecifyTrueif everything is alright (goods are available, etc.) and the bot is ready to proceed with the order. UseFalseif there are any problems.error_message (
str, optional) – Required if ok isFalse. Error message in human readable form that explains the reason for failure to proceed with the checkout (e.g. “Sorry, somebody just bought the last of our amazing black T-shirts while you were busy filling out your payment details. Please choose a different color or garment!”). Telegram will display this message to the user.
- Return type:
True
- async answer_shipping_query(shipping_query_id, ok, shipping_options=None, error_message=None)[source]¶
https://core.telegram.org/bots/api#answershippingquery
If you sent an invoice requesting a shipping address and the parameter is_flexible was specified, the Bot API will send an
Updatewith a shipping_query field to the bot. Use this method to reply to shipping queries. On success,Trueis returned.- Parameters:
shipping_query_id (
str) – Unique identifier for the query to be answered.ok (
bool) – PassTrueif delivery to the specified address is possible andFalseif there are any problems (for example, if delivery to the specified address is not possible).shipping_options (
listofShippingOption, optional) – Required if ok isTrue. A JSON-serialized array of available shipping options.error_message (
str, optional) – Required if ok isFalse. Error message in human readable form that explains why it is impossible to complete the order (e.g. “Sorry, delivery to your desired address is unavailable”). Telegram will display this message to the user.
- Return type:
True
- async answer_web_app_query(web_app_query_id, result)[source]¶
https://core.telegram.org/bots/api#answerwebappquery
Use this method to set the result of an interaction with a Web App and send a corresponding message on behalf of the user to the chat from which the query originated. On success, a
SentWebAppMessageobject is returned.- Parameters:
web_app_query_id (
str) – Unique identifier for the query to be answered.result (
InlineQueryResult) – A JSON-serialized object describing the message to be sent.
- Return type:
- async approve_chat_join_request(chat_id, user_id)[source]¶
https://core.telegram.org/bots/api#approvechatjoinrequest
Use this method to approve a chat join request. The bot must be an administrator in the chat for this to work and must have the can_invite_users administrator right. Returns
Trueon success.- Parameters:
chat_id (
intorstr) – Unique identifier for the target chat or username of the target channel (in the format@channelusername).user_id (
int) – Unique identifier of the target user.
- Return type:
True
- async approve_suggested_post(chat_id, message_id, send_date=None)[source]¶
https://core.telegram.org/bots/api#approvesuggestedpost
Use this method to approve a suggested post in a direct messages chat. The bot must have the ‘can_post_messages’ administrator right in the corresponding channel chat. Returns
Trueon success.- Parameters:
chat_id (
int) – Unique identifier for the target direct messages chat.message_id (
int) – Identifier of a suggested post message to approve.send_date (
int, optional) – Point in time (Unix timestamp) when the post is expected to be published; omit if the date has already been specified when the suggested post was created. If specified, then the date must be not more than 2678400 seconds (30 days) in the future.
- Return type:
True
- async ban_chat_member(chat_id, user_id, until_date=None, revoke_messages=None)[source]¶
https://core.telegram.org/bots/api#banchatmember
Use this method to ban a user in a group, a supergroup or a channel. In the case of supergroups and channels, the user will not be able to return to the chat on their own using invite links, etc., unless
unbannedfirst. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. ReturnsTrueon success.- Parameters:
chat_id (
intorstr) – Unique identifier for the target group or username of the target supergroup or channel (in the format@channelusername).user_id (
int) – Unique identifier of the target user.until_date (
int, optional) – Date when the user will be unbanned; Unix time. If user is banned for more than 366 days or less than 30 seconds from the current time they are considered to be banned forever. Applied for supergroups and channels only.revoke_messages (
bool, optional) – PassTrueto delete all messages from the chat for the user that is being removed. IfFalse, the user will be able to see messages in the group that were sent before the user was removed. AlwaysTruefor supergroups and channels.
- Return type:
True
- async ban_chat_sender_chat(chat_id, sender_chat_id)[source]¶
https://core.telegram.org/bots/api#banchatsenderchat
Use this method to ban a channel chat in a supergroup or a channel. Until the chat is
unbanned, the owner of the banned chat won’t be able to send messages on behalf of any of their channels. The bot must be an administrator in the supergroup or channel for this to work and must have the appropriate administrator rights. ReturnsTrueon success.- Parameters:
chat_id (
intorstr) – Unique identifier for the target chat or username of the target channel (in the format@channelusername).sender_chat_id (
int) – Unique identifier of the target sender chat.
- Return type:
True
- async close()[source]¶
https://core.telegram.org/bots/api#close
Use this method to close the bot instance before moving it from one local server to another. You need to delete the webhook before calling this method to ensure that the bot isn’t launched again after server restart. The method will return error 429 in the first 10 minutes after the bot is launched. Returns
Trueon success. Requires no parameters.- Return type:
True
- async close_forum_topic(chat_id, message_thread_id)[source]¶
https://core.telegram.org/bots/api#closeforumtopic
Use this method to close an open topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic. Returns
Trueon success.- Parameters:
chat_id (
intorstr) – Unique identifier for the target chat or username of the target supergroup (in the format@supergroupusername).message_thread_id (
int) – Unique identifier for the target message thread of the forum topic.
- Return type:
True
- async close_general_forum_topic(chat_id)[source]¶
https://core.telegram.org/bots/api#closegeneralforumtopic
Use this method to close an open ‘General’ topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. Returns
Trueon success.- Parameters:
chat_id (
intorstr) – Unique identifier for the target chat or username of the target supergroup (in the format@supergroupusername).- Return type:
True
- async convert_gift_to_stars(business_connection_id, owned_gift_id)[source]¶
https://core.telegram.org/bots/api#convertgifttostars
Converts a given regular gift to Telegram Stars. Requires the can_convert_gifts_to_stars business bot right. Returns
Trueon success.- Parameters:
business_connection_id (
str) – Unique identifier of the business connection.owned_gift_id (
str) – Unique identifier of the regular gift that should be converted to Telegram Stars.
- Return type:
True
- async copy_message(chat_id, from_chat_id, message_id, message_thread_id=None, direct_messages_topic_id=None, video_start_timestamp=None, caption=None, parse_mode=None, caption_entities=None, show_caption_above_media=None, disable_notification=None, protect_content=None, allow_paid_broadcast=None, suggested_post_parameters=None, reply_parameters=None, reply_markup=None)[source]¶
https://core.telegram.org/bots/api#copymessage
Use this method to copy messages of any kind. Service messages, paid media messages, giveaway messages, giveaway winners messages, and invoice messages can’t be copied. A quiz
pollcan be copied only if the value of the field correct_option_id is known to the bot. The method is analogous to the methodforward_message(), but the copied message doesn’t have a link to the original message. Returns theMessageIdof the sent message on success.- Parameters:
chat_id (
intorstr) – Unique identifier for the target chat or username of the target channel (in the format@channelusername).from_chat_id (
intorstr) – Unique identifier for the chat where the original message was sent (or channel username in the format@channelusername).message_id (
int) – Message identifier in the chat specified in from_chat_id.message_thread_id (
int, optional) – Unique identifier for the target message thread (topic) of the forum; for forum supergroups only.direct_messages_topic_id (
int, optional) – Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat.video_start_timestamp (
int, optional) – New start timestamp for the copied video in the message.caption (
str, optional) – New caption for media, 0-1024 characters after entities parsing. If not specified, the original caption is kept.parse_mode (
str, optional) – Mode for parsing entities in the new caption. See formatting options for more details.caption_entities (
listofMessageEntity, optional) – A JSON-serialized list of special entities that appear in the new caption, which can be specified instead of parse_mode.show_caption_above_media (
bool, optional) – PassTrue, if the caption must be shown above the message media. Ignored if a new caption isn’t specified.disable_notification (
bool, optional) – Sends the message silently. Users will receive a notification with no sound.protect_content (
bool, optional) – Protects the contents of the sent message from forwarding and saving.allow_paid_broadcast (
bool, optional) – PassTrueto allow up to 1000 messages per second, ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot’s balance.suggested_post_parameters (
SuggestedPostParameters, optional) – A JSON-serialized object containing the parameters of the suggested post to send; for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post is automatically declined.reply_parameters (
ReplyParameters, optional) – Description of the message to reply to.reply_markup (
REPLY_MARKUP_TYPES, optional) – Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
- Return type:
- async copy_messages(chat_id, from_chat_id, message_ids, message_thread_id=None, direct_messages_topic_id=None, disable_notification=None, protect_content=None, remove_caption=None)[source]¶
https://core.telegram.org/bots/api#copymessages
Use this method to copy messages of any kind. If some of the specified messages can’t be found or copied, they are skipped. Service messages, paid media messages, giveaway messages, giveaway winners messages, and invoice messages can’t be copied. A quiz
pollcan be copied only if the value of the field correct_option_id is known to the bot. The method is analogous to the methodforward_messages(), but the copied messages don’t have a link to the original message. Album grouping is kept for copied messages. On success, an array ofMessageIdof the sent messages is returned.- Parameters:
chat_id (
intorstr) – Unique identifier for the target chat or username of the target channel (in the format@channelusername).from_chat_id (
intorstr) – Unique identifier for the chat where the original messages were sent (or channel username in the format@channelusername).message_ids (
listofint) – Identifiers of 1-100 messages in the chat from_chat_id to copy. The identifiers must be specified in a strictly increasing order.message_thread_id (
int, optional) – Unique identifier for the target message thread (topic) of the forum; for forum supergroups only.direct_messages_topic_id (
int, optional) – Identifier of the direct messages topic to which the messages will be sent; required if the messages are sent to a direct messages chat.disable_notification (
bool, optional) –Sends the messages silently. Users will receive a notification with no sound.
protect_content (
bool, optional) – Protects the contents of the sent messages from forwarding and saving.remove_caption (
bool, optional) – PassTrueto copy the messages without their captions.
- Return type:
listofMessageId
- async create_chat_invite_link(chat_id, name=None, expire_date=None, member_limit=None, creates_join_request=None)[source]¶
https://core.telegram.org/bots/api#createchatinvitelink
Use this method to create an additional invite link for a chat. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. The link can be revoked using the method
revoke_chat_invite_link(). Returns the new invite link asChatInviteLinkobject.- Parameters:
chat_id (
intorstr) – Unique identifier for the target chat or username of the target channel (in the format@channelusername).name (
str, optional) – Invite link name; 0-32 characters.expire_date (
int, optional) – Point in time (Unix timestamp) when the link will expire.member_limit (
int, optional) – The maximum number of users that can be members of the chat simultaneously after joining the chat via this invite link; 1-99999.creates_join_request (
bool, optional) –True, if users joining the chat via the link need to be approved by chat administrators. IfTrue, member_limit can’t be specified.
- Return type:
- async create_chat_subscription_invite_link(chat_id, subscription_period, subscription_price, name=None)[source]¶
https://core.telegram.org/bots/api#createchatsubscriptioninvitelink
Use this method to create a subscription invite link for a channel chat. The bot must have the can_invite_users administrator rights. The link can be edited using the method
edit_chat_subscription_invite_link()or revoked using the methodrevoke_chat_invite_link(). Returns the new invite link as aChatInviteLinkobject.- Parameters:
chat_id (
intorstr) – Unique identifier for the target channel chat or username of the target channel (in the format@channelusername).subscription_period (
int) – The number of seconds the subscription will be active for before the next payment. Currently, it must always be 2592000 (30 days).subscription_price (
int) – The amount of Telegram Stars a user must pay initially and after each subsequent subscription period to be a member of the chat; 1-2500.name (
str, optional) – Invite link name; 0-32 characters.
- Return type:
- async create_forum_topic(chat_id, name, icon_color=None, icon_custom_emoji_id=None)[source]¶
https://core.telegram.org/bots/api#createforumtopic
Use this method to create a topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. Returns information about the created topic as a
ForumTopicobject.- Parameters:
chat_id (
intorstr) – Unique identifier for the target chat or username of the target supergroup (in the format@supergroupusername).name (
str) – Topic name, 1-128 characters.icon_color (
int, optional) – Color of the topic icon in RGB format. Currently, must be one of 7322096 (0x6FB9F0), 16766590 (0xFFD67E), 13338331 (0xCB86DB), 9367192 (0x8EEE98), 16749490 (0xFF93B2), or 16478047 (0xFB6F5F).icon_custom_emoji_id (
str, optional) – Unique identifier of the custom emoji shown as the topic icon. Useget_forum_topic_icon_stickers()to get all allowed custom emoji identifiers.
- Return type:
- async create_invoice_link(title, description, payload, currency, prices, business_connection_id=None, provider_token=None, subscription_period=None, max_tip_amount=None, suggested_tip_amounts=None, provider_data=None, photo_url=None, photo_size=None, photo_width=None, photo_height=None, need_name=None, need_phone_number=None, need_email=None, need_shipping_address=None, send_phone_number_to_provider=None, send_email_to_provider=None, is_flexible=None)[source]¶
https://core.telegram.org/bots/api#createinvoicelink
Use this method to create a link for an invoice. Returns the created invoice link as
Stringon success.- Parameters:
title (
str) – Product name, 1-32 characters.description (
str) – Product description, 1-255 characters.payload (
str) – Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes.currency (
str) – Three-letter ISO 4217 currency code, see more on currencies. Pass “XTR” for payments in Telegram Stars.prices (
listofLabeledPrice) –Price breakdown, a JSON-serialized list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.). Must contain exactly one item for payments in Telegram Stars
business_connection_id (
str, optional) –Unique identifier of the business connection on behalf of which the link will be created. For payments in Telegram Stars only.
provider_token (
str, optional) –Payment provider token, obtained via BotFather. Pass an empty string for payments in Telegram Stars
subscription_period (
int, optional) – The number of seconds the subscription will be active for before the next payment. The currency must be set to “XTR” (Telegram Stars) if the parameter is used. Currently, it must always be 2592000 (30 days) if specified. Any number of subscriptions can be active for a given bot at the same time, including multiple concurrent subscriptions from the same user. Subscription price must no exceed 10000 Telegram Stars.max_tip_amount (
int, optional) –The maximum accepted amount for tips in the smallest units of the currency (integer, not float/double). For example, for a maximum tip of
US$ 1.45passmax_tip_amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). Defaults to0. Not supported for payments in Telegram Starssuggested_tip_amounts (
listofint, optional) – A JSON-serialized array of suggested amounts of tips in the smallest units of the currency (integer, not float/double). At most 4 suggested tip amounts can be specified. The suggested tip amounts must be positive, passed in a strictly increased order and must not exceed max_tip_amount.provider_data (
str, optional) – JSON-serialized data about the invoice, which will be shared with the payment provider. A detailed description of required fields should be provided by the payment provider.photo_url (
str, optional) – URL of the product photo for the invoice. Can be a photo of the goods or a marketing image for a service.photo_size (
int, optional) – Photo size in bytes.photo_width (
int, optional) – Photo width.photo_height (
int, optional) – Photo height.need_name (
bool, optional) –Pass
Trueif you require the user’s full name to complete the order. Ignored for payments in Telegram Stars.need_phone_number (
bool, optional) –Pass
Trueif you require the user’s phone number to complete the order. Ignored for payments in Telegram Stars.need_email (
bool, optional) –Pass
Trueif you require the user’s email address to complete the order. Ignored for payments in Telegram Stars.need_shipping_address (
bool, optional) –Pass
Trueif you require the user’s shipping address to complete the order. Ignored for payments in Telegram Stars.send_phone_number_to_provider (
bool, optional) –Pass
Trueif the user’s phone number should be sent to the provider. Ignored for payments in Telegram Stars.send_email_to_provider (
bool, optional) –Pass
Trueif the user’s email address should be sent to the provider. Ignored for payments in Telegram Stars.is_flexible (
bool, optional) –Pass
Trueif the final price depends on the shipping method. Ignored for payments in Telegram Stars.
- Return type:
str
- async create_new_sticker_set(user_id, name, title, stickers, sticker_type=None, needs_repainting=None)[source]¶
https://core.telegram.org/bots/api#createnewstickerset
Use this method to create a new sticker set owned by a user. The bot will be able to edit the sticker set thus created. Returns
Trueon success.- Parameters:
user_id (
int) – User identifier of created sticker set owner.name (
str) – Short name of sticker set, to be used int.me/addstickers/URLs (e.g., animals). Can contain only English letters, digits and underscores. Must begin with a letter, can’t contain consecutive underscores and must end in"_by_<bot_username>".<bot_username>is case insensitive. 1-64 characters.title (
str) – Sticker set title, 1-64 characters.stickers (
listofInputSticker) – A JSON-serialized list of 1-50 initial stickers to be added to the sticker set.sticker_type (
str, optional) – Type of stickers in the set, pass “regular”, “mask”, or “custom_emoji”. By default, a regular sticker set is created.needs_repainting (
bool, optional) – PassTrueif stickers in the sticker set must be repainted to the color of text when used in messages, the accent color if used as emoji status, white on chat photos, or another appropriate color based on context; for custom emoji sticker sets only.
- Return type:
True
- async decline_chat_join_request(chat_id, user_id)[source]¶
https://core.telegram.org/bots/api#declinechatjoinrequest
Use this method to decline a chat join request. The bot must be an administrator in the chat for this to work and must have the can_invite_users administrator right. Returns
Trueon success.- Parameters:
chat_id (
intorstr) – Unique identifier for the target chat or username of the target channel (in the format@channelusername).user_id (
int) – Unique identifier of the target user.
- Return type:
True
- async decline_suggested_post(chat_id, message_id, comment=None)[source]¶
https://core.telegram.org/bots/api#declinesuggestedpost
Use this method to decline a suggested post in a direct messages chat. The bot must have the ‘can_manage_direct_messages’ administrator right in the corresponding channel chat. Returns
Trueon success.- Parameters:
chat_id (
int) – Unique identifier for the target direct messages chat.message_id (
int) – Identifier of a suggested post message to decline.comment (
str, optional) – Comment for the creator of the suggested post; 0-128 characters.
- Return type:
True
- async delete_business_messages(business_connection_id, message_ids)[source]¶
https://core.telegram.org/bots/api#deletebusinessmessages
Delete messages on behalf of a business account. Requires the can_delete_sent_messages business bot right to delete messages sent by the bot itself, or the can_delete_all_messages business bot right to delete any message. Returns
Trueon success.- Parameters:
business_connection_id (
str) – Unique identifier of the business connection on behalf of which to delete the messages.message_ids (
listofint) – A JSON-serialized list of 1-100 identifiers of messages to delete. All messages must be from the same chat. See deleteMessage for limitations on which messages can be deleted.
- Return type:
True
- async delete_chat_photo(chat_id)[source]¶
https://core.telegram.org/bots/api#deletechatphoto
Use this method to delete a chat photo. Photos can’t be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns
Trueon success.- Parameters:
chat_id (
intorstr) – Unique identifier for the target chat or username of the target channel (in the format@channelusername).- Return type:
True
- async delete_chat_sticker_set(chat_id)[source]¶
https://core.telegram.org/bots/api#deletechatstickerset
Use this method to delete a group sticker set from a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Use the field can_set_sticker_set optionally returned in
get_chat()requests to check if the bot can use this method. ReturnsTrueon success.- Parameters:
chat_id (
intorstr) – Unique identifier for the target chat or username of the target supergroup (in the format@supergroupusername).- Return type:
True
- async delete_forum_topic(chat_id, message_thread_id)[source]¶
https://core.telegram.org/bots/api#deleteforumtopic
Use this method to delete a forum topic along with all its messages in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_delete_messages administrator rights. Returns
Trueon success.- Parameters:
chat_id (
intorstr) – Unique identifier for the target chat or username of the target supergroup (in the format@supergroupusername).message_thread_id (
int) – Unique identifier for the target message thread of the forum topic.
- Return type:
True
- async delete_message(chat_id, message_id)[source]¶
https://core.telegram.org/bots/api#deletemessage
Use this method to delete a message, including service messages, with the following limitations:
A message can only be deleted if it was sent less than 48 hours ago.
Service messages about a supergroup, channel, or forum topic creation can’t be deleted.
A dice message in a private chat can only be deleted if it was sent more than 24 hours ago.
Bots can delete outgoing messages in private chats, groups, and supergroups.
Bots can delete incoming messages in private chats.
Bots granted can_post_messages permissions can delete outgoing messages in channels.
If the bot is an administrator of a group, it can delete any message there.
If the bot has can_delete_messages permission in a supergroup or a channel, it can delete any message there.
Returns
Trueon success.- Parameters:
chat_id (
intorstr) – Unique identifier for the target chat or username of the target channel (in the format@channelusername).message_id (
int) – Identifier of the message to delete.
- Return type:
True
- async delete_messages(chat_id, message_ids)[source]¶
https://core.telegram.org/bots/api#deletemessages
Use this method to delete multiple messages simultaneously. If some of the specified messages can’t be found, they are skipped. Returns
Trueon success.- Parameters:
chat_id (
intorstr) – Unique identifier for the target chat or username of the target channel (in the format@channelusername).message_ids (
listofint) – A JSON-serialized list of 1-100 identifiers of messages to delete. Seedelete_message()for limitations on which messages can be deleted.
- Return type:
True
- async delete_my_commands(scope=None, language_code=None)[source]¶
https://core.telegram.org/bots/api#deletemycommands
Use this method to delete the list of the bot’s commands for the given scope and user language. After deletion, higher level commands will be shown to affected users. Returns
Trueon success.- Parameters:
scope (
BotCommandScope, optional) – A JSON-serialized object, describing scope of users for which the commands are relevant. Defaults toBotCommandScopeDefault.language_code (
str, optional) – A two-letter ISO 639-1 language code. If empty, commands will be applied to all users from the given scope, for whose language there are no dedicated commands.
- Return type:
True
- async delete_sticker_from_set(sticker)[source]¶
https://core.telegram.org/bots/api#deletestickerfromset
Use this method to delete a sticker from a set created by the bot. Returns
Trueon success.- Parameters:
sticker (
str) – File identifier of the sticker.- Return type:
True
- async delete_sticker_set(name)[source]¶
https://core.telegram.org/bots/api#deletestickerset
Use this method to delete a sticker set that was created by the bot. Returns
Trueon success.- Parameters:
name (
str) – Sticker set name.- Return type:
True
- async delete_story(business_connection_id, story_id)[source]¶
https://core.telegram.org/bots/api#deletestory
Deletes a story previously posted by the bot on behalf of a managed business account. Requires the can_manage_stories business bot right. Returns
Trueon success.- Parameters:
business_connection_id (
str) – Unique identifier of the business connection.story_id (
int) – Unique identifier of the story to delete.
- Return type:
True
- async edit_chat_invite_link(chat_id, invite_link, name=None, expire_date=None, member_limit=None, creates_join_request=None)[source]¶
https://core.telegram.org/bots/api#editchatinvitelink
Use this method to edit a non-primary invite link created by the bot. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the edited invite link as a
ChatInviteLinkobject.- Parameters:
chat_id (
intorstr) – Unique identifier for the target chat or username of the target channel (in the format@channelusername).invite_link (
str) – The invite link to edit.name (
str, optional) – Invite link name; 0-32 characters.expire_date (
int, optional) – Point in time (Unix timestamp) when the link will expire.member_limit (
int, optional) – The maximum number of users that can be members of the chat simultaneously after joining the chat via this invite link; 1-99999.creates_join_request (
bool, optional) –True, if users joining the chat via the link need to be approved by chat administrators. IfTrue, member_limit can’t be specified.
- Return type:
- async edit_chat_subscription_invite_link(chat_id, invite_link, name=None)[source]¶
https://core.telegram.org/bots/api#editchatsubscriptioninvitelink
Use this method to edit a subscription invite link created by the bot. The bot must have the can_invite_users administrator rights. Returns the edited invite link as a
ChatInviteLinkobject.- Parameters:
chat_id (
intorstr) – Unique identifier for the target chat or username of the target channel (in the format@channelusername).invite_link (
str) – The invite link to edit.name (
str, optional) – Invite link name; 0-32 characters.
- Return type:
- async edit_forum_topic(chat_id, message_thread_id, name=None, icon_custom_emoji_id=None)[source]¶
https://core.telegram.org/bots/api#editforumtopic
Use this method to edit name and icon of a topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have can_manage_topics administrator rights, unless it is the creator of the topic. Returns
Trueon success.- Parameters:
chat_id (
intorstr) – Unique identifier for the target chat or username of the target supergroup (in the format@supergroupusername).message_thread_id (
int) – Unique identifier for the target message thread of the forum topic.name (
str, optional) – New topic name, 0-128 characters. If not specified or empty, the current name of the topic will be kept.icon_custom_emoji_id (
str, optional) – New unique identifier of the custom emoji shown as the topic icon. Useget_forum_topic_icon_stickers()to get all allowed custom emoji identifiers. Pass an empty string to remove the icon. If not specified, the current icon will be kept.
- Return type:
True
- async edit_general_forum_topic(chat_id, name)[source]¶
https://core.telegram.org/bots/api#editgeneralforumtopic
Use this method to edit the name of the ‘General’ topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have can_manage_topics administrator rights. Returns
Trueon success.- Parameters:
chat_id (
intorstr) – Unique identifier for the target chat or username of the target supergroup (in the format@supergroupusername).name (
str) – New topic name, 1-128 characters.
- Return type:
True
- async edit_message_caption(business_connection_id=None, chat_id=None, message_id=None, inline_message_id=None, caption=None, parse_mode=None, caption_entities=None, show_caption_above_media=None, reply_markup=None)[source]¶
https://core.telegram.org/bots/api#editmessagecaption
Use this method to edit captions of messages. On success, if the edited message is not an inline message, the edited
Messageis returned, otherwiseTrueis returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent.- Parameters:
business_connection_id (
str, optional) – Unique identifier of the business connection on behalf of which the message to be edited was sent.chat_id (
intorstr, optional) – Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target channel (in the format@channelusername).message_id (
int, optional) – Required if inline_message_id is not specified. Identifier of the message to edit.inline_message_id (
str, optional) – Required if chat_id and message_id are not specified. Identifier of the inline message.caption (
str, optional) – New caption of the message, 0-1024 characters after entities parsing.parse_mode (
str, optional) –Mode for parsing entities in the message caption. See formatting options for more details.
caption_entities (
listofMessageEntity, optional) – A JSON-serialized list of special entities that appear in the caption, which can be specified instead of parse_mode.show_caption_above_media (
bool, optional) – PassTrue, if the caption must be shown above the message media. Supported only for animation, photo and video messages.reply_markup (
InlineKeyboardMarkup, optional) –A JSON-serialized object for an inline keyboard.
- Return type:
MessageorTrue
- async edit_message_checklist(business_connection_id, chat_id, message_id, checklist, reply_markup=None)[source]¶
https://core.telegram.org/bots/api#editmessagechecklist
Use this method to edit a checklist on behalf of a connected business account. On success, the edited
Messageis returned.- Parameters:
business_connection_id (
str) – Unique identifier of the business connection on behalf of which the message will be sent.chat_id (
int) – Unique identifier for the target chat.message_id (
int) – Unique identifier for the target message.checklist (
InputChecklist) – A JSON-serialized object for the new checklist.reply_markup (
InlineKeyboardMarkup, optional) – A JSON-serialized object for the new inline keyboard for the message.
- Return type:
- async edit_message_live_location(latitude, longitude, business_connection_id=None, chat_id=None, message_id=None, inline_message_id=None, live_period=None, horizontal_accuracy=None, heading=None, proximity_alert_radius=None, reply_markup=None)[source]¶
https://core.telegram.org/bots/api#editmessagelivelocation
Use this method to edit live location messages. A location can be edited until its live_period expires or editing is explicitly disabled by a call to
stop_message_live_location(). On success, if the edited message is not an inline message, the editedMessageis returned, otherwiseTrueis returned.- Parameters:
latitude (
float) – Latitude of new location.longitude (
float) – Longitude of new location.business_connection_id (
str, optional) – Unique identifier of the business connection on behalf of which the message to be edited was sent.chat_id (
intorstr, optional) – Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target channel (in the format@channelusername).message_id (
int, optional) – Required if inline_message_id is not specified. Identifier of the message to edit.inline_message_id (
str, optional) – Required if chat_id and message_id are not specified. Identifier of the inline message.live_period (
int, optional) – New period in seconds during which the location can be updated, starting from the message send date. If 0x7FFFFFFF is specified, then the location can be updated forever. Otherwise, the new value must not exceed the current live_period by more than a day, and the live location expiration date must remain within the next 90 days. If not specified, then live_period remains unchanged.horizontal_accuracy (
float, optional) – The radius of uncertainty for the location, measured in meters; 0-1500.heading (
int, optional) – Direction in which the user is moving, in degrees. Must be between 1 and 360 if specified.proximity_alert_radius (
int, optional) – The maximum distance for proximity alerts about approaching another chat member, in meters. Must be between 1 and 100000 if specified.reply_markup (
InlineKeyboardMarkup, optional) –A JSON-serialized object for a new inline keyboard.
- Return type:
MessageorTrue
- async edit_message_media(media, business_connection_id=None, chat_id=None, message_id=None, inline_message_id=None, reply_markup=None)[source]¶
https://core.telegram.org/bots/api#editmessagemedia
Use this method to edit animation, audio, document, photo, or video messages. If a message is part of a message album, then it can be edited only to an audio for audio albums, only to a document for document albums and to a photo or a video otherwise. When an inline message is edited, a new file can’t be uploaded; use a previously uploaded file via its file_id or specify a URL. On success, if the edited message is not an inline message, the edited
Messageis returned, otherwiseTrueis returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent.- Parameters:
media (
InputMedia) – A JSON-serialized object for a new media content of the message.business_connection_id (
str, optional) – Unique identifier of the business connection on behalf of which the message to be edited was sent.chat_id (
intorstr, optional) – Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target channel (in the format@channelusername).message_id (
int, optional) – Required if inline_message_id is not specified. Identifier of the message to edit.inline_message_id (
str, optional) – Required if chat_id and message_id are not specified. Identifier of the inline message.reply_markup (
InlineKeyboardMarkup, optional) –A JSON-serialized object for a new inline keyboard.
- Return type:
MessageorTrue
- async edit_message_reply_markup(business_connection_id=None, chat_id=None, message_id=None, inline_message_id=None, reply_markup=None)[source]¶
https://core.telegram.org/bots/api#editmessagereplymarkup
Use this method to edit only the reply markup of messages. On success, if the edited message is not an inline message, the edited
Messageis returned, otherwiseTrueis returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent.- Parameters:
business_connection_id (
str, optional) – Unique identifier of the business connection on behalf of which the message to be edited was sent.chat_id (
intorstr, optional) – Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target channel (in the format@channelusername).message_id (
int, optional) – Required if inline_message_id is not specified. Identifier of the message to edit.inline_message_id (
str, optional) – Required if chat_id and message_id are not specified. Identifier of the inline message.reply_markup (
InlineKeyboardMarkup, optional) –A JSON-serialized object for an inline keyboard.
- Return type:
MessageorTrue
- async edit_message_text(text, chat_id=None, message_id=None, inline_message_id=None, parse_mode=None, entities=None, link_preview_options=None, business_connection_id=None, reply_markup=None)[source]¶
https://core.telegram.org/bots/api#editmessagetext
Use this method to edit text and game messages. On success, if the edited message is not an inline message, the edited
Messageis returned, otherwiseTrueis returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent.- Parameters:
text (
str) – New text of the message, 1-4096 characters after entities parsing.chat_id (
intorstr, optional) – Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target channel (in the format@channelusername).message_id (
int, optional) – Required if inline_message_id is not specified. Identifier of the message to edit.inline_message_id (
str, optional) – Required if chat_id and message_id are not specified. Identifier of the inline message.parse_mode (
str, optional) –Mode for parsing entities in the message text. See formatting options for more details.
entities (
listofMessageEntity, optional) – A JSON-serialized list of special entities that appear in message text, which can be specified instead of parse_mode.link_preview_options (
LinkPreviewOptions, optional) – Link preview generation options for the message.business_connection_id (
str, optional) – Unique identifier of the business connection on behalf of which the message to be edited was sent.reply_markup (
InlineKeyboardMarkup, optional) –A JSON-serialized object for an inline keyboard.
- Return type:
MessageorTrue
- async edit_story(business_connection_id, story_id, content, caption=None, parse_mode=None, caption_entities=None, areas=None)[source]¶
https://core.telegram.org/bots/api#editstory
Edits a story previously posted by the bot on behalf of a managed business account. Requires the can_manage_stories business bot right. Returns
Storyon success.- Parameters:
business_connection_id (
str) – Unique identifier of the business connection.story_id (
int) – Unique identifier of the story to edit.content (
InputStoryContent) – Content of the story.caption (
str, optional) – Caption of the story, 0-2048 characters after entities parsing.parse_mode (
str, optional) –Mode for parsing entities in the story caption. See formatting options for more details.
caption_entities (
listofMessageEntity, optional) – A JSON-serialized list of special entities that appear in the caption, which can be specified instead of parse_mode.areas (
listofStoryArea, optional) – A JSON-serialized list of clickable areas to be shown on the story.
- Return type:
- async edit_user_star_subscription(user_id, telegram_payment_charge_id, is_canceled)[source]¶
https://core.telegram.org/bots/api#edituserstarsubscription
Allows the bot to cancel or re-enable extension of a subscription paid in Telegram Stars. Returns
Trueon success.- Parameters:
user_id (
int) – Identifier of the user whose subscription will be edited.telegram_payment_charge_id (
str) – Telegram payment identifier for the subscription.is_canceled (
bool) – PassTrueto cancel extension of the user subscription; the subscription must be active up to the end of the current subscription period. PassFalseto allow the user to re-enable a subscription that was previously canceled by the bot.
- Return type:
True
- async export_chat_invite_link(chat_id)[source]¶
https://core.telegram.org/bots/api#exportchatinvitelink
Use this method to generate a new primary invite link for a chat; any previously generated primary link is revoked. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the new invite link as
Stringon success.Note: Each administrator in a chat generates their own invite links. Bots can’t use invite links generated by other administrators. If you want your bot to work with invite links, it will need to generate its own link using
export_chat_invite_link()or by calling theget_chat()method. If your bot needs to generate a new primary invite link replacing its previous one, useexport_chat_invite_link()again.- Parameters:
chat_id (
intorstr) – Unique identifier for the target chat or username of the target channel (in the format@channelusername).- Return type:
str
- async forward_message(chat_id, from_chat_id, message_id, message_thread_id=None, direct_messages_topic_id=None, video_start_timestamp=None, disable_notification=None, protect_content=None, suggested_post_parameters=None)[source]¶
https://core.telegram.org/bots/api#forwardmessage
Use this method to forward messages of any kind. Service messages and messages with protected content can’t be forwarded. On success, the sent
Messageis returned.- Parameters:
chat_id (
intorstr) – Unique identifier for the target chat or username of the target channel (in the format@channelusername).from_chat_id (
intorstr) – Unique identifier for the chat where the original message was sent (or channel username in the format@channelusername).message_id (
int) – Message identifier in the chat specified in from_chat_id.message_thread_id (
int, optional) – Unique identifier for the target message thread (topic) of the forum; for forum supergroups only.direct_messages_topic_id (
int, optional) – Identifier of the direct messages topic to which the message will be forwarded; required if the message is forwarded to a direct messages chat.video_start_timestamp (
int, optional) – New start timestamp for the forwarded video in the message.disable_notification (
bool, optional) –Sends the message silently. Users will receive a notification with no sound.
protect_content (
bool, optional) – Protects the contents of the forwarded message from forwarding and saving.suggested_post_parameters (
SuggestedPostParameters, optional) – A JSON-serialized object containing the parameters of the suggested post to send; for direct messages chats only.
- Return type:
- async forward_messages(chat_id, from_chat_id, message_ids, message_thread_id=None, direct_messages_topic_id=None, disable_notification=None, protect_content=None)[source]¶
https://core.telegram.org/bots/api#forwardmessages
Use this method to forward multiple messages of any kind. If some of the specified messages can’t be found or forwarded, they are skipped. Service messages and messages with protected content can’t be forwarded. Album grouping is kept for forwarded messages. On success, an array of
MessageIdof the sent messages is returned.- Parameters:
chat_id (
intorstr) – Unique identifier for the target chat or username of the target channel (in the format@channelusername).from_chat_id (
intorstr) – Unique identifier for the chat where the original messages were sent (or channel username in the format@channelusername).message_ids (
listofint) – A JSON-serialized list of 1-100 identifiers of messages in the chat from_chat_id to forward. The identifiers must be specified in a strictly increasing order.message_thread_id (
int, optional) – Unique identifier for the target message thread (topic) of the forum; for forum supergroups only.direct_messages_topic_id (
int, optional) – Identifier of the direct messages topic to which the messages will be forwarded; required if the messages are forwarded to a direct messages chat.disable_notification (
bool, optional) –Sends the messages silently. Users will receive a notification with no sound.
protect_content (
bool, optional) – Protects the contents of the forwarded messages from forwarding and saving.
- Return type:
listofMessageId
- async get_available_gifts()[source]¶
https://core.telegram.org/bots/api#getavailablegifts
Returns the list of gifts that can be sent by the bot to users and channel chats. Requires no parameters. Returns a
Giftsobject.- Return type:
- async get_business_account_gifts(business_connection_id, exclude_unsaved=None, exclude_saved=None, exclude_unlimited=None, exclude_limited=None, exclude_unique=None, sort_by_price=None, offset=None, limit=None)[source]¶
https://core.telegram.org/bots/api#getbusinessaccountgifts
Returns the gifts received and owned by a managed business account. Requires the can_view_gifts_and_stars business bot right. Returns
OwnedGiftson success.- Parameters:
business_connection_id (
str) – Unique identifier of the business connection.exclude_unsaved (
bool, optional) – PassTrueto exclude gifts that aren’t saved to the account’s profile page.exclude_saved (
bool, optional) – PassTrueto exclude gifts that are saved to the account’s profile page.exclude_unlimited (
bool, optional) – PassTrueto exclude gifts that can be purchased an unlimited number of times.exclude_limited (
bool, optional) – PassTrueto exclude gifts that can be purchased a limited number of times.exclude_unique (
bool, optional) – PassTrueto exclude unique gifts.sort_by_price (
bool, optional) – PassTrueto sort results by gift price instead of send date. Sorting is applied before pagination.offset (
str, optional) – Offset of the first entry to return as received from the previous request; use empty string to get the first chunk of results.limit (
int, optional) – The maximum number of gifts to be returned; 1-100. Defaults to 100.
- Return type:
- async get_business_account_star_balance(business_connection_id)[source]¶
https://core.telegram.org/bots/api#getbusinessaccountstarbalance
Returns the amount of Telegram Stars owned by a managed business account. Requires the can_view_gifts_and_stars business bot right. Returns
StarAmounton success.- Parameters:
business_connection_id (
str) – Unique identifier of the business connection.- Return type:
- async get_business_connection(business_connection_id)[source]¶
https://core.telegram.org/bots/api#getbusinessconnection
Use this method to get information about the connection of the bot with a business account. Returns a
BusinessConnectionobject on success.- Parameters:
business_connection_id (
str) – Unique identifier of the business connection.- Return type:
- async get_chat(chat_id)[source]¶
https://core.telegram.org/bots/api#getchat
Use this method to get up-to-date information about the chat. Returns a
ChatFullInfoobject on success.- Parameters:
chat_id (
intorstr) – Unique identifier for the target chat or username of the target supergroup or channel (in the format@channelusername).- Return type:
- async get_chat_administrators(chat_id)[source]¶
https://core.telegram.org/bots/api#getchatadministrators
Use this method to get a list of administrators in a chat, which aren’t bots. Returns an Array of
ChatMemberobjects.- Parameters:
chat_id (
intorstr) – Unique identifier for the target chat or username of the target supergroup or channel (in the format@channelusername).- Return type:
listofChatMember
- async get_chat_member(chat_id, user_id)[source]¶
https://core.telegram.org/bots/api#getchatmember
Use this method to get information about a member of a chat. The method is only guaranteed to work for other users if the bot is an administrator in the chat. Returns a
ChatMemberobject on success.- Parameters:
chat_id (
intorstr) – Unique identifier for the target chat or username of the target supergroup or channel (in the format@channelusername).user_id (
int) – Unique identifier of the target user.
- Return type:
- async get_chat_member_count(chat_id)[source]¶
https://core.telegram.org/bots/api#getchatmembercount
Use this method to get the number of members in a chat. Returns
Inton success.- Parameters:
chat_id (
intorstr) – Unique identifier for the target chat or username of the target supergroup or channel (in the format@channelusername).- Return type:
int
https://core.telegram.org/bots/api#getchatmenubutton
Use this method to get the current value of the bot’s menu button in a private chat, or the default menu button. Returns
MenuButtonon success.- Parameters:
chat_id (
int, optional) – Unique identifier for the target private chat. If not specified, default bot’s menu button will be returned.- Return type:
- async get_custom_emoji_stickers(custom_emoji_ids)[source]¶
https://core.telegram.org/bots/api#getcustomemojistickers
Use this method to get information about custom emoji stickers by their identifiers. Returns an Array of
Stickerobjects.- Parameters:
custom_emoji_ids (
listofstr) – A JSON-serialized list of custom emoji identifiers. At most 200 custom emoji identifiers can be specified.- Return type:
listofSticker
- async get_file(file_id)[source]¶
https://core.telegram.org/bots/api#getfile
Use this method to get basic information about a file and prepare it for downloading. For the moment, bots can download files of up to 20MB in size. On success, a
Fileobject is returned. The file can then be downloaded via the linkhttps://api.telegram.org/file/bot<token>/<file_path>, where<file_path>is taken from the response. It is guaranteed that the link will be valid for at least 1 hour. When the link expires, a new one can be requested by callingget_file()again.Note: This function may not preserve the original file name and MIME type. You should save the file’s MIME type and name (if available) when the File object is received.
- Parameters:
file_id (
str) – File identifier to get information about.- Return type:
- async get_forum_topic_icon_stickers()[source]¶
https://core.telegram.org/bots/api#getforumtopiciconstickers
Use this method to get custom emoji stickers, which can be used as a forum topic icon by any user. Requires no parameters. Returns an Array of
Stickerobjects.- Return type:
listofSticker
- async get_game_high_scores(user_id, chat_id=None, message_id=None, inline_message_id=None)[source]¶
https://core.telegram.org/bots/api#getgamehighscores
Use this method to get data for high score tables. Will return the score of the specified user and several of their neighbors in a game. Returns an Array of
GameHighScoreobjects.This method will currently return scores for the target user, plus two of their closest neighbors on each side. Will also return the top three users if the user and their neighbors are not among them. Please note that this behavior is subject to change.
- Parameters:
user_id (
int) – Target user id.chat_id (
int, optional) – Required if inline_message_id is not specified. Unique identifier for the target chat.message_id (
int, optional) – Required if inline_message_id is not specified. Identifier of the sent message.inline_message_id (
str, optional) – Required if chat_id and message_id are not specified. Identifier of the inline message.
- Return type:
listofGameHighScore
- async get_me()[source]¶
https://core.telegram.org/bots/api#getme
A simple method for testing your bot’s authentication token. Requires no parameters. Returns basic information about the bot in form of a
Userobject.- Return type:
- async get_my_commands(scope=None, language_code=None)[source]¶
https://core.telegram.org/bots/api#getmycommands
Use this method to get the current list of the bot’s commands for the given scope and user language. Returns an Array of
BotCommandobjects. If commands aren’t set, an empty list is returned.- Parameters:
scope (
BotCommandScope, optional)language_code (
str, optional)
- Return type:
listofBotCommand
- async get_my_default_administrator_rights(for_channels=None)[source]¶
https://core.telegram.org/bots/api#getmydefaultadministratorrights
Use this method to get the current default administrator rights of the bot. Returns
ChatAdministratorRightson success.- Parameters:
for_channels (
bool, optional) – PassTrueto get default administrator rights of the bot in channels. Otherwise, default administrator rights of the bot for groups and supergroups will be returned.- Return type:
- async get_my_description(language_code=None)[source]¶
https://core.telegram.org/bots/api#getmydescription
Use this method to get the current bot description for the given user language. Returns
BotDescriptionon success.- Parameters:
language_code (
str, optional) – A two-letter ISO 639-1 language code or an empty string.- Return type:
- async get_my_name(language_code=None)[source]¶
https://core.telegram.org/bots/api#getmyname
Use this method to get the current bot name for the given user language. Returns
BotNameon success.- Parameters:
language_code (
str, optional) – A two-letter ISO 639-1 language code or an empty string.- Return type:
- async get_my_short_description(language_code=None)[source]¶
https://core.telegram.org/bots/api#getmyshortdescription
Use this method to get the current bot short description for the given user language. Returns
BotShortDescriptionon success.- Parameters:
language_code (
str, optional) – A two-letter ISO 639-1 language code or an empty string.- Return type:
- async get_my_star_balance()[source]¶
https://core.telegram.org/bots/api#getmystarbalance
A method to get the current Telegram Stars balance of the bot. Requires no parameters. On success, returns a
StarAmountobject.- Return type:
- async get_star_transactions(offset=None, limit=None)[source]¶
https://core.telegram.org/bots/api#getstartransactions
Returns the bot’s Telegram Star transactions in chronological order. On success, returns a
StarTransactionsobject.- Parameters:
offset (
int, optional) – Number of transactions to skip in the response.limit (
int, optional) – The maximum number of transactions to be retrieved. Values between 1-100 are accepted. Defaults to100.
- Return type:
- async get_sticker_set(name)[source]¶
https://core.telegram.org/bots/api#getstickerset
Use this method to get a sticker set. On success, a
StickerSetobject is returned.- Parameters:
name (
str) – Name of the sticker set.- Return type:
- async get_updates(offset=None, limit=None, timeout=None, allowed_updates=None)[source]¶
https://core.telegram.org/bots/api#getupdates
Use this method to receive incoming updates using long polling (wiki). Returns an Array of
Updateobjects.Notes1. This method will not work if an outgoing webhook is set up.2. In order to avoid getting duplicate updates, recalculate offset after each server response.- Parameters:
offset (
int, optional) – Identifier of the first update to be returned. Must be greater by one than the highest among the identifiers of previously received updates. By default, updates starting with the earliest unconfirmed update are returned. An update is considered confirmed as soon asget_updates()is called with an offset higher than its update_id. The negative offset can be specified to retrieve updates starting from -offset update from the end of the updates queue. All previous updates will be forgotten.limit (
int, optional) – Limits the number of updates to be retrieved. Values between 1-100 are accepted. Defaults to100.timeout (
int, optional) – Timeout in seconds for long polling. Defaults to0, i.e. usual short polling. Should be positive, short polling should be used for testing purposes only.allowed_updates (
listofstr, optional) –A JSON-serialized list of the update types you want your bot to receive. For example, specify
["message", "edited_channel_post", "callback_query"]to only receive updates of these types. SeeUpdatefor a complete list of available update types. Specify an empty list to receive all update types except chat_member, message_reaction, and message_reaction_count (default). If not specified, the previous setting will be used.Please note that this parameter doesn’t affect updates created before the call to the
get_updates(), so unwanted updates may be received for a short period of time.
- Return type:
listofUpdate
- async get_user_chat_boosts(chat_id, user_id)[source]¶
https://core.telegram.org/bots/api#getuserchatboosts
Use this method to get the list of boosts added to a chat by a user. Requires administrator rights in the chat. Returns a
UserChatBoostsobject.- Parameters:
chat_id (
intorstr) – Unique identifier for the chat or username of the channel (in the format@channelusername).user_id (
int) – Unique identifier of the target user.
- Return type:
- async get_user_profile_photos(user_id, offset=None, limit=None)[source]¶
https://core.telegram.org/bots/api#getuserprofilephotos
Use this method to get a list of profile pictures for a user. Returns a
UserProfilePhotosobject.- Parameters:
user_id (
int) – Unique identifier of the target user.offset (
int, optional) – Sequential number of the first photo to be returned. By default, all photos are returned.limit (
int, optional) – Limits the number of photos to be retrieved. Values between 1-100 are accepted. Defaults to100.
- Return type:
https://core.telegram.org/bots/api#giftpremiumsubscription
Gifts a Telegram Premium subscription to the given user. Returns
Trueon success.- Parameters:
user_id (
int) – Unique identifier of the target user who will receive a Telegram Premium subscription.month_count (
int) – Number of months the Telegram Premium subscription will be active for the user; must be one of 3, 6, or 12.star_count (
int) – Number of Telegram Stars to pay for the Telegram Premium subscription; must be 1000 for 3 months, 1500 for 6 months, and 2500 for 12 months.text (
str, optional) – Text that will be shown along with the service message about the subscription; 0-128 characters.text_parse_mode (
str, optional) –Mode for parsing entities in the text. See formatting options for more details. Entities other than “bold”, “italic”, “underline”, “strikethrough”, “spoiler”, and “custom_emoji” are ignored.
text_entities (
listofMessageEntity, optional) – A JSON-serialized list of special entities that appear in the gift text. It can be specified instead of text_parse_mode. Entities other than “bold”, “italic”, “underline”, “strikethrough”, “spoiler”, and “custom_emoji” are ignored.
- Return type:
True
- async hide_general_forum_topic(chat_id)[source]¶
https://core.telegram.org/bots/api#hidegeneralforumtopic
Use this method to hide the ‘General’ topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. The topic will be automatically closed if it was open. Returns
Trueon success.- Parameters:
chat_id (
intorstr) – Unique identifier for the target chat or username of the target supergroup (in the format@supergroupusername).- Return type:
True
- async leave_chat(chat_id)[source]¶
https://core.telegram.org/bots/api#leavechat
Use this method for your bot to leave a group, supergroup or channel. Returns
Trueon success.- Parameters:
chat_id (
intorstr) – Unique identifier for the target chat or username of the target supergroup or channel (in the format@channelusername).- Return type:
True
- async log_out()[source]¶
https://core.telegram.org/bots/api#logout
Use this method to log out from the cloud Bot API server before launching the bot locally. You must log out the bot before running it locally, otherwise there is no guarantee that the bot will receive updates. After a successful call, you can immediately log in on a local server, but will not be able to log in back to the cloud Bot API server for 10 minutes. Returns
Trueon success. Requires no parameters.- Return type:
True
- async long_polling(timeout=45, *, limit=None, allowed_updates=None)[source]¶
Use this method with the asyncio module, to receive
updatesfrom the Telegram Bot API Server and manage them using decorators method likemanage_message().Usage:
import apitele import asyncio from apitele.types import Message bot = apitele.Client('<your_api_token>') @bot.manage_message() async def foo(msg: Message): await bot.send_message(msg.chat.id, 'hello') asyncio.run(bot.long_polling())
- Parameters:
timeout (
int) – Timeout in seconds for long polling. Should be higher than 30, short polling should be used for testing purposes only.limit (
int, optional) – Limits the number of updates to be retrieved. Values between 1-100 are accepted. Defaults to100.allowed_updates (
listofstr, optional) –A JSON-serialized list of the update types you want your bot to receive. For example, specify
["message", "edited_channel_post", "callback_query"]to only receive updates of these types. SeeUpdatefor a complete list of available update types. Specify an empty list to receive all update types except chat_member, message_reaction, and message_reaction_count (default). If not specified, the previous setting will be used.Please note that this parameter doesn’t affect updates created before the call to the
get_updates(), so unwanted updates may be received for a short period of time.
- manage_business_connection(checker=lambda business_connection: ..., /)[source]¶
You must wrap a coroutine inside this decorator to manage an incoming business_connection
Update. The coroutine must takes only one argument, it will be processed asBusinessConnection. Then you need to call the methodlong_polling()using the function asyncio.run() to process theBusinessConnectionupdate.Usage:
import apitele import asyncio from apitele.types import BusinessConnection bot = apitele.Client('<your_api_token>') @bot.manage_business_connection(lambda business_connection: business_connection.user.id == xyz) async def foo(business_connection: BusinessConnection): ... asyncio.run(bot.long_polling())
- Parameters:
checker (
Callable[[BusinessConnection], Any]) – A function that takes only one argument to check an incoming business_connectionUpdate. E.g. a lambda function.
- manage_business_message(checker=lambda business_message: ..., /)[source]¶
You must wrap a coroutine inside this decorator to manage an incoming business_message
Update. The coroutine must takes only one argument, it will be processed asMessage. Then you need to call the methodlong_polling()using the function asyncio.run() to process theMessageupdate.Usage:
import apitele import asyncio from apitele.types import Message bot = apitele.Client('<your_api_token>') @bot.manage_business_message(lambda business_message: business_message.chat.id == xyz) async def foo(business_message: Message): ... asyncio.run(bot.long_polling())
- Parameters:
checker (
Callable[[Message], Any]) – A function that takes only one argument to check an incoming business_messageUpdate. E.g. a lambda function.
- manage_callback_query(checker=lambda callback_query: ..., /)[source]¶
You must wrap a coroutine inside this decorator to manage an incoming callback_query
Update. The coroutine must takes only one argument, it will be processed asCallbackQuery. Then you need to call the methodlong_polling()using the function asyncio.run() to process theCallbackQueryupdate.Usage:
import apitele import asyncio from apitele.types import CallbackQuery bot = apitele.Client('<your_api_token>') @bot.manage_callback_query(lambda callback_query: callback_query.from_user.id == xyz) async def foo(callback_query: CallbackQuery): ... asyncio.run(bot.long_polling())
- Parameters:
checker (
Callable[[CallbackQuery], Any]) – A function that takes only one argument to check an incoming callback_queryUpdate. E.g. a lambda function.
- manage_channel_post(checker=lambda channel_post: ..., /)[source]¶
You must wrap a coroutine inside this decorator to manage an incoming channel_post
Update. The coroutine must takes only one argument, it will be processed asMessage. Then you need to call the methodlong_polling()using the function asyncio.run() to process theMessageupdate.Usage:
import apitele import asyncio from apitele.types import Message bot = apitele.Client('<your_api_token>') @bot.manage_channel_post(lambda channel_post: channel_post.chat.id == xyz) async def foo(channel_post: Message): ... asyncio.run(bot.long_polling())
- Parameters:
checker (
Callable[[Message], Any]) – A function that takes only one argument to check an incoming channel_postUpdate. E.g. a lambda function.
- manage_chat_boost(checker=lambda chat_boost: ..., /)[source]¶
You must wrap a coroutine inside this decorator to manage an incoming chat_boost
Update. The coroutine must takes only one argument, it will be processed asChatBoostUpdated. Then you need to call the methodlong_polling()using the function asyncio.run() to process theChatBoostUpdatedupdate.Usage:
import apitele import asyncio from apitele.types import ChatBoostUpdated bot = apitele.Client('<your_api_token>') @bot.manage_chat_boost(lambda chat_boost: chat_boost.chat.id == xyz) async def foo(chat_boost: ChatBoostUpdated): ... asyncio.run(bot.long_polling())
- Parameters:
checker (
Callable[[ChatBoostUpdated], Any]) – A function that takes only one argument to check an incoming chat_boostUpdate. E.g. a lambda function.
- manage_chat_join_request(checker=lambda chat_join_request: ..., /)[source]¶
You must wrap a coroutine inside this decorator to manage an incoming chat_join_request
Update. The coroutine must takes only one argument, it will be processed asChatJoinRequest. Then you need to call the methodlong_polling()using the function asyncio.run() to process theChatJoinRequestupdate.Usage:
import apitele import asyncio from apitele.types import ChatJoinRequest bot = apitele.Client('<your_api_token>') @bot.manage_chat_join_request(lambda chat_join_request: chat_join_request.chat.id == xyz) async def foo(chat_join_request: ChatJoinRequest): ... asyncio.run(bot.long_polling())
- Parameters:
checker (
Callable[[ChatJoinRequest], Any]) – A function that takes only one argument to check an incoming chat_join_requestUpdate. E.g. a lambda function.
- manage_chat_member(checker=lambda chat_member: ..., /)[source]¶
You must wrap a coroutine inside this decorator to manage an incoming chat_member
Update. The coroutine must takes only one argument, it will be processed asChatMemberUpdated. Then you need to call the methodlong_polling()using the function asyncio.run() to process theChatMemberUpdatedupdate.Usage:
import apitele import asyncio from apitele.types import ChatMemberUpdated bot = apitele.Client('<your_api_token>') @bot.manage_chat_member(lambda chat_member: chat_member.chat.id == xyz) async def foo(chat_member: ChatMemberUpdated): ... asyncio.run(bot.long_polling())
- Parameters:
checker (
Callable[[ChatMemberUpdated], Any]) – A function that takes only one argument to check an incoming chat_memberUpdate. E.g. a lambda function.
- manage_chosen_inline_result(checker=lambda chosen_inline_result: ..., /)[source]¶
You must wrap a coroutine inside this decorator to manage an incoming chosen_inline_result
Update. The coroutine must takes only one argument, it will be processed asChosenInlineResult. Then you need to call the methodlong_polling()using the function asyncio.run() to process theChosenInlineResultupdate.Usage:
import apitele import asyncio from apitele.types import ChosenInlineResult bot = apitele.Client('<your_api_token>') @bot.manage_chosen_inline_result(lambda chosen_inline_result: chosen_inline_result.from_user.id == xyz) async def foo(chosen_inline_result: ChosenInlineResult): ... asyncio.run(bot.long_polling())
- Parameters:
checker (
Callable[[ChosenInlineResult], Any]) – A function that takes only one argument to check an incoming chosen_inline_resultUpdate. E.g. a lambda function.
- manage_deleted_business_messages(checker=lambda deleted_business_messages: ..., /)[source]¶
You must wrap a coroutine inside this decorator to manage an incoming deleted_business_messages
Update. The coroutine must takes only one argument, it will be processed asBusinessMessagesDeleted. Then you need to call the methodlong_polling()using the function asyncio.run() to process theBusinessMessagesDeletedupdate.Usage:
import apitele import asyncio from apitele.types import BusinessMessagesDeleted bot = apitele.Client('<your_api_token>') @bot.manage_deleted_business_messages(lambda deleted_business_messages: deleted_business_messages.chat.id == xyz) async def foo(deleted_business_messages: BusinessMessagesDeleted): ... asyncio.run(bot.long_polling())
- Parameters:
checker (
Callable[[BusinessMessagesDeleted], Any]) – A function that takes only one argument to check an incoming deleted_business_messagesUpdate. E.g. a lambda function.
- manage_edited_business_message(checker=lambda edited_business_message: ..., /)[source]¶
You must wrap a coroutine inside this decorator to manage an incoming edited_business_message
Update. The coroutine must takes only one argument, it will be processed asMessage. Then you need to call the methodlong_polling()using the function asyncio.run() to process theMessageupdate.Usage:
import apitele import asyncio from apitele.types import Message bot = apitele.Client('<your_api_token>') @bot.manage_business_message(lambda edited_business_message: edited_business_message.chat.id == xyz) async def foo(edited_business_message: Message): ... asyncio.run(bot.long_polling())
- Parameters:
checker (
Callable[[Message], Any]) – A function that takes only one argument to check an incoming edited_business_messageUpdate. E.g. a lambda function.
- manage_edited_channel_post(checker=lambda edited_channel_post: ..., /)[source]¶
You must wrap a coroutine inside this decorator to manage an incoming edited_channel_post
Update. The coroutine must takes only one argument, it will be processed asMessage. Then you need to call the methodlong_polling()using the function asyncio.run() to process theMessageupdate.Usage:
import apitele import asyncio from apitele.types import Message bot = apitele.Client('<your_api_token>') @bot.manage_edited_channel_post(lambda edited_channel_post: edited_channel_post.chat.id == xyz) async def foo(edited_channel_post: Message): ... asyncio.run(bot.long_polling())
- Parameters:
checker (
Callable[[Message], Any]) – A function that takes only one argument to check an incoming edited_channel_postUpdate. E.g. a lambda function.
- manage_edited_message(checker=lambda edited_message: ..., /)[source]¶
You must wrap a coroutine inside this decorator to manage an incoming edited_message
Update. The coroutine must takes only one argument, it will be processed asMessage. Then you need to call the methodlong_polling()using the function asyncio.run() to process theMessageupdate.Usage:
import apitele import asyncio from apitele.types import Message bot = apitele.Client('<your_api_token>') @bot.manage_edited_message(lambda edited_message: edited_message.chat.id == xyz) async def foo(edited_message: Message): ... asyncio.run(bot.long_polling())
- Parameters:
checker (
Callable[[Message], Any]) – A function that takes only one argument to check an incoming edited_messageUpdate. E.g. a lambda function.
- manage_inline_query(checker=lambda inline_query: ..., /)[source]¶
You must wrap a coroutine inside this decorator to manage an incoming inline_query
Update. The coroutine must takes only one argument, it will be processed asInlineQuery. Then you need to call the methodlong_polling()using the function asyncio.run() to process theInlineQueryupdate.Usage:
import apitele import asyncio from apitele.types import InlineQuery bot = apitele.Client('<your_api_token>') @bot.manage_inline_query(lambda inline_query: inline_query.from_user.id == xyz) async def foo(inline_query: InlineQuery): ... asyncio.run(bot.long_polling())
- Parameters:
checker (
Callable[[InlineQuery], Any]) – A function that takes only one argument to check an incoming inline_queryUpdate. E.g. a lambda function.
- manage_message(checker=lambda message: ..., /)[source]¶
You must wrap a coroutine inside this decorator to manage an incoming message
Update. The coroutine must takes only one argument, it will be processed asMessage. Then you need to call the methodlong_polling()using the function asyncio.run() to process theMessageupdate.Usage:
import apitele import asyncio from apitele.types import Message bot = apitele.Client('<your_api_token>') @bot.manage_message(lambda message: message.chat.id == xyz) async def foo(message: Message): ... asyncio.run(bot.long_polling())
- Parameters:
checker (
Callable[[Message], Any]) – A function that takes only one argument to check an incoming messageUpdate. E.g. a lambda function.
- manage_message_reaction(checker=lambda message_reaction: ..., /)[source]¶
You must wrap a coroutine inside this decorator to manage an incoming message_reaction
Update. The coroutine must takes only one argument, it will be processed asMessageReactionUpdated. Then you need to call the methodlong_polling()using the function asyncio.run() to process theMessageReactionUpdatedupdate.Usage:
import apitele import asyncio from apitele.types import MessageReactionUpdated bot = apitele.Client('<your_api_token>') @bot.manage_message_reaction(lambda message_reaction: message_reaction.chat.id == xyz) async def foo(message_reaction: MessageReactionUpdated): ... asyncio.run(bot.long_polling())
- Parameters:
checker (
Callable[[MessageReactionUpdated], Any]) – A function that takes only one argument to check an incoming message_reactionUpdate. E.g. a lambda function.
- manage_message_reaction_count(checker=lambda message_reaction_count: ..., /)[source]¶
You must wrap a coroutine inside this decorator to manage an incoming message_reaction_count
Update. The coroutine must takes only one argument, it will be processed asMessageReactionCountUpdated. Then you need to call the methodlong_polling()using the function asyncio.run() to process theMessageReactionCountUpdatedupdate.Usage:
import apitele import asyncio from apitele.types import MessageReactionCountUpdated bot = apitele.Client('<your_api_token>') @bot.manage_message_reaction_count(lambda message_reaction_count: message_reaction_count.chat.id == xyz) async def foo(message_reaction_count: MessageReactionCountUpdated): ... asyncio.run(bot.long_polling())
- Parameters:
checker (
Callable[[MessageReactionCountUpdated], Any]) – A function that takes only one argument to check an incoming message_reaction_countUpdate. E.g. a lambda function.
- manage_my_chat_member(checker=lambda my_chat_member: ..., /)[source]¶
You must wrap a coroutine inside this decorator to manage an incoming my_chat_member
Update. The coroutine must takes only one argument, it will be processed asChatMemberUpdated. Then you need to call the methodlong_polling()using the function asyncio.run() to process theChatMemberUpdatedupdate.Usage:
import apitele import asyncio from apitele.types import ChatMemberUpdated bot = apitele.Client('<your_api_token>') @bot.manage_my_chat_member(lambda my_chat_member: my_chat_member.chat.id == xyz) async def foo(my_chat_member: ChatMemberUpdated): ... asyncio.run(bot.long_polling())
- Parameters:
checker (
Callable[[ChatMemberUpdated], Any]) – A function that takes only one argument to check an incoming my_chat_memberUpdate. E.g. a lambda function.
- manage_poll(checker=lambda poll: ..., /)[source]¶
You must wrap a coroutine inside this decorator to manage an incoming poll
Update. The coroutine must takes only one argument, it will be processed asPoll. Then you need to call the methodlong_polling()using the function asyncio.run() to process thePollupdate.Usage:
import apitele import asyncio from apitele.types import Poll bot = apitele.Client('<your_api_token>') @bot.manage_poll(lambda poll: poll.id == xyz) async def foo(poll: Poll): ... asyncio.run(bot.long_polling())
- Parameters:
checker (
Callable[[Poll], Any]) – A function that takes only one argument to check an incoming pollUpdate. E.g. a lambda function.
- manage_poll_answer(checker=lambda poll_answer: ..., /)[source]¶
You must wrap a coroutine inside this decorator to manage an incoming poll_answer
Update. The coroutine must takes only one argument, it will be processed asPollAnswer. Then you need to call the methodlong_polling()using the function asyncio.run() to process thePollAnswerupdate.Usage:
import apitele import asyncio from apitele.types import PollAnswer bot = apitele.Client('<your_api_token>') @bot.manage_poll_answer(lambda poll_answer: poll_answer.poll_id == xyz) async def foo(poll_answer: PollAnswer): ... asyncio.run(bot.long_polling())
- Parameters:
checker (
Callable[[PollAnswer], Any]) – A function that takes only one argument to check an incoming poll_answerUpdate. E.g. a lambda function.
- manage_pre_checkout_query(checker=lambda pre_checkout_query: ..., /)[source]¶
You must wrap a coroutine inside this decorator to manage an incoming pre_checkout_query
Update. The coroutine must takes only one argument, it will be processed asPreCheckoutQuery. Then you need to call the methodlong_polling()using the function asyncio.run() to process thePreCheckoutQueryupdate.Usage:
import apitele import asyncio from apitele.types import PreCheckoutQuery bot = apitele.Client('<your_api_token>') @bot.manage_pre_checkout_query(lambda pre_checkout_query: pre_checkout_query.from_user.id == xyz) async def foo(pre_checkout_query: PreCheckoutQuery): ... asyncio.run(bot.long_polling())
- Parameters:
checker (
Callable[[PreCheckoutQuery], Any]) – A function that takes only one argument to check an incoming pre_checkout_queryUpdate. E.g. a lambda function.
- manage_purchased_paid_media(checker, /)[source]¶
You must wrap a coroutine inside this decorator to manage an incoming purchased_paid_media
Update. The coroutine must takes only one argument, it will be processed asPaidMediaPurchased. Then you need to call the methodlong_polling()using the function asyncio.run() to process thePaidMediaPurchasedupdate.Usage:
import apitele import asyncio from apitele.types import PaidMediaPurchased bot = apitele.Client('<your_api_token>') @bot.manage_purchased_paid_media(lambda purchased_paid_media: purchased_paid_media.from_user.id == xyz) async def foo(purchased_paid_media: PaidMediaPurchased): ... asyncio.run(bot.long_polling())
- Parameters:
checker (
Callable[[PaidMediaPurchased], Any]) – A function that takes only one argument to check an incoming purchased_paid_mediaUpdate. E.g. a lambda function.
- manage_removed_chat_boost(checker=lambda removed_chat_boost: ..., /)[source]¶
You must wrap a coroutine inside this decorator to manage an incoming removed_chat_boost
Update. The coroutine must takes only one argument, it will be processed asChatBoostRemoved. Then you need to call the methodlong_polling()using the function asyncio.run() to process theChatBoostRemovedupdate.Usage:
import apitele import asyncio from apitele.types import ChatBoostRemoved bot = apitele.Client('<your_api_token>') @bot.manage_removed_chat_boost(lambda removed_chat_boost: removed_chat_boost.chat.id == xyz) async def foo(removed_chat_boost: ChatBoostRemoved): ... asyncio.run(bot.long_polling())
- Parameters:
checker (
Callable[[ChatBoostRemoved], Any]) – A function that takes only one argument to check an incoming removed_chat_boostUpdate. E.g. a lambda function.
- manage_shipping_query(checker=lambda shipping_query: ..., /)[source]¶
You must wrap a coroutine inside this decorator to manage an incoming shipping_query
Update. The coroutine must takes only one argument, it will be processed asShippingQuery. Then you need to call the methodlong_polling()using the function asyncio.run() to process theShippingQueryupdate.Usage:
import apitele import asyncio from apitele.types import ShippingQuery bot = apitele.Client('<your_api_token>') @bot.manage_shipping_query(lambda shipping_query: shipping_query.from_user.id == xyz) async def foo(shipping_query: ShippingQuery): ... asyncio.run(bot.long_polling())
- Parameters:
checker (
Callable[[ShippingQuery], Any]) – A function that takes only one argument to check an incoming shipping_queryUpdate. E.g. a lambda function.
- async pin_chat_message(chat_id, message_id, disable_notification=None, business_connection_id=None)[source]¶
https://core.telegram.org/bots/api#pinchatmessage
Use this method to add a message to the list of pinned messages in a chat. If the chat is not a private chat, the bot must be an administrator in the chat for this to work and must have the can_pin_messages administrator right in a supergroup or can_edit_messages administrator right in a channel. Returns
Trueon success.- Parameters:
chat_id (
intorstr) – Unique identifier for the target chat or username of the target channel (in the format@channelusername).message_id (
int) – Identifier of a message to pin.disable_notification (
bool, optional) – PassTrueif it is not necessary to send a notification to all chat members about the new pinned message. Notifications are always disabled in channels and private chats.business_connection_id (
str, optional) – Unique identifier of the business connection on behalf of which the message will be pinned.
- Return type:
True
- async post_story(business_connection_id, content, active_period, caption=None, parse_mode=None, caption_entities=None, areas=None, post_to_chat_page=None, protect_content=None)[source]¶
https://core.telegram.org/bots/api#poststory
Posts a story on behalf of a managed business account. Requires the can_manage_stories business bot right. Returns
Storyon success.- Parameters:
business_connection_id (
str) – Unique identifier of the business connection.content (
InputStoryContent) – Content of the story.active_period (
int) – Period after which the story is moved to the archive, in seconds; must be one of6 * 3600,12 * 3600,86400, or2 * 86400.caption (
str, optional) – Caption of the story, 0-2048 characters after entities parsing.parse_mode (
str, optional) –Mode for parsing entities in the story caption. See formatting options for more details.
caption_entities (
listofMessageEntity, optional) – A JSON-serialized list of special entities that appear in the caption, which can be specified instead of parse_mode.areas (
listofStoryArea, optional) – A JSON-serialized list of clickable areas to be shown on the story.post_to_chat_page (
bool, optional) – PassTrueto keep the story accessible after it expires.protect_content (
bool, optional) – PassTrueif the content of the story must be protected from forwarding and screenshotting.
- Return type:
- async promote_chat_member(chat_id, user_id, is_anonymous=None, can_manage_chat=None, can_delete_messages=None, can_manage_video_chats=None, can_restrict_members=None, can_promote_members=None, can_change_info=None, can_invite_users=None, can_post_stories=None, can_edit_stories=None, can_delete_stories=None, can_post_messages=None, can_edit_messages=None, can_pin_messages=None, can_manage_topics=None, can_manage_direct_messages=None)[source]¶
https://core.telegram.org/bots/api#promotechatmember
Use this method to promote or demote a user in a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Pass
Falsefor all boolean parameters to demote a user. ReturnsTrueon success.- Parameters:
chat_id (
intorstr) – Unique identifier for the target chat or username of the target channel (in the format@channelusername).user_id (
int) – Unique identifier of the target user.is_anonymous (
bool, optional) – PassTrueif the administrator’s presence in the chat is hidden.can_manage_chat (
bool, optional) – PassTrueif the administrator can access the chat event log, get boost list, see hidden supergroup and channel members, report spam messages and ignore slow mode. Implied by any other administrator privilege.can_delete_messages (
bool, optional) – PassTrueif the administrator can delete messages of other users.can_manage_video_chats (
bool, optional) – PassTrueif the administrator can manage video chats.can_restrict_members (
bool, optional) – PassTrueif the administrator can restrict, ban or unban chat members, or access supergroup statistics.can_promote_members (
bool, optional) – PassTrueif the administrator can add new administrators with a subset of their own privileges or demote administrators that they have promoted, directly or indirectly (promoted by administrators that were appointed by him).can_change_info (
bool, optional) – PassTrueif the administrator can change chat title, photo and other settings.can_invite_users (
bool, optional) – PassTrueif the administrator can invite new users to the chat.can_post_stories (
bool, optional) – PassTrueif the administrator can post stories to the chat.can_edit_stories (
bool, optional) – PassTrueif the administrator can edit stories posted by other users.can_delete_stories (
bool, optional) – PassTrueif the administrator can delete stories posted by other users.can_post_messages (
bool, optional) – PassTrueif the administrator can post messages in the channel, or access channel statistics; for channels only.can_edit_messages (
bool, optional) – PassTrueif the administrator can edit messages of other users and can pin messages; for channels only.can_pin_messages (
bool, optional) – PassTrueif the administrator can pin messages; for supergroups only.can_manage_topics (
bool, optional) – PassTrueif the user is allowed to create, rename, close, and reopen forum topics; for supergroups only.can_manage_direct_messages (
bool, optional) – PassTrueif the administrator can manage direct messages within the channel and decline suggested posts; for channels only.
- Return type:
True
- async read_business_message(business_connection_id, chat_id, message_id)[source]¶
https://core.telegram.org/bots/api#readbusinessmessage
Marks incoming message as read on behalf of a business account. Requires the can_read_messages business bot right. Returns
Trueon success.- Parameters:
business_connection_id (
str) – Unique identifier of the business connection on behalf of which to read the message.chat_id (
int) – Unique identifier of the chat in which the message was received. The chat must have been active in the last 24 hours.message_id (
int) – Unique identifier of the message to mark as read.
- Return type:
True
- async refund_star_payment(user_id, telegram_payment_charge_id)[source]¶
https://core.telegram.org/bots/api#refundstarpayment
Refunds a successful payment in Telegram Stars. Returns
Trueon success.- Parameters:
user_id (
int) – Identifier of the user whose payment will be refunded.telegram_payment_charge_id (
str) – Telegram payment identifier.
- Return type:
True
- async remove_business_account_profile_photo(business_connection_id, is_public=None)[source]¶
https://core.telegram.org/bots/api#removebusinessaccountprofilephoto
Removes the current profile photo of a managed business account. Requires the can_edit_profile_photo business bot right. Returns
Trueon success.- Parameters:
business_connection_id (
str) – Unique identifier of the business connection.is_public (
bool, optional) – PassTrueto remove the public photo, which is visible even if the main photo is hidden by the business account’s privacy settings. After the main photo is removed, the previous profile photo (if present) becomes the main photo.
- Return type:
True
- async remove_chat_verification(chat_id)[source]¶
https://core.telegram.org/bots/api#removechatverification
Removes verification from a chat that is currently verified on behalf of the organization represented by the bot. Returns
Trueon success.- Parameters:
chat_id (
intorstr) – Unique identifier for the target chat or username of the target channel (in the format@channelusername).- Return type:
True
- async remove_user_verification(user_id)[source]¶
https://core.telegram.org/bots/api#removeuserverification
Removes verification from a user who is currently verified on behalf of the organization represented by the bot. Returns
Trueon success.- Parameters:
user_id (
int) – Unique identifier of the target user.- Return type:
True
- async reopen_forum_topic(chat_id, message_thread_id)[source]¶
https://core.telegram.org/bots/api#reopenforumtopic
Use this method to reopen a closed topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic. Returns
Trueon success.- Parameters:
chat_id (
intorstr) – Unique identifier for the target chat or username of the target supergroup (in the format@supergroupusername).message_thread_id (
int) – Unique identifier for the target message thread of the forum topic.
- Return type:
True
- async reopen_general_forum_topic(chat_id)[source]¶
https://core.telegram.org/bots/api#reopengeneralforumtopic
Use this method to reopen a closed ‘General’ topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. The topic will be automatically unhidden if it was hidden. Returns
Trueon success.- Parameters:
chat_id (
intorstr) – Unique identifier for the target chat or username of the target supergroup (in the format@supergroupusername).- Return type:
True
- async replace_sticker_in_set(user_id, name, old_sticker, sticker)[source]¶
https://core.telegram.org/bots/api#replacestickerinset
Use this method to replace an existing sticker in a sticker set with a new one. The method is equivalent to calling
delete_sticker_from_set(), thenadd_sticker_to_set(), thenset_sticker_position_in_set(). ReturnsTrueon success.- Parameters:
user_id (
int) – User identifier of the sticker set owner.name (
str) – Sticker set name.old_sticker (
str) – File identifier of the replaced sticker.sticker (
InputSticker) – A JSON-serialized object with information about the added sticker. If exactly the same sticker had already been added to the set, then the set remains unchanged.
- Return type:
True
- async restrict_chat_member(chat_id, user_id, permissions, use_independent_chat_permissions=None, until_date=None)[source]¶
https://core.telegram.org/bots/api#restrictchatmember
Use this method to restrict a user in a supergroup. The bot must be an administrator in the supergroup for this to work and must have the appropriate administrator rights. Pass
Truefor all permissions to lift restrictions from a user. ReturnsTrueon success.- Parameters:
chat_id (
intorstr) – Unique identifier for the target chat or username of the target supergroup (in the format@supergroupusername).user_id (
int) – Unique identifier of the target user.permissions (
ChatPermissions) – A JSON-serialized object for new user permissions.use_independent_chat_permissions (
bool, optional) – PassTrueif chat permissions are set independently. Otherwise, the can_send_other_messages and can_add_web_page_previews permissions will imply the can_send_messages, can_send_audios, can_send_documents, can_send_photos, can_send_videos, can_send_video_notes, and can_send_voice_notes permissions; the can_send_polls permission will imply the can_send_messages permission.until_date (
int, optional) – Date when restrictions will be lifted for the user; Unix time. If user is restricted for more than 366 days or less than 30 seconds from the current time, they are considered to be restricted forever.
- Return type:
True
- async revoke_chat_invite_link(chat_id, invite_link)[source]¶
https://core.telegram.org/bots/api#revokechatinvitelink
Use this method to revoke an invite link created by the bot. If the primary link is revoked, a new link is automatically generated. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the revoked invite link as
ChatInviteLinkobject.- Parameters:
chat_id (
intorstr) – Unique identifier of the target chat or username of the target channel (in the format@channelusername).invite_link (
str) – The invite link to revoke.
- Return type:
- async save_prepared_inline_message(user_id, result, allow_user_chats=None, allow_bot_chats=None, allow_group_chats=None, allow_channel_chats=None)[source]¶
https://core.telegram.org/bots/api#savepreparedinlinemessage
Stores a message that can be sent by a user of a Mini App. Returns a
PreparedInlineMessageobject.- Parameters:
user_id (
int) – Unique identifier of the target user that can use the prepared message.result (
InlineQueryResult) – A JSON-serialized object describing the message to be sent.allow_user_chats (
bool, optional) – PassTrueif the message can be sent to private chats with users.allow_bot_chats (
bool, optional) – PassTrueif the message can be sent to private chats with bots.allow_group_chats (
bool, optional) – PassTrueif the message can be sent to group and supergroup chats.allow_channel_chats (
bool, optional) – PassTrueif the message can be sent to channel chats.
- Return type:
- async send_animation(chat_id, animation, business_connection_id=None, message_thread_id=None, direct_messages_topic_id=None, duration=None, width=None, height=None, thumbnail=None, caption=None, parse_mode=None, caption_entities=None, show_caption_above_media=None, has_spoiler=None, disable_notification=None, protect_content=None, allow_paid_broadcast=None, message_effect_id=None, suggested_post_parameters=None, reply_parameters=None, reply_markup=None)[source]¶
https://core.telegram.org/bots/api#sendanimation
Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without sound). On success, the sent
Messageis returned. Bots can currently send animation files of up to 50 MB in size, this limit may be changed in the future.- Parameters:
chat_id (
intorstr) – Unique identifier for the target chat or username of the target channel (in the format@channelusername).animation (
InputFileorstr) – Animation to send. Pass a file_id as String to send an animation that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get an animation from the Internet, or upload a new animation using multipart/form-data. More information on Sending Files ».business_connection_id (
str, optional) – Unique identifier of the business connection on behalf of which the message will be sent.message_thread_id (
int, optional) – Unique identifier for the target message thread (topic) of the forum; for forum supergroups only.direct_messages_topic_id (
int, optional) – Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat.duration (
int, optional) – Duration of sent animation in seconds.width (
int, optional) – Animation width.height (
int, optional) – Animation height.thumbnail (
InputFileorstr, optional) –Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail’s width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. More information on Sending Files ».
caption (
str, optional) – Animation caption (may also be used when resending animation by file_id), 0-1024 characters after entities parsing.parse_mode (
str, optional) –Mode for parsing entities in the animation caption. See formatting options for more details.
caption_entities (
listofMessageEntity, optional) – A JSON-serialized list of special entities that appear in the caption, which can be specified instead of parse_mode.show_caption_above_media (
bool, optional) – PassTrue, if the caption must be shown above the message media.has_spoiler (
bool, optional) – PassTrueif the animation needs to be covered with a spoiler animation.disable_notification (
bool, optional) –Sends the message silently. Users will receive a notification with no sound.
protect_content (
bool, optional) – Protects the contents of the sent message from forwarding and saving.allow_paid_broadcast (
bool, optional) –Pass
Trueto allow up to 1000 messages per second, ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot’s balance.message_effect_id (
str, optional) – Unique identifier of the message effect to be added to the message; for private chats only.suggested_post_parameters (
SuggestedPostParameters, optional) – A JSON-serialized object containing the parameters of the suggested post to send; for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post is automatically declined.reply_parameters (
ReplyParameters, optional) – Description of the message to reply to.reply_markup (
REPLY_MARKUP_TYPES, optional) –Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
- Return type:
- async send_audio(chat_id, audio, business_connection_id=None, message_thread_id=None, direct_messages_topic_id=None, caption=None, parse_mode=None, caption_entities=None, duration=None, performer=None, title=None, thumbnail=None, disable_notification=None, protect_content=None, allow_paid_broadcast=None, message_effect_id=None, suggested_post_parameters=None, reply_parameters=None, reply_markup=None)[source]¶
https://core.telegram.org/bots/api#sendaudio
Use this method to send audio files, if you want Telegram clients to display them in the music player. Your audio must be in the .MP3 or .M4A format. On success, the sent
Messageis returned. Bots can currently send audio files of up to 50 MB in size, this limit may be changed in the future. For sending voice messages, use thesend_voice()method instead.- Parameters:
chat_id (
intorstr) – Unique identifier for the target chat or username of the target channel (in the format@channelusername).audio (
InputFileorstr) –Audio file to send. Pass a file_id as String to send an audio file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get an audio file from the Internet, or upload a new one using multipart/form-data. More information on Sending Files ».
business_connection_id (
str, optional) – Unique identifier of the business connection on behalf of which the message will be sent.message_thread_id (
int, optional) – Unique identifier for the target message thread (topic) of the forum; for forum supergroups only.direct_messages_topic_id (
int, optional) – Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat.caption (
str, optional) – Audio caption, 0-1024 characters after entities parsing.parse_mode (
str, optional) –Mode for parsing entities in the audio caption. See formatting options for more details.
caption_entities (
listofMessageEntity, optional) – A JSON-serialized list of special entities that appear in the caption, which can be specified instead of parse_mode.duration (
int, optional) – Duration of the audio in seconds.performer (
str, optional) – Performer.title (
str, optional) – Track name.thumbnail (
InputFileorstr, optional) –Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail’s width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. More information on Sending Files ».
disable_notification (
bool, optional) –Sends the message silently. Users will receive a notification with no sound.
protect_content (
bool, optional) – Protects the contents of the sent message from forwarding and saving.allow_paid_broadcast (
bool, optional) –Pass
Trueto allow up to 1000 messages per second, ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot’s balance.message_effect_id (
str, optional) – Unique identifier of the message effect to be added to the message; for private chats only.suggested_post_parameters (
SuggestedPostParameters, optional) – A JSON-serialized object containing the parameters of the suggested post to send; for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post is automatically declined.reply_parameters (
ReplyParameters, optional) – Description of the message to reply to.reply_markup (
REPLY_MARKUP_TYPES, optional) –Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
- Return type:
- async send_chat_action(chat_id, action, business_connection_id=None, message_thread_id=None)[source]¶
https://core.telegram.org/bots/api#sendchataction
Use this method when you need to tell the user that something is happening on the bot’s side. The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status). Returns
Trueon success.Example: The ImageBot needs some time to process a request and upload the image. Instead of sending a text message along the lines of “Retrieving image, please wait…”, the bot may use
send_chat_action()with action = upload_photo. The user will see a “sending photo” status for the bot.We only recommend using this method when a response from the bot will take a noticeable amount of time to arrive.
- Parameters:
chat_id (
intorstr) – Unique identifier for the target chat or username of the target channel (in the format@channelusername).action (
str) – Type of action to broadcast. Choose one, depending on what the user is about to receive: typing fortext messages, upload_photo forphotos, record_video or upload_video forvideos, record_voice or upload_voice forvoice notes, upload_document forgeneral files, choose_sticker forstickers, find_location forlocation data, record_video_note or upload_video_note forvideo notes.business_connection_id (
str, optional) – Unique identifier of the business connection on behalf of which the action will be sent.message_thread_id (
int, optional) – Unique identifier for the target message thread; for supergroups only.
- Return type:
True
- async send_checklist(business_connection_id, chat_id, checklist, disable_notification=None, protect_content=None, message_effect_id=None, reply_parameters=None, reply_markup=None)[source]¶
https://core.telegram.org/bots/api#sendchecklist
Use this method to send a checklist on behalf of a connected business account. On success, the sent
Messageis returned.- Parameters:
business_connection_id (
str) – Unique identifier of the business connection on behalf of which the message will be sent.chat_id (
int) – Unique identifier for the target chat.checklist (
InputChecklist) – A JSON-serialized object for the checklist to send.disable_notification (
bool, optional) – Sends the message silently. Users will receive a notification with no sound.protect_content (
bool, optional) – Protects the contents of the sent message from forwarding and saving.message_effect_id (
str, optional) – Unique identifier of the message effect to be added to the message.reply_parameters (
ReplyParameters, optional) – A JSON-serialized object for description of the message to reply to.reply_markup (
InlineKeyboardMarkup, optional) – A JSON-serialized object for an inline keyboard.
- Return type:
- async send_contact(chat_id, phone_number, first_name, business_connection_id=None, message_thread_id=None, direct_messages_topic_id=None, last_name=None, vcard=None, disable_notification=None, protect_content=None, allow_paid_broadcast=None, message_effect_id=None, suggested_post_parameters=None, reply_parameters=None, reply_markup=None)[source]¶
https://core.telegram.org/bots/api#sendcontact
Use this method to send phone contacts. On success, the sent
Messageis returned.- Parameters:
chat_id (
intorstr) – Unique identifier for the target chat or username of the target channel (in the format@channelusername).phone_number (
str) – Contact’s phone number.first_name (
str) – Contact’s first name.business_connection_id (
str, optional) – Unique identifier of the business connection on behalf of which the message will be sent.message_thread_id (
int, optional) – Unique identifier for the target message thread (topic) of the forum; for forum supergroups only.direct_messages_topic_id (
int, optional) – Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat.last_name (
str, optional) – Contact’s last name.vcard (
str, optional) – Additional data about the contact in the form of a vCard, 0-2048 bytes.disable_notification (
bool, optional) –Sends the message silently. Users will receive a notification with no sound.
protect_content (
bool, optional) – Protects the contents of the sent message from forwarding and saving.allow_paid_broadcast (
bool, optional) –Pass
Trueto allow up to 1000 messages per second, ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot’s balance.message_effect_id (
str, optional) – Unique identifier of the message effect to be added to the message; for private chats only.suggested_post_parameters (
SuggestedPostParameters, optional) – A JSON-serialized object containing the parameters of the suggested post to send; for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post is automatically declined.reply_parameters (
ReplyParameters, optional) – Description of the message to reply to.reply_markup (
REPLY_MARKUP_TYPES, optional) –Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
- Return type:
- async send_dice(chat_id, business_connection_id=None, message_thread_id=None, direct_messages_topic_id=None, emoji=None, disable_notification=None, protect_content=None, allow_paid_broadcast=None, message_effect_id=None, suggested_post_parameters=None, reply_parameters=None, reply_markup=None)[source]¶
https://core.telegram.org/bots/api#senddice
Use this method to send an animated emoji that will display a random value. On success, the sent
Messageis returned.- Parameters:
chat_id (
intorstr) – Unique identifier for the target chat or username of the target channel (in the format@channelusername).business_connection_id (
str, optional) – Unique identifier of the business connection on behalf of which the message will be sent.message_thread_id (
int, optional) – Unique identifier for the target message thread (topic) of the forum; for forum supergroups only.direct_messages_topic_id (
int, optional) – Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat.emoji (
str, optional) – Emoji on which the dice throw animation is based. Currently, must be one of “🎲”, “🎯”, “🏀”, “⚽”, “🎳”, or “🎰”. Dice can have values 1-6 for “🎲”, “🎯” and “🎳”, values 1-5 for “🏀” and “⚽”, and values 1-64 for “🎰”. Defaults to “🎲”.disable_notification (
bool, optional) –Sends the message silently. Users will receive a notification with no sound.
protect_content (
bool, optional) – Protects the contents of the sent message from forwarding.allow_paid_broadcast (
bool, optional) –Pass
Trueto allow up to 1000 messages per second, ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot’s balance.message_effect_id (
str, optional) – Unique identifier of the message effect to be added to the message; for private chats only.suggested_post_parameters (
SuggestedPostParameters, optional) – A JSON-serialized object containing the parameters of the suggested post to send; for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post is automatically declined.reply_parameters (
ReplyParameters, optional) – Description of the message to reply to.reply_markup (
REPLY_MARKUP_TYPES, optional) –Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
- Return type:
- async send_document(chat_id, document, business_connection_id=None, message_thread_id=None, direct_messages_topic_id=None, thumbnail=None, caption=None, parse_mode=None, caption_entities=None, disable_content_type_detection=None, disable_notification=None, protect_content=None, allow_paid_broadcast=None, message_effect_id=None, suggested_post_parameters=None, reply_parameters=None, reply_markup=None)[source]¶
https://core.telegram.org/bots/api#senddocument
Use this method to send general files. On success, the sent
Messageis returned. Bots can currently send files of any type of up to 50 MB in size, this limit may be changed in the future.- Parameters:
chat_id (
intorstr) – Unique identifier for the target chat or username of the target channel (in the format@channelusername).document (
InputFileorstr) –File to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. More information on Sending Files ».
business_connection_id (
str, optional) – Unique identifier of the business connection on behalf of which the message will be sent.message_thread_id (
int, optional) – Unique identifier for the target message thread (topic) of the forum; for forum supergroups only.direct_messages_topic_id (
int, optional) – Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat.thumbnail (
InputFileorstr, optional) –Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail’s width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. More information on Sending Files ».
caption (
str, optional) – Document caption (may also be used when resending documents by file_id), 0-1024 characters after entities parsing.parse_mode (
str, optional) –Mode for parsing entities in the document caption. See formatting options for more details.
caption_entities (
listofMessageEntity, optional) – A JSON-serialized list of special entities that appear in the caption, which can be specified instead of parse_mode.disable_content_type_detection (
bool, optional) – Disables automatic server-side content type detection for files uploaded using multipart/form-data.disable_notification (
bool, optional) –Sends the message silently. Users will receive a notification with no sound.
protect_content (
bool, optional) – Protects the contents of the sent message from forwarding and saving.allow_paid_broadcast (
bool, optional) –Pass
Trueto allow up to 1000 messages per second, ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot’s balance.message_effect_id (
str, optional) – Unique identifier of the message effect to be added to the message; for private chats only.suggested_post_parameters (
SuggestedPostParameters, optional) – A JSON-serialized object containing the parameters of the suggested post to send; for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post is automatically declined.reply_parameters (
ReplyParameters, optional) – Description of the message to reply to.reply_markup (
REPLY_MARKUP_TYPES, optional) –Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
- Return type:
- async send_game(chat_id, game_short_name, business_connection_id=None, message_thread_id=None, disable_notification=None, protect_content=None, allow_paid_broadcast=None, message_effect_id=None, reply_parameters=None, reply_markup=None)[source]¶
https://core.telegram.org/bots/api#sendgame
Use this method to send a game. On success, the sent
Messageis returned.- Parameters:
chat_id (
int) – Unique identifier for the target chat.game_short_name (
str) –Short name of the game, serves as the unique identifier for the game. Set up your games via @BotFather.
business_connection_id (
str, optional) – Unique identifier of the business connection on behalf of which the message will be sent.message_thread_id (
int, optional) – Unique identifier for the target message thread (topic) of the forum; for forum supergroups only.disable_notification (
bool, optional) –Sends the message silently. Users will receive a notification with no sound.
protect_content (
bool, optional) – Protects the contents of the sent message from forwarding and saving.allow_paid_broadcast (
bool, optional) –Pass
Trueto allow up to 1000 messages per second, ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot’s balance.message_effect_id (
str, optional) – Unique identifier of the message effect to be added to the message; for private chats only.reply_parameters (
ReplyParameters, optional) – Description of the message to reply to.reply_markup (
InlineKeyboardMarkup, optional) –A JSON-serialized object for an inline keyboard. If empty, one ‘Play game_title’ button will be shown. If not empty, the first button must launch the game.
- Return type:
- async send_gift(gift_id, user_id=None, chat_id=None, pay_for_upgrade=None, text=None, text_parse_mode=None, text_entities=None)[source]¶
https://core.telegram.org/bots/api#sendgift
Sends a gift to the given user or channel chat. The gift can’t be converted to Telegram Stars by the receiver. Returns
Trueon success.- Parameters:
gift_id (
str) – Identifier of the gift.user_id (
int, optional) – Required if chat_id is not specified. Unique identifier of the target user who will receive the gift.chat_id (
intorstr, optional) – Required if user_id is not specified. Unique identifier for the chat or username of the channel (in the format@channelusername) that will receive the gift.pay_for_upgrade (
bool, optional) – PassTrueto pay for the gift upgrade from the bot’s balance, thereby making the upgrade free for the receiver.text (
str, optional) – Text that will be shown along with the gift; 0-128 characters.text_parse_mode (
str, optional) –Mode for parsing entities in the text. See formatting options for more details. Entities other than “bold”, “italic”, “underline”, “strikethrough”, “spoiler”, and “custom_emoji” are ignored.
text_entities (
listofMessageEntity, optional) – A JSON-serialized list of special entities that appear in the gift text. It can be specified instead of text_parse_mode. Entities other than “bold”, “italic”, “underline”, “strikethrough”, “spoiler”, and “custom_emoji” are ignored.
- Return type:
True
- async send_invoice(chat_id, title, description, payload, currency, prices, message_thread_id=None, direct_messages_topic_id=None, provider_token=None, max_tip_amount=None, suggested_tip_amounts=None, start_parameter=None, provider_data=None, photo_url=None, photo_size=None, photo_width=None, photo_height=None, need_name=None, need_phone_number=None, need_email=None, need_shipping_address=None, send_phone_number_to_provider=None, send_email_to_provider=None, is_flexible=None, disable_notification=None, protect_content=None, allow_paid_broadcast=None, message_effect_id=None, suggested_post_parameters=None, reply_parameters=None, reply_markup=None)[source]¶
https://core.telegram.org/bots/api#sendinvoice
Use this method to send invoices. On success, the sent
Messageis returned.- Parameters:
chat_id (
intorstr) – Unique identifier for the target chat or username of the target channel (in the format@channelusername).title (
str) – Product name, 1-32 characters.description (
str) – Product description, 1-255 characters.payload (
str) – Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes.currency (
str) –Three-letter ISO 4217 currency code, see more on currencies. Pass “XTR” for payments in Telegram Stars.
prices (
listofLabeledPrice) –Price breakdown, a JSON-serialized list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.). Must contain exactly one item for payments in Telegram Stars.
message_thread_id (
int, optional) – Unique identifier for the target message thread (topic) of the forum; for forum supergroups only.direct_messages_topic_id (
int, optional) – Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat.provider_token (
str, optional) –Payment provider token, obtained via @BotFather. Pass an empty string for payments in Telegram Stars.
max_tip_amount (
int, optional) –The maximum accepted amount for tips in the smallest units of the currency (integer, not float/double). For example, for a maximum tip of
US$ 1.45passmax_tip_amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies). Defaults to0. Not supported for payments in Telegram Stars.suggested_tip_amounts (
listofint, optional) – A JSON-serialized array of suggested amounts of tips in the smallest units of the currency (integer, not float/double). At most 4 suggested tip amounts can be specified. The suggested tip amounts must be positive, passed in a strictly increased order and must not exceed max_tip_amount.start_parameter (
str, optional) – Unique deep-linking parameter. If left empty, forwarded copies of the sent message will have a Pay button, allowing multiple users to pay directly from the forwarded message, using the same invoice. If non-empty, forwarded copies of the sent message will have a URL button with a deep link to the bot (instead of a Pay button), with the value used as the start parameter.provider_data (
str, optional) – JSON-serialized data about the invoice, which will be shared with the payment provider. A detailed description of required fields should be provided by the payment provider.photo_url (
str, optional) – URL of the product photo for the invoice. Can be a photo of the goods or a marketing image for a service. People like it better when they see what they are paying for.photo_size (
int, optional) – Photo size in bytes.photo_width (
int, optional) – Photo width.photo_height (
int, optional) – Photo height.need_name (
bool, optional) –Pass
Trueif you require the user’s full name to complete the order. Ignored for payments in Telegram Stars.need_phone_number (
bool, optional) –Pass
Trueif you require the user’s phone number to complete the order. Ignored for payments in Telegram Stars.need_email (
bool, optional) –Pass
Trueif you require the user’s email address to complete the order. Ignored for payments in Telegram Stars.need_shipping_address (
bool, optional) –Pass
Trueif you require the user’s shipping address to complete the order. Ignored for payments in Telegram Stars.send_phone_number_to_provider (
bool, optional) –Pass
Trueif the user’s phone number should be sent to provider. Ignored for payments in Telegram Stars.send_email_to_provider (
bool, optional) –Pass
Trueif the user’s email address should be sent to provider. Ignored for payments in Telegram Stars.is_flexible (
bool, optional) –Pass
Trueif the final price depends on the shipping method. Ignored for payments in Telegram Stars.disable_notification (
bool, optional) –Sends the message silently. Users will receive a notification with no sound.
protect_content (
bool, optional) – Protects the contents of the sent message from forwarding and saving.allow_paid_broadcast (
bool, optional) –Pass
Trueto allow up to 1000 messages per second, ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot’s balance.message_effect_id (
str, optional) – Unique identifier of the message effect to be added to the message; for private chats only.suggested_post_parameters (
SuggestedPostParameters, optional) – A JSON-serialized object containing the parameters of the suggested post to send; for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post is automatically declined.reply_parameters (
ReplyParameters, optional) – Description of the message to reply to.reply_markup (
InlineKeyboardMarkup, optional) –A JSON-serialized object for an inline keyboard. If empty, one ‘Pay
total price’ button will be shown. If not empty, the first button must be a Pay button.
- Return type:
- async send_location(chat_id, latitude, longitude, business_connection_id=None, message_thread_id=None, direct_messages_topic_id=None, horizontal_accuracy=None, live_period=None, heading=None, proximity_alert_radius=None, disable_notification=None, protect_content=None, allow_paid_broadcast=None, message_effect_id=None, suggested_post_parameters=None, reply_parameters=None, reply_markup=None)[source]¶
https://core.telegram.org/bots/api#sendlocation
Use this method to send point on the map. On success, the sent
Messageis returned.- Parameters:
chat_id (
intorstr) – Unique identifier for the target chat or username of the target channel (in the format@channelusername).latitude (
float) – Latitude of the location.longitude (
float) – Longitude of the location.business_connection_id (
str, optional) – Unique identifier of the business connection on behalf of which the message will be sent.message_thread_id (
int, optional) – Unique identifier for the target message thread (topic) of the forum; for forum supergroups only.direct_messages_topic_id (
int, optional) – Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat.horizontal_accuracy (
float, optional) – The radius of uncertainty for the location, measured in meters; 0-1500.live_period (
int, optional) – Period in seconds for which the location will be updated (see Live Locations, should be between 60 and 86400.heading (
int, optional) – For live locations, a direction in which the user is moving, in degrees. Must be between 1 and 360 if specified.proximity_alert_radius (
int, optional) – For live locations, a maximum distance for proximity alerts about approaching another chat member, in meters. Must be between 1 and 100000 if specified.disable_notification (
bool, optional) –Sends the message silently. Users will receive a notification with no sound.
protect_content (
bool, optional) – Protects the contents of the sent message from forwarding and saving.allow_paid_broadcast (
bool, optional) –Pass
Trueto allow up to 1000 messages per second, ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot’s balance.message_effect_id (
str, optional) – Unique identifier of the message effect to be added to the message; for private chats only.suggested_post_parameters (
SuggestedPostParameters, optional) – A JSON-serialized object containing the parameters of the suggested post to send; for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post is automatically declined.reply_parameters (
ReplyParameters, optional) – Description of the message to reply to.reply_markup (
REPLY_MARKUP_TYPES, optional) –Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
- Return type:
- async send_media_group(chat_id, media, business_connection_id=None, message_thread_id=None, direct_messages_topic_id=None, disable_notification=None, protect_content=None, allow_paid_broadcast=None, message_effect_id=None, reply_parameters=None)[source]¶
https://core.telegram.org/bots/api#sendmediagroup
Use this method to send a group of photos, videos, documents or audios as an album. Documents and audio files can be only grouped in an album with messages of the same type. On success, an array of
Messagesthat were sent is returned.- Parameters:
chat_id (
intorstr) – Unique identifier for the target chat or username of the target channel (in the format@channelusername).media (
listofInputMediaAudio,InputMediaDocument,InputMediaPhotoandInputMediaVideo) – A JSON-serialized array describing messages to be sent, must include 2-10 items.business_connection_id (
str, optional) – Unique identifier of the business connection on behalf of which the message will be sent.message_thread_id (
int, optional) – Unique identifier for the target message thread (topic) of the forum; for forum supergroups only.direct_messages_topic_id (
int, optional) – Identifier of the direct messages topic to which the messages will be sent; required if the messages are sent to a direct messages chat.disable_notification (
bool, optional) –Sends messages silently. Users will receive a notification with no sound.
protect_content (
bool, optional) – Protects the contents of the sent messages from forwarding and saving.allow_paid_broadcast (
bool, optional) –Pass
Trueto allow up to 1000 messages per second, ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot’s balance.message_effect_id (
str, optional) – Unique identifier of the message effect to be added to the message; for private chats only.reply_parameters (
ReplyParameters, optional) – Description of the message to reply to.
- Return type:
listofMessage
- async send_message(chat_id, text, business_connection_id=None, message_thread_id=None, direct_messages_topic_id=None, parse_mode=None, entities=None, link_preview_options=None, disable_notification=None, protect_content=None, allow_paid_broadcast=None, message_effect_id=None, suggested_post_parameters=None, reply_parameters=None, reply_markup=None)[source]¶
https://core.telegram.org/bots/api#sendmessage
Use this method to send text messages. On success, the sent
Messageis returned.- Parameters:
chat_id (
intorstr) – Unique identifier for the target chat or username of the target channel (in the format@channelusername).text (
str) – Text of the message to be sent, 1-4096 characters after entities parsing.business_connection_id (
str, optional) – Unique identifier of the business connection on behalf of which the message will be sent.message_thread_id (
int, optional) – Unique identifier for the target message thread (topic) of the forum; for forum supergroups only.direct_messages_topic_id (
int, optional) – Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat.parse_mode (
str, optional) –Mode for parsing entities in the message text. See formatting options for more details.
entities (
listofMessageEntity, optional) – A JSON-serialized list of special entities that appear in message text, which can be specified instead of parse_mode.link_preview_options (
LinkPreviewOptions, optional) – Link preview generation options for the message.disable_notification (
bool, optional) –Sends the message silently. Users will receive a notification with no sound.
protect_content (
bool, optional) – Protects the contents of the sent message from forwarding and saving.allow_paid_broadcast (
bool, optional) –Pass
Trueto allow up to 1000 messages per second, ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot’s balance.message_effect_id (
str, optional) – Unique identifier of the message effect to be added to the message; for private chats only.suggested_post_parameters (
SuggestedPostParameters, optional) – A JSON-serialized object containing the parameters of the suggested post to send; for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post is automatically declined.reply_parameters (
ReplyParameters, optional) – Description of the message to reply to.reply_markup (
REPLY_MARKUP_TYPES, optional) –Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
- Return type:
- async send_paid_media(chat_id, star_count, media, business_connection_id=None, message_thread_id=None, direct_messages_topic_id=None, payload=None, caption=None, parse_mode=None, caption_entities=None, show_caption_above_media=None, disable_notification=None, protect_content=None, allow_paid_broadcast=None, suggested_post_parameters=None, reply_parameters=None, reply_markup=None)[source]¶
https://core.telegram.org/bots/api#sendpaidmedia
Use this method to send paid media to channel chats. On success, the sent
Messageis returned.- Parameters:
chat_id (
intorstr) – Unique identifier for the target chat or username of the target channel (in the format@channelusername).star_count (
int) – The number of Telegram Stars that must be paid to buy access to the media.media (
listofInputPaidMedia) – A JSON-serialized array describing the media to be sent; up to 10 items.business_connection_id (
str, optional) – Unique identifier of the business connection on behalf of which the message will be sent.message_thread_id (
int, optional) – Unique identifier for the target message thread (topic) of the forum; for forum supergroups only.direct_messages_topic_id (
int, optional) – Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat.payload (
str, optional) – Bot-defined paid media payload, 0-128 bytes. This will not be displayed to the user, use it for your internal processes.caption (
str, optional) – Media caption, 0-1024 characters after entities parsingparse_mode (
str, optional) –Mode for parsing entities in the media caption. See formatting options for more details.
caption_entities (
listofMessageEntity, optional) – A JSON-serialized list of special entities that appear in the caption, which can be specified instead of parse_mode.show_caption_above_media (
bool, optional) – PassTrue, if the caption must be shown above the message media.disable_notification (
bool, optional) –Sends the message silently. Users will receive a notification with no sound.
protect_content (
bool, optional) – Protects the contents of the sent message from forwarding and saving.allow_paid_broadcast (
bool, optional) –Pass
Trueto allow up to 1000 messages per second, ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot’s balance.suggested_post_parameters (
SuggestedPostParameters, optional) – A JSON-serialized object containing the parameters of the suggested post to send; for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post is automatically declined.reply_parameters (
ReplyParameters, optional) – Description of the message to reply to.reply_markup (
REPLY_MARKUP_TYPES, optional) –Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove a reply keyboard or to force a reply from the user.
- Return type:
- async send_photo(chat_id, photo, business_connection_id=None, message_thread_id=None, direct_messages_topic_id=None, caption=None, parse_mode=None, caption_entities=None, show_caption_above_media=None, has_spoiler=None, disable_notification=None, protect_content=None, allow_paid_broadcast=None, message_effect_id=None, suggested_post_parameters=None, reply_parameters=None, reply_markup=None)[source]¶
https://core.telegram.org/bots/api#sendphoto
Use this method to send photos. On success, the sent
Messageis returned.- Parameters:
chat_id (
intorstr) – Unique identifier for the target chat or username of the target channel (in the format@channelusername).photo (
InputFileorstr) –Photo to send. Pass a file_id as String to send a photo that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a photo from the Internet, or upload a new photo using multipart/form-data. The photo must be at most 10 MB in size. The photo’s width and height must not exceed 10000 in total. Width and height ratio must be at most 20. More information on Sending Files ».
business_connection_id (
str, optional) – Unique identifier of the business connection on behalf of which the message will be sent.message_thread_id (
int, optional) – Unique identifier for the target message thread (topic) of the forum; for forum supergroups only.direct_messages_topic_id (
int, optional) – Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat.caption (
str, optional) – Photo caption (may also be used when resending photos by file_id), 0-1024 characters after entities parsing.parse_mode (
str, optional) –Mode for parsing entities in the photo caption. See formatting options for more details.
caption_entities (
listofMessageEntity, optional) – A JSON-serialized list of special entities that appear in the caption, which can be specified instead of parse_mode.show_caption_above_media (
bool, optional) – PassTrue, if the caption must be shown above the message media.has_spoiler (
bool, optional) – PassTrueif the photo needs to be covered with a spoiler animation.disable_notification (
bool, optional) –Sends the message silently. Users will receive a notification with no sound.
protect_content (
bool, optional) – Protects the contents of the sent message from forwarding and saving.allow_paid_broadcast (
bool, optional) –Pass
Trueto allow up to 1000 messages per second, ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot’s balance.message_effect_id (
str, optional) – Unique identifier of the message effect to be added to the message; for private chats only.suggested_post_parameters (
SuggestedPostParameters, optional) – A JSON-serialized object containing the parameters of the suggested post to send; for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post is automatically declined.reply_parameters (
ReplyParameters, optional) – Description of the message to reply to.reply_markup (
REPLY_MARKUP_TYPES, optional) –Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
- Return type:
- async send_poll(chat_id, question, options, business_connection_id=None, message_thread_id=None, question_parse_mode=None, question_entities=None, is_anonymous=None, type=None, allows_multiple_answers=None, correct_option_id=None, explanation=None, explanation_parse_mode=None, explanation_entities=None, open_period=None, close_date=None, is_closed=None, disable_notification=None, protect_content=None, allow_paid_broadcast=None, message_effect_id=None, reply_parameters=None, reply_markup=None)[source]¶
https://core.telegram.org/bots/api#sendpoll
Use this method to send a native poll. On success, the sent
Messageis returned.- Parameters:
chat_id (
intorstr) – Unique identifier for the target chat or username of the target channel (in the format@channelusername).question (
str) – Poll question, 1-300 characters.options (
listofInputPollOption) – A JSON-serialized list of 2-10 answer options.business_connection_id (
str, optional) – Unique identifier of the business connection on behalf of which the message will be sent.message_thread_id (
int, optional) – Unique identifier for the target message thread (topic) of the forum; for forum supergroups only.question_parse_mode (
str, optional) –Mode for parsing entities in the question. See formatting options for more details. Currently, only custom emoji entities are allowed.
question_entities (
listofMessageEntity, optional) – A JSON-serialized list of special entities that appear in the poll question. It can be specified instead of question_parse_mode.is_anonymous (
bool, optional) –True, if the poll needs to be anonymous, defaults toTrue.type (
str, optional) – Poll type, “quiz” or “regular”, defaults to “regular”.allows_multiple_answers (
bool, optional) –True, if the poll allows multiple answers, ignored for polls in quiz mode, defaults toFalse.correct_option_id (
int, optional) – 0-based identifier of the correct answer option, required for polls in quiz mode.explanation (
str, optional) – Text that is shown when a user chooses an incorrect answer or taps on the lamp icon in a quiz-style poll, 0-200 characters with at most 2 line feeds after entities parsing.explanation_parse_mode (
str, optional) –Mode for parsing entities in the explanation. See formatting options for more details.
explanation_entities (
listofMessageEntity, optional) – A JSON-serialized list of special entities that appear in the poll explanation, which can be specified instead of parse_mode.open_period (
int, optional) – Amount of time in seconds the poll will be active after creation, 5-600. Can’t be used together with close_date.close_date (
int, optional) – Point in time (Unix timestamp) when the poll will be automatically closed. Must be at least 5 and no more than 600 seconds in the future. Can’t be used together with open_period.is_closed (
bool, optional) – PassTrueif the poll needs to be immediately closed. This can be useful for poll preview.disable_notification (
bool, optional) –Sends the message silently. Users will receive a notification with no sound.
protect_content (
bool, optional) – Protects the contents of the sent message from forwarding and saving.allow_paid_broadcast (
bool, optional) –Pass
Trueto allow up to 1000 messages per second, ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot’s balance.message_effect_id (
str, optional) – Unique identifier of the message effect to be added to the message; for private chats only.reply_parameters (
ReplyParameters, optional) – Description of the message to reply to.reply_markup (
REPLY_MARKUP_TYPES, optional) –Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
- Return type:
- async send_sticker(chat_id, sticker, business_connection_id=None, message_thread_id=None, direct_messages_topic_id=None, emoji=None, disable_notification=None, protect_content=None, allow_paid_broadcast=None, message_effect_id=None, suggested_post_parameters=None, reply_parameters=None, reply_markup=None)[source]¶
https://core.telegram.org/bots/api#sendsticker
Use this method to send static .WEBP, animated .TGS, or video .WEBM stickers. On success, the sent
Messageis returned.- Parameters:
chat_id (
intorstr) – Unique identifier for the target chat or username of the target channel (in the format@channelusername).sticker (
InputFileorstr) –Sticker to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a .WEBP sticker from the Internet, or upload a new .WEBP or .TGS sticker using multipart/form-data. More information on Sending Files ». Video stickers can only be sent by a file_id. Animated stickers can’t be sent via an HTTP URL.
business_connection_id (
str, optional) – Unique identifier of the business connection on behalf of which the message will be sent.message_thread_id (
int, optional) – Unique identifier for the target message thread (topic) of the forum; for forum supergroups only.direct_messages_topic_id (
int, optional) – Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat.emoji (
str, optional) – Emoji associated with the sticker; only for just uploaded stickers.disable_notification (
bool, optional) –Sends the message silently. Users will receive a notification with no sound.
protect_content (
bool, optional) – Protects the contents of the sent message from forwarding and saving.allow_paid_broadcast (
bool, optional) –Pass
Trueto allow up to 1000 messages per second, ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot’s balance.message_effect_id (
str, optional) – Unique identifier of the message effect to be added to the message; for private chats only.suggested_post_parameters (
SuggestedPostParameters, optional) – A JSON-serialized object containing the parameters of the suggested post to send; for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post is automatically declined.reply_parameters (
ReplyParameters, optional) – Description of the message to reply to.reply_markup (
REPLY_MARKUP_TYPES, optional) –Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
- Return type:
- async send_venue(chat_id, latitude, longitude, title, address, business_connection_id=None, message_thread_id=None, direct_messages_topic_id=None, foursquare_id=None, foursquare_type=None, google_place_id=None, google_place_type=None, disable_notification=None, protect_content=None, allow_paid_broadcast=None, message_effect_id=None, suggested_post_parameters=None, reply_parameters=None, reply_markup=None)[source]¶
https://core.telegram.org/bots/api#sendvenue
Use this method to send information about a venue. On success, the sent
Messageis returned.- Parameters:
chat_id (
intorstr) – Unique identifier for the target chat or username of the target channel (in the format@channelusername).latitude (
float) – Latitude of the venue.longitude (
float) – Longitude of the venue.title (
str) – Name of the venue.address (
str) – Address of the venue.business_connection_id (
str, optional) – Unique identifier of the business connection on behalf of which the message will be sent.message_thread_id (
int, optional) – Unique identifier for the target message thread (topic) of the forum; for forum supergroups only.direct_messages_topic_id (
int, optional) – Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat.foursquare_id (
str, optional) – Foursquare identifier of the venue.foursquare_type (
str, optional) – Foursquare type of the venue, if known. (For example, “arts_entertainment/default”, “arts_entertainment/aquarium” or “food/icecream”.)google_place_id (
str, optional) – Google Places identifier of the venue.google_place_type (
str, optional) – Google Places type of the venue. (See supported types.)disable_notification (
bool, optional) –Sends the message silently. Users will receive a notification with no sound.
protect_content (
bool, optional) – Protects the contents of the sent message from forwarding and saving.allow_paid_broadcast (
bool, optional) –Pass
Trueto allow up to 1000 messages per second, ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot’s balance.message_effect_id (
str, optional) – Unique identifier of the message effect to be added to the message; for private chats only.suggested_post_parameters (
SuggestedPostParameters, optional) – A JSON-serialized object containing the parameters of the suggested post to send; for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post is automatically declined.reply_parameters (
ReplyParameters, optional) – Description of the message to reply to.reply_markup (
REPLY_MARKUP_TYPES, optional) –Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
- Return type:
- async send_video(chat_id, video, business_connection_id=None, message_thread_id=None, direct_messages_topic_id=None, duration=None, width=None, height=None, thumbnail=None, cover=None, start_timestamp=None, caption=None, parse_mode=None, caption_entities=None, show_caption_above_media=None, has_spoiler=None, supports_streaming=None, disable_notification=None, protect_content=None, allow_paid_broadcast=None, message_effect_id=None, suggested_post_parameters=None, reply_parameters=None, reply_markup=None)[source]¶
https://core.telegram.org/bots/api#sendvideo
Use this method to send video files, Telegram clients support MPEG4 videos (other formats may be sent as
Document). On success, the sentMessageis returned. Bots can currently send video files of up to 50 MB in size, this limit may be changed in the future.- Parameters:
chat_id (
intorstr) – Unique identifier for the target chat or username of the target channel (in the format@channelusername).video (
InputFileorstr) –Video to send. Pass a file_id as String to send a video that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a video from the Internet, or upload a new video using multipart/form-data. More information on Sending Files ».
business_connection_id (
str, optional) – Unique identifier of the business connection on behalf of which the message will be sent.message_thread_id (
int, optional) – Unique identifier for the target message thread (topic) of the forum; for forum supergroups only.direct_messages_topic_id (
int, optional) – Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat.duration (
int, optional) – Duration of sent video in seconds.width (
int, optional) – Video width.height (
int, optional) – Video height.thumbnail (
InputFileorstr, optional) –Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail’s width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. More information on Sending Files ».
cover (
InputFileorstr, optional) –Cover for the video in the message. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass “attach://<file_attach_name>” to upload a new one using multipart/form-data under <file_attach_name> name. More information on Sending Files ».
start_timestamp (
int, optional) – Start timestamp for the video in the message.caption (
str, optional) – Video caption (may also be used when resending videos by file_id), 0-1024 characters after entities parsing.parse_mode (
str, optional) –Mode for parsing entities in the video caption. See formatting options for more details.
caption_entities (
listofMessageEntity, optional) – A JSON-serialized list of special entities that appear in the caption, which can be specified instead of parse_mode.show_caption_above_media (
bool, optional) – PassTrue, if the caption must be shown above the message media.has_spoiler (
bool, optional) – PassTrueif the video needs to be covered with a spoiler animation.supports_streaming (
bool, optional) – PassTrueif the uploaded video is suitable for streaming.disable_notification (
bool, optional) –Sends the message silently. Users will receive a notification with no sound.
protect_content (
bool, optional) – Protects the contents of the sent message from forwarding and saving.allow_paid_broadcast (
bool, optional) –Pass
Trueto allow up to 1000 messages per second, ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot’s balance.message_effect_id (
str, optional) – Unique identifier of the message effect to be added to the message; for private chats only.suggested_post_parameters (
SuggestedPostParameters, optional) – A JSON-serialized object containing the parameters of the suggested post to send; for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post is automatically declined.reply_parameters (
ReplyParameters, optional) – Description of the message to reply to.reply_markup (
REPLY_MARKUP_TYPES, optional) –Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
- Return type:
- async send_video_note(chat_id, video_note, business_connection_id=None, message_thread_id=None, direct_messages_topic_id=None, duration=None, length=None, thumbnail=None, disable_notification=None, protect_content=None, allow_paid_broadcast=None, message_effect_id=None, suggested_post_parameters=None, reply_parameters=None, reply_markup=None)[source]¶
https://core.telegram.org/bots/api#sendvideonote
As of v.4.0, Telegram clients support rounded square MPEG4 videos of up to 1 minute long. Use this method to send video messages. On success, the sent
Messageis returned.- Parameters:
chat_id (
intorstr) – Unique identifier for the target chat or username of the target channel (in the format@channelusername).video_note (
InputFileorstr) –Video note to send. Pass a file_id as String to send a video note that exists on the Telegram servers (recommended) or upload a new video using multipart/form-data. More information on Sending Files ». Sending video notes by a URL is currently unsupported.
business_connection_id (
str, optional) – Unique identifier of the business connection on behalf of which the message will be sent.message_thread_id (
int, optional) – Unique identifier for the target message thread (topic) of the forum; for forum supergroups only.direct_messages_topic_id (
int, optional) – Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat.duration (
int, optional) – Duration of sent video in seconds.length (
int, optional) – Video width and height, i.e. diameter of the video message.thumbnail (
InputFileorstr, optional) –Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail’s width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. More information on Sending Files ».
disable_notification (
bool, optional) –Sends the message silently. Users will receive a notification with no sound.
protect_content (
bool, optional) – Protects the contents of the sent message from forwarding and saving.allow_paid_broadcast (
bool, optional) –Pass
Trueto allow up to 1000 messages per second, ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot’s balance.message_effect_id (
str, optional) – Unique identifier of the message effect to be added to the message; for private chats only.suggested_post_parameters (
SuggestedPostParameters, optional) – A JSON-serialized object containing the parameters of the suggested post to send; for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post is automatically declined.reply_parameters (
ReplyParameters, optional) – Description of the message to reply to.reply_markup (
REPLY_MARKUP_TYPES, optional) –Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
- Return type:
- async send_voice(chat_id, voice, business_connection_id=None, message_thread_id=None, direct_messages_topic_id=None, caption=None, parse_mode=None, caption_entities=None, duration=None, disable_notification=None, protect_content=None, allow_paid_broadcast=None, message_effect_id=None, suggested_post_parameters=None, reply_parameters=None, reply_markup=None)[source]¶
https://core.telegram.org/bots/api#sendvoice
Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message. For this to work, your audio must be in an .OGG file encoded with OPUS, or in .MP3 format, or in .M4A (other formats may be sent as
AudioorDocument). On success, the sentMessageis returned. Bots can currently send voice messages of up to 50 MB in size, this limit may be changed in the future.- Parameters:
chat_id (
intorstr) – Unique identifier for the target chat or username of the target channel (in the format@channelusername).voice (
InputFileorstr) –Audio file to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. More information on Sending Files ».
business_connection_id (
str, optional) – Unique identifier of the business connection on behalf of which the message will be sent.message_thread_id (
int, optional) – Unique identifier for the target message thread (topic) of the forum; for forum supergroups only.direct_messages_topic_id (
int, optional) – Identifier of the direct messages topic to which the message will be sent; required if the message is sent to a direct messages chat.caption (
str, optional) – Voice message caption, 0-1024 characters after entities parsing.parse_mode (
str, optional) –Mode for parsing entities in the voice message caption. See formatting options for more details.
caption_entities (
listofMessageEntity, optional) – A JSON-serialized list of special entities that appear in the caption, which can be specified instead of parse_mode.duration (
int, optional) – Duration of the voice message in seconds.disable_notification (
bool, optional) –Sends the message silently. Users will receive a notification with no sound.
protect_content (
bool, optional) – Protects the contents of the sent message from forwarding and saving.allow_paid_broadcast (
bool, optional) –Pass
Trueto allow up to 1000 messages per second, ignoring broadcasting limits for a fee of 0.1 Telegram Stars per message. The relevant Stars will be withdrawn from the bot’s balance.message_effect_id (
str, optional) – Unique identifier of the message effect to be added to the message; for private chats only.suggested_post_parameters (
SuggestedPostParameters, optional) – A JSON-serialized object containing the parameters of the suggested post to send; for direct messages chats only. If the message is sent as a reply to another suggested post, then that suggested post is automatically declined.reply_parameters (
ReplyParameters, optional) – Description of the message to reply to.reply_markup (
REPLY_MARKUP_TYPES, optional) –Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
- Return type:
- async set_business_account_bio(business_connection_id, bio=None)[source]¶
https://core.telegram.org/bots/api#setbusinessaccountbio
Changes the bio of a managed business account. Requires the can_change_bio business bot right. Returns
Trueon success.- Parameters:
business_connection_id (
str) – Unique identifier of the business connection.bio (
str, optional) – The new value of the bio for the business account; 0-140 characters.
- Return type:
True
- async set_business_account_gift_settings(business_connection_id, show_gift_button, accepted_gift_types)[source]¶
https://core.telegram.org/bots/api#setbusinessaccountgiftsettings
Changes the privacy settings pertaining to incoming gifts in a managed business account. Requires the can_change_gift_settings business bot right. Returns
Trueon success.- Parameters:
business_connection_id (
str) – Unique identifier of the business connection.show_gift_button (
bool) – PassTrue, if a button for sending a gift to the user or by the business account must always be shown in the input field.accepted_gift_types (
AcceptedGiftTypes) – Types of gifts accepted by the business account.
- Return type:
True
- async set_business_account_name(business_connection_id, first_name, last_name=None)[source]¶
https://core.telegram.org/bots/api#setbusinessaccountname
Changes the first and last name of a managed business account. Requires the can_change_name business bot right. Returns
Trueon success.- Parameters:
business_connection_id (
str) – Unique identifier of the business connection.first_name (
str) – The new value of the first name for the business account; 1-64 characters.last_name (
str, optional) – The new value of the last name for the business account; 0-64 characters.
- Return type:
True
- async set_business_account_profile_photo(business_connection_id, photo, is_public=None)[source]¶
https://core.telegram.org/bots/api#setbusinessaccountprofilephoto
Changes the profile photo of a managed business account. Requires the can_edit_profile_photo business bot right. Returns
Trueon success.- Parameters:
business_connection_id (
str) – Unique identifier of the business connection.photo (
InputProfilePhoto) – The new profile photo to set.is_public (
bool, optional) – PassTrueto set the public photo, which will be visible even if the main photo is hidden by the business account’s privacy settings. An account can have only one public photo.
- Return type:
True
- async set_business_account_username(business_connection_id, username=None)[source]¶
https://core.telegram.org/bots/api#setbusinessaccountusername
Changes the username of a managed business account. Requires the can_change_username business bot right. Returns
Trueon success.- Parameters:
business_connection_id (
str) – Unique identifier of the business connection.username (
str, optional) – The new value of the username for the business account; 0-32 characters.
- Return type:
True
- async set_chat_administrator_custom_title(chat_id, user_id, custom_title)[source]¶
https://core.telegram.org/bots/api#setchatadministratorcustomtitle
Use this method to set a custom title for an administrator in a supergroup promoted by the bot. Returns
Trueon success.- Parameters:
chat_id (
intorstr) – Unique identifier for the target chat or username of the target supergroup (in the format@supergroupusername).user_id (
int) – Unique identifier of the target user.custom_title (
str) – New custom title for the administrator; 0-16 characters, emoji are not allowed.
- Return type:
True
- async set_chat_description(chat_id, description=None)[source]¶
https://core.telegram.org/bots/api#setchatdescription
Use this method to change the description of a group, a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns
Trueon success.- Parameters:
chat_id (
intorstr) – Unique identifier for the target chat or username of the target channel (in the format@channelusername).description (
str, optional) – New chat description, 0-255 characters.
- Return type:
True
https://core.telegram.org/bots/api#setchatmenubutton
Use this method to change the bot’s menu button in a private chat, or the default menu button. Returns
Trueon success.- Parameters:
chat_id (
int, optional) – Unique identifier for the target private chat. If not specified, default bot’s menu button will be changed.menu_button (
MenuButton, optional) – A JSON-serialized object for the bot’s new menu button. Defaults toMenuButtonDefault.
- Return type:
True
- async set_chat_permissions(chat_id, permissions, use_independent_chat_permissions=None)[source]¶
https://core.telegram.org/bots/api#setchatpermissions
Use this method to set default chat permissions for all members. The bot must be an administrator in the group or a supergroup for this to work and must have the can_restrict_members administrator rights. Returns
Trueon success.- Parameters:
chat_id (
intorstr) – Unique identifier for the target chat or username of the target supergroup (in the format@supergroupusername).permissions (
ChatPermissions) – A JSON-serialized object for new default chat permissions.use_independent_chat_permissions (
bool, optional) – PassTrueif chat permissions are set independently. Otherwise, the can_send_other_messages and can_add_web_page_previews permissions will imply the can_send_messages, can_send_audios, can_send_documents, can_send_photos, can_send_videos, can_send_video_notes, and can_send_voice_notes permissions; the can_send_polls permission will imply the can_send_messages permission.
- Return type:
True
- async set_chat_photo(chat_id, photo)[source]¶
https://core.telegram.org/bots/api#setchatphoto
Use this method to set a new profile photo for the chat. Photos can’t be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns
Trueon success.- Parameters:
chat_id (
intorstr) – Unique identifier for the target chat or username of the target channel (in the format@channelusername).photo (
InputFile) – New chat photo, uploaded using multipart/form-data.
- Return type:
True
- async set_chat_sticker_set(chat_id, sticker_set_name)[source]¶
https://core.telegram.org/bots/api#setchatstickerset
Use this method to set a new group sticker set for a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Use the field can_set_sticker_set optionally returned in
get_chat()requests to check if the bot can use this method. ReturnsTrueon success.- Parameters:
chat_id (
intorstr) – Unique identifier for the target chat or username of the target supergroup (in the format@supergroupusername).sticker_set_name (
str) – Name of the sticker set to be set as the group sticker set.
- Return type:
True
- async set_chat_title(chat_id, title)[source]¶
https://core.telegram.org/bots/api#setchattitle
Use this method to change the title of a chat. Titles can’t be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns
Trueon success.- Parameters:
chat_id (
intorstr) – Unique identifier for the target chat or username of the target channel (in the format@channelusername).title (
str) – New chat title, 1-128 characters.
- Return type:
True
- async set_custom_emoji_sticker_set_thumbnail(name, custom_emoji_id=None)[source]¶
https://core.telegram.org/bots/api#setcustomemojistickersetthumbnail
Use this method to set the thumbnail of a custom emoji sticker set. Returns
Trueon success.- Parameters:
name (
str) – Sticker set name.custom_emoji_id (
str, optional) – Custom emoji identifier of a sticker from the sticker set; pass an empty string to drop the thumbnail and use the first sticker as the thumbnail.
- Return type:
True
- async set_game_score(user_id, score, force=None, disable_edit_message=None, chat_id=None, message_id=None, inline_message_id=None)[source]¶
https://core.telegram.org/bots/api#setgamescore
Use this method to set the score of the specified user in a game message. On success, if the message is not an inline message, the
Messageis returned, otherwiseTrueis returned. Returns an error, if the new score is not greater than the user’s current score in the chat and force isFalse.- Parameters:
user_id (
int) – User identifier.score (
int) – New score, must be non-negative.force (
bool, optional) – PassTrueif the high score is allowed to decrease. This can be useful when fixing mistakes or banning cheaters.disable_edit_message (
bool, optional) – PassTrueif the game message should not be automatically edited to include the current scoreboard.chat_id (
int, optional) – Required if inline_message_id is not specified. Unique identifier for the target chat.message_id (
int, optional) – Required if inline_message_id is not specified. Identifier of the sent message.inline_message_id (
str, optional) – Required if chat_id and message_id are not specified. Identifier of the inline message.
- Return type:
MessageorTrue
- async set_message_reaction(chat_id, message_id, reaction=None, is_big=None)[source]¶
https://core.telegram.org/bots/api#setmessagereaction
Use this method to change the chosen reactions on a message. Service messages can’t be reacted to. Automatically forwarded messages from a channel to its discussion group have the same available reactions as messages in the channel. Returns
Trueon success.- Parameters:
chat_id (
intorstr) – Unique identifier for the target chat or username of the target channel (in the format@channelusername).message_id (
int) – Identifier of the target message. If the message belongs to a media group, the reaction is set to the first non-deleted message in the group instead.reaction (
listofReactionType, optional) – A JSON-serialized list of reaction types to set on the message. Currently, as non-premium users, bots can set up to one reaction per message. A custom emoji reaction can be used if it is either already present on the message or explicitly allowed by chat administrators.is_big (
bool, optional) – PassTrueto set the reaction with a big animation.
- Return type:
True
- async set_my_commands(commands, scope=None, language_code=None)[source]¶
https://core.telegram.org/bots/api#setmycommands
Use this method to change the list of the bot’s commands. See this manual for more details about bot commands. Returns
Trueon success.- Parameters:
commands (
listofBotCommand) – A JSON-serialized list of bot commands to be set as the list of the bot’s commands. At most 100 commands can be specified.scope (
BotCommandScope, optional) – A JSON-serialized object, describing scope of users for which the commands are relevant. Defaults toBotCommandScopeDefault.language_code (
str, optional) – A two-letter ISO 639-1 language code. If empty, commands will be applied to all users from the given scope, for whose language there are no dedicated commands.
- Return type:
True
- async set_my_default_administrator_rights(rights=None, for_channels=None)[source]¶
https://core.telegram.org/bots/api#setmydefaultadministratorrights
Use this method to change the default administrator rights requested by the bot when it’s added as an administrator to groups or channels. These rights will be suggested to users, but they are free to modify the list before adding the bot. Returns
Trueon success.- Parameters:
rights (
ChatAdministratorRights, optional) – A JSON-serialized object describing new default administrator rights. If not specified, the default administrator rights will be cleared.for_channels (
bool, optional) – PassTrueto change the default administrator rights of the bot in channels. Otherwise, the default administrator rights of the bot for groups and supergroups will be changed.
- Return type:
True
- async set_my_description(description=None, language_code=None)[source]¶
https://core.telegram.org/bots/api#setmydescription
Use this method to change the bot’s description, which is shown in the chat with the bot if the chat is empty. Returns
Trueon success.- Parameters:
description (
str, optional) – New bot description; 0-512 characters. Pass an empty string to remove the dedicated description for the given language.language_code (
str, optional) – A two-letter ISO 639-1 language code. If empty, the description will be applied to all users for whose language there is no dedicated description.
- Return type:
True
- async set_my_name(name=None, language_code=None)[source]¶
https://core.telegram.org/bots/api#setmyname
Use this method to change the bot’s name. Returns
Trueon success.- Parameters:
name (
str, optional) – New bot name; 0-64 characters. Pass an empty string to remove the dedicated name for the given language.language_code (
str, optional) – A two-letter ISO 639-1 language code. If empty, the name will be shown to all users for whose language there is no dedicated name.
- Return type:
True
- async set_my_short_description(short_description=None, language_code=None)[source]¶
https://core.telegram.org/bots/api#setmyshortdescription
Use this method to change the bot’s short description, which is shown on the bot’s profile page and is sent together with the link when users share the bot. Returns
Trueon success.- Parameters:
short_description (
str, optional) – New short description for the bot; 0-120 characters. Pass an empty string to remove the dedicated short description for the given language.language_code (
str, optional) – A two-letter ISO 639-1 language code. If empty, the short description will be applied to all users for whose language there is no dedicated short description.
- Return type:
True
- async set_passport_data_errors(user_id, errors)[source]¶
https://core.telegram.org/bots/api#setpassportdataerrors
Informs a user that some of the Telegram Passport elements they provided contains errors. The user will not be able to re-submit their Passport to you until the errors are fixed (the contents of the field for which you returned the error must change). Returns
Trueon success.Use this if the data submitted by the user doesn’t satisfy the standards your service requires for any reason. For example, if a birthday date seems invalid, a submitted document is blurry, a scan shows evidence of tampering, etc. Supply some details in the error message to make sure the user knows how to correct the issues.
- Parameters:
user_id (
int) – User identifier.errors (
listofPassportElementError) – A JSON-serialized array describing the errors.
- Return type:
True
- async set_sticker_emoji_list(sticker, emoji_list)[source]¶
https://core.telegram.org/bots/api#setstickeremojilist
Use this method to change the list of emoji assigned to a regular or custom emoji sticker. The sticker must belong to a sticker set created by the bot. Returns
Trueon success.- Parameters:
sticker (
str) – File identifier of the sticker.emoji_list (
listofstr) – A JSON-serialized list of 1-20 emoji associated with the sticker.
- Return type:
True
- async set_sticker_keywords(sticker, keywords=None)[source]¶
https://core.telegram.org/bots/api#setstickerkeywords
Use this method to change search keywords assigned to a regular or custom emoji sticker. The sticker must belong to a sticker set created by the bot. Returns
Trueon success.- Parameters:
sticker (
str) – File identifier of the sticker.keywords (
listofstr, optional) – A JSON-serialized list of 0-20 search keywords for the sticker with total length of up to 64 characters.
- Return type:
True
- async set_sticker_mask_position(sticker, mask_position=None)[source]¶
https://core.telegram.org/bots/api#setstickermaskposition
Use this method to change the
mask positionof a mask sticker. The sticker must belong to a sticker set that was created by the bot. ReturnsTrueon success.- Parameters:
sticker (
str) – File identifier of the sticker.mask_position (
MaskPosition, optional) – A JSON-serialized object with the position where the mask should be placed on faces. Omit the parameter to remove the mask position.
- Return type:
True
- async set_sticker_position_in_set(sticker, position)[source]¶
https://core.telegram.org/bots/api#setstickerpositioninset
Use this method to move a sticker in a set created by the bot to a specific position. Returns
Trueon success.- Parameters:
sticker (
str) – File identifier of the sticker.position (
int) – New sticker position in the set, zero-based.
- Return type:
True
- async set_sticker_set_thumbnail(name, user_id, format, thumbnail=None)[source]¶
https://core.telegram.org/bots/api#setstickersetthumbnail
Use this method to set the thumbnail of a regular or mask sticker set. The format of the thumbnail file must match the format of the stickers in the set. Returns
Trueon success.- Parameters:
name (
str) – Sticker set name.user_id (
int) – User identifier of the sticker set owner.format (
str) – Format of the thumbnail, must be one of “static” for a .WEBP or .PNG image, “animated” for a .TGS animation, or “video” for a WEBM video.thumbnail (
InputFileorstr, optional) –A .WEBP or .PNG image with the thumbnail, must be up to 128 kilobytes in size and have a width and height of exactly 100px, or a .TGS animation with a thumbnail up to 32 kilobytes in size (see https://core.telegram.org/stickers#animated-sticker-requirements for animated sticker technical requirements), or a WEBM video with the thumbnail up to 32 kilobytes in size; see https://core.telegram.org/stickers#video-sticker-requirements for video sticker technical requirements. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. More information on Sending Files ». Animated and video sticker set thumbnails can’t be uploaded via HTTP URL. If omitted, then the thumbnail is dropped and the first sticker is used as the thumbnail.
- Return type:
True
- async set_sticker_set_title(name, title)[source]¶
https://core.telegram.org/bots/api#setstickersettitle
Use this method to set the title of a created sticker set. Returns
Trueon success.- Parameters:
name (
str) – Sticker set name.title (
str) – Sticker set title, 1-64 characters.
- Return type:
True
- async set_user_emoji_status(user_id, emoji_status_custom_emoji_id=None, emoji_status_expiration_date=None)[source]¶
https://core.telegram.org/bots/api#setuseremojistatus
Changes the emoji status for a given user that previously allowed the bot to manage their emoji status via the Mini App method requestEmojiStatusAccess. Returns
Trueon success.- Parameters:
user_id (
int) – Unique identifier of the target user.emoji_status_custom_emoji_id (
str, optional) – Custom emoji identifier of the emoji status to set. Pass an empty string to remove the status.emoji_status_expiration_date (
int, optional) – Expiration date of the emoji status, if any.
- Return type:
True
- async stop_message_live_location(business_connection_id=None, chat_id=None, message_id=None, inline_message_id=None, reply_markup=None)[source]¶
https://core.telegram.org/bots/api#stopmessagelivelocation
Use this method to stop updating a live location message before live_period expires. On success, if the message is not an inline message, the edited
Messageis returned, otherwiseTrueis returned.- Parameters:
business_connection_id (
str, optional) – Unique identifier of the business connection on behalf of which the message to be edited was sent.chat_id (
intorstr, optional) – Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target channel (in the format@channelusername).message_id (
int, optional) – Required if inline_message_id is not specified. Identifier of the message with live location to stop.inline_message_id (
str, optional) – Required if chat_id and message_id are not specified. Identifier of the inline message.reply_markup (
InlineKeyboardMarkup, optional) –A JSON-serialized object for a new inline keyboard.
- Return type:
MessageorTrue
- async stop_poll(chat_id, message_id, business_connection_id=None, reply_markup=None)[source]¶
https://core.telegram.org/bots/api#stoppoll
Use this method to stop a poll which was sent by the bot. On success, the stopped
Pollis returned.- Parameters:
chat_id (
intorstr) – Unique identifier for the target chat or username of the target channel (in the format@channelusername).message_id (
int) – Identifier of the original message with the poll.business_connection_id (
str, optional) – Unique identifier of the business connection on behalf of which the message to be edited was sent.reply_markup (
InlineKeyboardMarkup, optional) –A JSON-serialized object for a new inline keyboard.
- Return type:
- async transfer_business_account_stars(business_connection_id, star_count)[source]¶
https://core.telegram.org/bots/api#transferbusinessaccountstars
Transfers Telegram Stars from the business account balance to the bot’s balance. Requires the can_transfer_stars business bot right. Returns
Trueon success.- Parameters:
business_connection_id (
str) – Unique identifier of the business connection.star_count (
int) – Number of Telegram Stars to transfer; 1-10000.
- Return type:
True
- async transfer_gift(business_connection_id, owned_gift_id, new_owner_chat_id, star_count=None)[source]¶
https://core.telegram.org/bots/api#transfergift
Transfers an owned unique gift to another user. Requires the can_transfer_and_upgrade_gifts business bot right. Requires can_transfer_stars business bot right if the transfer is paid. Returns
Trueon success.- Parameters:
business_connection_id (
str) – Unique identifier of the business connection.owned_gift_id (
str) – Unique identifier of the regular gift that should be transferred.new_owner_chat_id (
int) – Unique identifier of the chat which will own the gift. The chat must be active in the last 24 hours.star_count (
int, optional) – The amount of Telegram Stars that will be paid for the transfer from the business account balance. If positive, then the can_transfer_stars business bot right is required.
- Return type:
True
- async unban_chat_member(chat_id, user_id, only_if_banned=None)[source]¶
https://core.telegram.org/bots/api#unbanchatmember
Use this method to unban a previously banned user in a supergroup or channel. The user will not return to the group or channel automatically, but will be able to join via link, etc. The bot must be an administrator for this to work. By default, this method guarantees that after the call the user is not a member of the chat, but will be able to join it. So if the user is a member of the chat they will also be removed from the chat. If you don’t want this, use the parameter only_if_banned. Returns
Trueon success.- Parameters:
chat_id (
intorstr) – Unique identifier for the target group or username of the target supergroup or channel (in the format@channelusername).user_id (
int) – Unique identifier of the target user.only_if_banned (
bool, optional) – Do nothing if the user is not banned.
- Return type:
True
- async unban_chat_sender_chat(chat_id, sender_chat_id)[source]¶
https://core.telegram.org/bots/api#unbanchatsenderchat
Use this method to unban a previously banned channel chat in a supergroup or channel. The bot must be an administrator for this to work and must have the appropriate administrator rights. Returns
Trueon success.- Parameters:
chat_id (
intorstr) – Unique identifier for the target chat or username of the target channel (in the format@channelusername).sender_chat_id (
int) – Unique identifier of the target sender chat.
- Return type:
True
- async unhide_general_forum_topic(chat_id)[source]¶
https://core.telegram.org/bots/api#unhidegeneralforumtopic
Use this method to unhide the ‘General’ topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. Returns
Trueon success.- Parameters:
chat_id (
intorstr) – Unique identifier for the target chat or username of the target supergroup (in the format@supergroupusername).- Return type:
True
- async unpin_all_chat_messages(chat_id)[source]¶
https://core.telegram.org/bots/api#unpinallchatmessages
Use this method to clear the list of pinned messages in a chat. If the chat is not a private chat, the bot must be an administrator in the chat for this to work and must have the ‘can_pin_messages’ administrator right in a supergroup or ‘can_edit_messages’ administrator right in a channel. Returns
Trueon success.- Parameters:
chat_id (
intorstr) – Unique identifier for the target chat or username of the target channel (in the format@channelusername).- Return type:
True
- async unpin_all_forum_topic_messages(chat_id, message_thread_id)[source]¶
https://core.telegram.org/bots/api#unpinallforumtopicmessages
Use this method to clear the list of pinned messages in a forum topic. The bot must be an administrator in the chat for this to work and must have the can_pin_messages administrator right in the supergroup. Returns
Trueon success.- Parameters:
chat_id (
intorstr) – Unique identifier for the target chat or username of the target supergroup (in the format@supergroupusername).message_thread_id (
int) – Unique identifier for the target message thread of the forum topic.
- Return type:
True
- async unpin_all_general_forum_topic_messages(chat_id)[source]¶
https://core.telegram.org/bots/api#unpinallgeneralforumtopicmessages
Use this method to clear the list of pinned messages in a General forum topic. The bot must be an administrator in the chat for this to work and must have the can_pin_messages administrator right in the supergroup. Returns
Trueon success.- Parameters:
chat_id (
intorstr) – Unique identifier for the target chat or username of the target supergroup (in the format@supergroupusername).- Return type:
True
- async unpin_chat_message(chat_id, message_id=None, business_connection_id=None)[source]¶
https://core.telegram.org/bots/api#unpinchatmessage
Use this method to remove a message from the list of pinned messages in a chat. If the chat is not a private chat, the bot must be an administrator in the chat for this to work and must have the ‘can_pin_messages’ administrator right in a supergroup or ‘can_edit_messages’ administrator right in a channel. Returns
Trueon success.- Parameters:
chat_id (
intorstr) – Unique identifier for the target chat or username of the target channel (in the format@channelusername).message_id (
int, optional) – Identifier of a message to unpin. If not specified, the most recent pinned message (by sending date) will be unpinned.business_connection_id (
str, optional) – Unique identifier of the business connection on behalf of which the message will be unpinned.
- Return type:
True
- async upgrade_gift(business_connection_id, owned_gift_id, keep_original_details=None, star_count=None)[source]¶
https://core.telegram.org/bots/api#upgradegift
Upgrades a given regular gift to a unique gift. Requires the can_transfer_and_upgrade_gifts business bot right. Additionally requires the can_transfer_stars business bot right if the upgrade is paid. Returns
Trueon success.- Parameters:
business_connection_id (
str) – Unique identifier of the business connection.owned_gift_id (
str) – Unique identifier of the regular gift that should be upgraded to a unique one.keep_original_details (
bool, optional) – PassTrueto keep the original gift text, sender and receiver in the upgraded gift.star_count (
int, optional) – The amount of Telegram Stars that will be paid for the upgrade from the business account balance.If gift.prepaid_upgrade_star_count > 0, then pass 0, otherwise, the can_transfer_stars business bot right is required andgift.upgrade_star_countmust be passed.
- Return type:
True
- async upload_sticker_file(user_id, sticker, sticker_format)[source]¶
https://core.telegram.org/bots/api#uploadstickerfile
Use this method to upload a file with a sticker for later use in the
create_new_sticker_set()andadd_sticker_to_set()methods (the file can be used multiple times). Returns the uploadedFileon success.- Parameters:
user_id (
int) – User identifier of sticker file owner.sticker (
InputFile) –A file with the sticker in .WEBP, .PNG, .TGS, or .WEBM format. See https://core.telegram.org/stickers for technical requirements. More information on Sending Files ».
sticker_format (
str) – Format of the sticker, must be one of “static”, “animated”, “video”.
- Return type:
- async verify_chat(chat_id, custom_description=None)[source]¶
https://core.telegram.org/bots/api#verifychat
Verifies a chat on behalf of the organization which is represented by the bot. Returns
Trueon success.- Parameters:
chat_id (
intorstr) – Unique identifier for the target chat or username of the target channel (in the format@channelusername).custom_description (
str, optional) – Custom description for the verification; 0-70 characters. Must be empty if the organization isn’t allowed to provide a custom verification description.
- Return type:
True
- async verify_user(user_id, custom_description=None)[source]¶
https://core.telegram.org/bots/api#verifyuser
Verifies a user on behalf of the organization which is represented by the bot. Returns
Trueon success.- Parameters:
user_id (
intorstr) – Unique identifier for the target chat or username of the target channel (in the format@channelusername).custom_description (
str, optional) – Custom description for the verification; 0-70 characters. Must be empty if the organization isn’t allowed to provide a custom verification description.
- Return type:
True