-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Bot API 9.3 #2539
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
coder2020official
wants to merge
28
commits into
eternnoir:master
Choose a base branch
from
coder2020official:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+969
−94
Open
Bot API 9.3 #2539
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
09308bf
Added the field has_topics_enabled to the class User, which can be us…
coder2020official ec90c74
Added the method sendMessageDraft, allowing partial messages to be st…
coder2020official 345a9b1
Supported the fields message_thread_id and is_topic_message in the cl…
coder2020official 0a1ab2f
Supported the parameter message_thread_id in private chats with topic…
coder2020official 184a672
Added the field is_name_implicit to the classes ForumTopic and ForumT…
coder2020official 00032db
Added the methods getUserGifts and getChatGifts.
coder2020official d8a107a
Replaced the field last_resale_star_count with the fields last_resale…
coder2020official 3bfc160
Replaced the parameter exclude_limited with the parameters exclude_li…
coder2020official b53bb59
Added the value “gifted_upgrade” as a possible value of UniqueGiftInf…
coder2020official 5ca90c8
Added the field gift_upgrade_sent to the class Message.
coder2020official 2f062da
Added the field gift_id to the class UniqueGift.
coder2020official 98245c3
Added the field is_from_blockchain to the class UniqueGift.
coder2020official 1702b7c
Added the parameter exclude_from_blockchain in the method getBusiness…
coder2020official e87e7cc
Added the fields personal_total_count and personal_remaining_count to…
coder2020official 19cea9d
Added the field is_premium to the classes Gift and UniqueGift.
coder2020official d1f2862
Fix
coder2020official 4ea5ddc
Added the field is_upgrade_separate to the classes GiftInfo and Owned…
coder2020official ba12d90
Added the class UniqueGiftColors that describes the color scheme for …
coder2020official 951f24c
Added the field has_colors to the class Gift.
coder2020official b6df64c
Added the field colors to the class UniqueGift.
coder2020official a845b76
Added the class GiftBackground and the field background to the class …
coder2020official 8ad7d7e
Merge branch 'master' into master
coder2020official 8d61448
Added the field unique_gift_variant_count to the class Gift. Added th…
coder2020official 913ff95
Added the method repostStory, allowing bots to repost stories across …
coder2020official 9688d33
Added the class UserRating and the field rating to the class ChatFull…
coder2020official 40d9c3b
Added the field paid_message_star_count to the class ChatFullInfo.
coder2020official 6e6190b
completed_by_chat & unique_gift_colors
coder2020official 9c057fb
Added the parameter message_effect_id to the methods forwardMessage a…
coder2020official File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1827,7 +1827,8 @@ def forward_message( | |
| message_thread_id: Optional[int]=None, | ||
| video_start_timestamp: Optional[int]=None, | ||
| direct_messages_topic_id: Optional[int]=None, | ||
| suggested_post_parameters: Optional[types.SuggestedPostParameters]=None) -> types.Message: | ||
| suggested_post_parameters: Optional[types.SuggestedPostParameters]=None, | ||
| message_effect_id: Optional[str]=None) -> types.Message: | ||
| """ | ||
| Use this method to forward messages of any kind. | ||
|
|
||
|
|
@@ -1866,6 +1867,9 @@ def forward_message( | |
| is automatically declined. | ||
| :type suggested_post_parameters: :class:`telebot.types.SuggestedPostParameters` | ||
|
|
||
| :param message_effect_id: Unique identifier of the message effect to be added to the message; only available when forwarding to private chats | ||
| :type message_effect_id: :obj:`str` | ||
|
|
||
| :return: On success, the sent Message is returned. | ||
| :rtype: :class:`telebot.types.Message` | ||
| """ | ||
|
|
@@ -1877,7 +1881,7 @@ def forward_message( | |
| self.token, chat_id, from_chat_id, message_id, disable_notification=disable_notification, | ||
| timeout=timeout, protect_content=protect_content, message_thread_id=message_thread_id, | ||
| video_start_timestamp=video_start_timestamp, direct_messages_topic_id=direct_messages_topic_id, | ||
| suggested_post_parameters=suggested_post_parameters | ||
| suggested_post_parameters=suggested_post_parameters, message_effect_id=message_effect_id | ||
| ) | ||
| ) | ||
|
|
||
|
|
@@ -1901,7 +1905,8 @@ def copy_message( | |
| allow_paid_broadcast: Optional[bool]=None, | ||
| video_start_timestamp: Optional[int]=None, | ||
| direct_messages_topic_id: Optional[int]=None, | ||
| suggested_post_parameters: Optional[types.SuggestedPostParameters]=None) -> types.MessageID: | ||
| suggested_post_parameters: Optional[types.SuggestedPostParameters]=None, | ||
| message_effect_id: Optional[str]=None) -> types.MessageID: | ||
| """ | ||
| 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. | ||
|
|
@@ -1973,6 +1978,9 @@ def copy_message( | |
| is automatically declined. | ||
| :type suggested_post_parameters: :class:`telebot.types.SuggestedPostParameters` | ||
|
|
||
| :param message_effect_id: Unique identifier of the message effect to be added to the message; only available when copying to private chats | ||
| :type message_effect_id: :obj:`str` | ||
|
|
||
| :return: On success, the MessageId of the sent message is returned. | ||
| :rtype: :class:`telebot.types.MessageID` | ||
| """ | ||
|
|
@@ -2006,7 +2014,7 @@ def copy_message( | |
| message_thread_id=message_thread_id, reply_parameters=reply_parameters, | ||
| show_caption_above_media=show_caption_above_media, allow_paid_broadcast=allow_paid_broadcast, | ||
| video_start_timestamp=video_start_timestamp, direct_messages_topic_id=direct_messages_topic_id, | ||
| suggested_post_parameters=suggested_post_parameters | ||
| suggested_post_parameters=suggested_post_parameters, message_effect_id=message_effect_id | ||
| )) | ||
|
|
||
|
|
||
|
|
@@ -4195,6 +4203,45 @@ def send_contact( | |
| business_connection_id=business_connection_id, message_effect_id=message_effect_id, allow_paid_broadcast=allow_paid_broadcast, | ||
| direct_messages_topic_id=direct_messages_topic_id, suggested_post_parameters=suggested_post_parameters) | ||
| ) | ||
|
|
||
|
|
||
| def send_message_draft( | ||
| self, chat_id: int, | ||
| draft_id: int, | ||
| text: str, | ||
| message_thread_id: Optional[int]=None, | ||
| parse_mode: Optional[str]=None, | ||
| entities: Optional[List[types.MessageEntity]]=None): | ||
| """ | ||
| Use this method to stream a partial message to a user while the message is being generated; | ||
| supported only for bots with forum topic mode enabled. Returns True on success. | ||
|
|
||
| Telegram documentation: https://core.telegram.org/bots/api#sendmessagedraft | ||
|
|
||
| :param chat_id: Unique identifier for the target private chat | ||
| :type chat_id: :obj:`int` | ||
|
|
||
| :param message_thread_id: Unique identifier for the target message thread | ||
| :type message_thread_id: :obj:`int` | ||
|
|
||
| :param draft_id: Unique identifier of the message draft; must be non-zero. Changes of drafts with the same identifier are animated | ||
| :type draft_id: :obj:`int` | ||
|
|
||
| :param text: Text of the message to be sent, 1-4096 characters after entities parsing | ||
| :type text: :obj:`str` | ||
|
|
||
| :param parse_mode: Mode for parsing entities in the message text. See formatting options for more details. | ||
| :type parse_mode: :obj:`str` | ||
|
|
||
| :param entities: A JSON-serialized list of special entities that appear in message text, which can be specified instead of parse_mode | ||
| :type entities: :obj:`list` of :class:`telebot.types.MessageEntity | ||
|
|
||
| :return: Returns True on success. | ||
| :rtype: :obj:`bool` | ||
| """ | ||
| return apihelper.send_message_draft( | ||
| self.token, chat_id, draft_id, text, parse_mode=parse_mode, entities=entities, message_thread_id=message_thread_id) | ||
|
|
||
|
|
||
|
|
||
| def send_chat_action( | ||
|
|
@@ -4222,7 +4269,7 @@ def send_chat_action( | |
| :param timeout: Timeout in seconds for the request. | ||
| :type timeout: :obj:`int` | ||
|
|
||
| :param message_thread_id: The thread identifier of a message from which the reply will be sent(supergroups only) | ||
| :param message_thread_id: The thread identifier of a message from which the reply will be sent(for supergroups and private chats) | ||
| :type message_thread_id: :obj:`int` | ||
|
|
||
| :param business_connection_id: Identifier of a business connection | ||
|
|
@@ -6909,7 +6956,10 @@ def get_business_account_gifts( | |
| exclude_unique: Optional[bool]=None, | ||
| sort_by_price: Optional[bool]=None, | ||
| offset: Optional[str]=None, | ||
| limit: Optional[int]=None) -> types.OwnedGifts: | ||
| limit: Optional[int]=None, | ||
| exclude_limited_upgradable: Optional[bool]=None, | ||
| exclude_limited_non_upgradable: Optional[bool]=None, | ||
| exclude_from_blockchain: Optional[bool]=None,) -> types.OwnedGifts: | ||
| """ | ||
| Returns the gifts received and owned by a managed business account. Requires the can_view_gifts_and_stars business bot right. Returns OwnedGifts on success. | ||
|
|
||
|
|
@@ -6933,6 +6983,9 @@ def get_business_account_gifts( | |
| :param exclude_unique: Pass True to exclude unique gifts | ||
| :type exclude_unique: :obj:`bool` | ||
|
|
||
| :param exclude_from_blockchain: Pass True to exclude gifts that were assigned from the TON blockchain and can't be resold or transferred in Telegram | ||
| :type exclude_from_blockchain: :obj:`bool` | ||
|
|
||
| :param sort_by_price: Pass True to sort results by gift price instead of send date. Sorting is applied before pagination. | ||
| :type sort_by_price: :obj:`bool` | ||
|
|
||
|
|
@@ -6942,23 +6995,165 @@ def get_business_account_gifts( | |
| :param limit: The maximum number of gifts to be returned; 1-100. Defaults to 100 | ||
| :type limit: :obj:`int` | ||
|
|
||
| :param exclude_limited_upgradable: Pass True to exclude gifts that can be purchased a limited number of times and can be upgraded to unique | ||
| :type exclude_limited_upgradable: :obj:`bool` | ||
|
|
||
| :param exclude_limited_non_upgradable: Pass True to exclude gifts that can be purchased a limited number of times and can't be upgraded to unique | ||
| :type exclude_limited_non_upgradable: :obj:`bool` | ||
|
|
||
| :return: On success, a OwnedGifts object is returned. | ||
| :rtype: :class:`telebot.types.OwnedGifts` | ||
| """ | ||
| if exclude_limited is not None and exclude_limited_upgradable is None and exclude_limited_non_upgradable is None: | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| exclude_limited_upgradable = exclude_limited | ||
| exclude_limited_non_upgradable = exclude_limited | ||
|
|
||
|
|
||
| return types.OwnedGifts.de_json( | ||
| apihelper.get_business_account_gifts( | ||
| self.token, business_connection_id, | ||
| exclude_unsaved=exclude_unsaved, | ||
| exclude_saved=exclude_saved, | ||
| exclude_unlimited=exclude_unlimited, | ||
| exclude_limited=exclude_limited, | ||
| exclude_unique=exclude_unique, | ||
| sort_by_price=sort_by_price, | ||
| offset=offset, | ||
| limit=limit, | ||
| exclude_limited_upgradable=exclude_limited_upgradable, | ||
| exclude_limited_non_upgradable=exclude_limited_non_upgradable, | ||
| exclude_from_blockchain=exclude_from_blockchain | ||
| ) | ||
| ) | ||
|
|
||
| def get_user_gifts( | ||
| self, user_id: int, | ||
| exclude_unlimited: Optional[bool]=None, | ||
| exclude_limited_upgradable: Optional[bool]=None, | ||
| exclude_limited_non_upgradable: Optional[bool]=None, | ||
| exclude_from_blockchain: Optional[bool]=None, | ||
| exclude_unique: Optional[bool]=None, | ||
| sort_by_price: Optional[bool]=None, | ||
| offset: Optional[str]=None, | ||
| limit: Optional[int]=None) -> types.OwnedGifts: | ||
| """ | ||
| Returns the gifts owned and hosted by a user. Returns OwnedGifts on success. | ||
|
|
||
| Telegram documentation: https://core.telegram.org/bots/api#getusergifts | ||
|
|
||
| :param user_id: Unique identifier of the user | ||
| :type user_id: :obj:`int` | ||
|
|
||
| :param exclude_unlimited: Pass True to exclude gifts that can be purchased an unlimited number of times | ||
| :type exclude_unlimited: :obj:`bool` | ||
|
|
||
| :param exclude_limited_upgradable: Pass True to exclude gifts that can be purchased a limited number of times and can be upgraded to unique | ||
| :type exclude_limited_upgradable: :obj:`bool` | ||
|
|
||
| :param exclude_limited_non_upgradable: Pass True to exclude gifts that can be purchased a limited number of times and can't be upgraded to unique | ||
| :type exclude_limited_non_upgradable: :obj:`bool` | ||
|
|
||
| :param exclude_from_blockchain: Pass True to exclude gifts that were assigned from the TON blockchain and can't be resold or transferred in Telegram | ||
| :type exclude_from_blockchain: :obj:`bool` | ||
|
|
||
| :param exclude_unique: Pass True to exclude unique gifts | ||
| :type exclude_unique: :obj:`bool` | ||
|
|
||
| :param sort_by_price: Pass True to sort results by gift price instead of send date. Sorting is applied before pagination. | ||
| :type sort_by_price: :obj:`bool` | ||
|
|
||
| :param offset: Offset of the first entry to return as received from the previous request; use an empty string to get the first chunk of results | ||
| :type offset: :obj:`str` | ||
|
|
||
| :param limit: The maximum number of gifts to be returned; 1-100. Defaults to 100 | ||
| :type limit: :obj:`int` | ||
|
|
||
| :return: On success, a OwnedGifts object is returned. | ||
| :rtype: :class:`telebot.types.OwnedGifts` | ||
| """ | ||
| return types.OwnedGifts.de_json( | ||
| apihelper.get_user_gifts( | ||
| self.token, user_id, | ||
| exclude_unlimited=exclude_unlimited, | ||
| exclude_limited_upgradable=exclude_limited_upgradable, | ||
| exclude_limited_non_upgradable=exclude_limited_non_upgradable, | ||
| exclude_from_blockchain=exclude_from_blockchain, | ||
| exclude_unique=exclude_unique, | ||
| sort_by_price=sort_by_price, | ||
| offset=offset, | ||
| limit=limit | ||
| ) | ||
| ) | ||
|
|
||
| def get_chat_gifts( | ||
| self, chat_id: Union[int, str], | ||
| exclude_unsaved: Optional[bool]=None, | ||
| exclude_saved: Optional[bool]=None, | ||
| exclude_unlimited: Optional[bool]=None, | ||
| exclude_limited_upgradable: Optional[bool]=None, | ||
| exclude_limited_non_upgradable: Optional[bool]=None, | ||
| exclude_from_blockchain: Optional[bool]=None, | ||
| exclude_unique: Optional[bool]=None, | ||
| sort_by_price: Optional[bool]=None, | ||
| offset: Optional[str]=None, | ||
| limit: Optional[int]=None) -> types.OwnedGifts: | ||
| """ | ||
| Returns the gifts owned by a chat. Returns OwnedGifts on success. | ||
|
|
||
| Telegram documentation: https://core.telegram.org/bots/api#getchatgifts | ||
|
|
||
| :param chat_id: Unique identifier for the target chat or username of the target channel (in the format @channelusername) | ||
| :type chat_id: :obj:`int` | :obj:`str` | ||
|
|
||
| :param exclude_unsaved: Pass True to exclude gifts that aren't saved to the chat's profile page. Always True, unless the bot has the can_post_messages administrator right in the channel. | ||
| :type exclude_unsaved: :obj:`bool` | ||
|
|
||
| :param exclude_saved: Pass True to exclude gifts that are saved to the chat's profile page. Always False, unless the bot has the can_post_messages administrator right in the channel. | ||
| :type exclude_saved: :obj:`bool` | ||
|
|
||
| :param exclude_unlimited: Pass True to exclude gifts that can be purchased an unlimited number of times | ||
| :type exclude_unlimited: :obj:`bool` | ||
|
|
||
| :param exclude_limited_upgradable: Pass True to exclude gifts that can be purchased a limited number of times and can be upgraded to unique | ||
| :type exclude_limited_upgradable: :obj:`bool` | ||
|
|
||
| :param exclude_limited_non_upgradable: Pass True to exclude gifts that can be purchased a limited number of times and can't be upgraded to unique | ||
| :type exclude_limited_non_upgradable: :obj:`bool` | ||
|
|
||
| :param exclude_from_blockchain: Pass True to exclude gifts that were assigned from the TON blockchain and can't be resold or transferred in Telegram | ||
| :type exclude_from_blockchain: :obj:`bool` | ||
|
|
||
| :param exclude_unique: Pass True to exclude unique gifts | ||
| :type exclude_unique: :obj:`bool` | ||
|
|
||
| :param sort_by_price: Pass True to sort results by gift price instead of send date. Sorting is applied before pagination. | ||
| :type sort_by_price: :obj:`bool` | ||
|
|
||
| :param offset: Offset of the first entry to return as received from the previous request; use an empty string to get the first chunk of results | ||
| :type offset: :obj:`str` | ||
|
|
||
| :param limit: The maximum number of gifts to be returned; 1-100. Defaults to 100 | ||
| :type limit: :obj:`int` | ||
|
|
||
| :return: On success, a OwnedGifts object is returned. | ||
| :rtype: :class:`telebot.types.OwnedGifts` | ||
| """ | ||
| return types.OwnedGifts.de_json( | ||
| apihelper.get_chat_gifts( | ||
| self.token, chat_id, | ||
| exclude_unsaved=exclude_unsaved, | ||
| exclude_saved=exclude_saved, | ||
| exclude_unlimited=exclude_unlimited, | ||
| exclude_limited_upgradable=exclude_limited_upgradable, | ||
| exclude_limited_non_upgradable=exclude_limited_non_upgradable, | ||
| exclude_from_blockchain=exclude_from_blockchain, | ||
| exclude_unique=exclude_unique, | ||
| sort_by_price=sort_by_price, | ||
| offset=offset, | ||
| limit=limit | ||
| ) | ||
| ) | ||
|
|
||
|
|
||
| def convert_gift_to_stars(self, business_connection_id: str, owned_gift_id: str) -> bool: | ||
| """ | ||
| Converts a given regular gift to Telegram Stars. Requires the can_convert_gifts_to_stars business bot right. Returns True on success. | ||
|
|
@@ -7096,6 +7291,50 @@ def post_story( | |
| ) | ||
| ) | ||
|
|
||
| def repost_story( | ||
| self, business_connection_id: str, | ||
| from_chat_id: int, from_story_id: int, | ||
| active_period: int, | ||
| post_to_chat_page: Optional[bool]=None, | ||
| protect_content: Optional[bool]=None) -> types.Story: | ||
| """ | ||
| Reposts a story on behalf of a business account from another business account. Both business accounts | ||
| must be managed by the same bot, and the story on the source account must have been posted (or reposted) | ||
| by the bot. Requires the can_manage_stories business bot right for both business accounts. Returns Story on success. | ||
|
|
||
| Telegram documentation: https://core.telegram.org/bots/api#repoststory | ||
|
|
||
| :param business_connection_id: Unique identifier of the business connection | ||
| :type business_connection_id: :obj:`str` | ||
|
|
||
| :param from_chat_id: Unique identifier of the chat which posted the story that should be reposted | ||
| :type from_chat_id: :obj:`int` | ||
|
|
||
| :param from_story_id: Unique identifier of the story that should be reposted | ||
| :type from_story_id: :obj:`int` | ||
|
|
||
| :param active_period: Period after which the story is moved to the archive, in seconds; must be one of 6 * 3600, 12 * 3600, 86400, or 2 * 86400 | ||
| :type active_period: :obj:`int` | ||
|
|
||
| :param post_to_chat_page: Pass True to keep the story accessible after it expires | ||
| :type post_to_chat_page: :obj:`bool` | ||
|
|
||
| :param protect_content: Pass True if the content of the story must be protected from forwarding and screenshotting | ||
| :type protect_content: :obj:`bool` | ||
|
|
||
| :return: On success, a Story object is returned. | ||
| :rtype: :class:`telebot.types.Story` | ||
| """ | ||
| return types.Story.de_json( | ||
| apihelper.repost_story( | ||
| self.token, business_connection_id, | ||
| from_chat_id, from_story_id, | ||
| active_period, | ||
| post_to_chat_page=post_to_chat_page, | ||
| protect_content=protect_content | ||
| ) | ||
| ) | ||
|
|
||
| def edit_story( | ||
| self, business_connection_id: str, story_id: int, | ||
| content: types.InputStoryContent, | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mark "exclude_limited" as deprecated in comment.