- Notifications
You must be signed in to change notification settings - Fork5.7k
V13 API 6.2 implementation#3203
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
7 commits Select commitHold shift + click to select a range
203f86e
API 6.2 implementation
Poolitzer6ad6a5d
Fix: ignore backwards function arg
Poolitzer2a03096
Fix: make deepsource happy
Poolitzer5ca8941
Fix: sphinx broke
Poolitzer9dd7d2a
Fix: maybe now its official?
Poolitzer9ecd63a
Fix: apply review
Poolitzerfe73773
Fix: improve note to list
PoolitzerFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
4 changes: 2 additions & 2 deletionsREADME.rst
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
4 changes: 2 additions & 2 deletionsREADME_RAW.rst
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
2 changes: 2 additions & 0 deletionsdocs/requirements-docs.txt
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
51 changes: 48 additions & 3 deletionstelegram/bot.py
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 |
---|---|---|
@@ -2429,8 +2429,8 @@ def get_file( | ||
if result.get('file_path') and not is_local_file( # type: ignore[union-attr] | ||
result['file_path'] # type: ignore[index] | ||
): | ||
result['file_path'] = ( # type: ignore[index] | ||
f"{self.base_file_url}/" f"{result['file_path']}" # type: ignore[index] | ||
) | ||
return File.de_json(result, self) # type: ignore[return-value, arg-type] | ||
@@ -4813,6 +4813,37 @@ def get_sticker_set( | ||
return StickerSet.de_json(result, self) # type: ignore[return-value, arg-type] | ||
@log | ||
def get_custom_emoji_stickers( | ||
self, | ||
custom_emoji_ids: List[str], | ||
*, | ||
timeout: ODVInput[float] = DEFAULT_NONE, | ||
api_kwargs: JSONDict = None, | ||
) -> List[Sticker]: | ||
""" | ||
Use this method to get information about emoji stickers by their identifiers. | ||
Bibo-Joshi marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
.. versionadded:: 13.14 | ||
Args: | ||
custom_emoji_ids (List[:obj:`str`]): List of custom emoji identifiers. | ||
At most 200 custom emoji identifiers can be specified. | ||
Keyword Args: | ||
timeout (:obj:`int` | :obj:`float`, optional): If this value is specified, use it as | ||
the read timeout from the server (instead of the one specified during | ||
creation of the connection pool). | ||
api_kwargs (:obj:`dict`, optional): Arbitrary keyword arguments to be passed to the | ||
Telegram API. | ||
Returns: | ||
List[:class:`telegram.Sticker`] | ||
Raises: | ||
:class:`telegram.error.TelegramError` | ||
""" | ||
data: JSONDict = {"custom_emoji_ids": custom_emoji_ids} | ||
result = self._post("getCustomEmojiStickers", data, timeout=timeout, api_kwargs=api_kwargs) | ||
return Sticker.de_list(result, self) # type: ignore[return-value, arg-type] | ||
@log | ||
def upload_sticker_file( | ||
self, | ||
@@ -4871,6 +4902,7 @@ def create_new_sticker_set( | ||
tgs_sticker: FileInput = None, | ||
api_kwargs: JSONDict = None, | ||
webm_sticker: FileInput = None, | ||
sticker_type: str = None, | ||
) -> bool: | ||
""" | ||
Use this method to create new sticker set owned by a user. | ||
@@ -4887,6 +4919,10 @@ def create_new_sticker_set( | ||
The png_sticker and tgs_sticker argument can be either a file_id, an URL or a file from | ||
disk ``open(filename, 'rb')`` | ||
.. versionchanged:: 13.14 | ||
The parameter ``contains_masks`` has been depreciated as of Bot API 6.2. | ||
Use ``sticker_type`` instead. | ||
Args: | ||
user_id (:obj:`int`): User identifier of created sticker set owner. | ||
name (:obj:`str`): Short name of sticker set, to be used in t.me/addstickers/ URLs | ||
@@ -4924,6 +4960,12 @@ def create_new_sticker_set( | ||
should be created. | ||
mask_position (:class:`telegram.MaskPosition`, optional): Position where the mask | ||
should be placed on faces. | ||
sticker_type (:obj:`str`, optional): Type of stickers in the set, pass | ||
:attr:`telegram.Sticker.REGULAR` or :attr:`telegram.Sticker.MASK`. Custom emoji | ||
sticker sets can't be created via the Bot API at the moment. By default, a | ||
regular sticker set is created. | ||
.. versionadded:: 13.14 | ||
timeout (:obj:`int` | :obj:`float`, optional): If this value is specified, use it as | ||
the read timeout from the server (instead of the one specified during | ||
creation of the connection pool). | ||
@@ -4951,7 +4993,8 @@ def create_new_sticker_set( | ||
# We need to_json() instead of to_dict() here, because we're sending a media | ||
# message here, which isn't json dumped by utils.request | ||
data['mask_position'] = mask_position.to_json() | ||
if sticker_type is not None: | ||
data['sticker_type'] = sticker_type | ||
result = self._post('createNewStickerSet', data, timeout=timeout, api_kwargs=api_kwargs) | ||
return result # type: ignore[return-value] | ||
@@ -6206,6 +6249,8 @@ def __hash__(self) -> int: | ||
"""Alias for :meth:`unpin_all_chat_messages`""" | ||
getStickerSet = get_sticker_set | ||
"""Alias for :meth:`get_sticker_set`""" | ||
getCustomEmojiStickers = get_custom_emoji_stickers | ||
"""Alias for :meth:`get_custom_emoji_stickers`""" | ||
uploadStickerFile = upload_sticker_file | ||
"""Alias for :meth:`upload_sticker_file`""" | ||
createNewStickerSet = create_new_sticker_set | ||
13 changes: 13 additions & 0 deletionstelegram/chat.py
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 |
---|---|---|
@@ -126,6 +126,11 @@ class Chat(TelegramObject): | ||
:meth:`telegram.Bot.get_chat`. | ||
.. versionadded:: 13.13 | ||
has_restricted_voice_and_video_messages (:obj:`bool`, optional): :obj:`True`, if the | ||
privacy settings of the other party restrict sending voice and video note messages | ||
in the private chat. Returned only in :meth:`telegram.Bot.get_chat`. | ||
.. versionadded:: 13.14 | ||
Bibo-Joshi marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
**kwargs (:obj:`dict`): Arbitrary keyword arguments. | ||
Attributes: | ||
@@ -180,6 +185,11 @@ class Chat(TelegramObject): | ||
:meth:`telegram.Bot.get_chat`. | ||
.. versionadded:: 13.13 | ||
has_restricted_voice_and_video_messages (:obj:`bool`): Optional. :obj:`True`, if the | ||
privacy settings of the other party restrict sending voice and video note messages | ||
in the private chat. Returned only in :meth:`telegram.Bot.get_chat`. | ||
.. versionadded:: 13.14 | ||
""" | ||
__slots__ = ( | ||
@@ -207,6 +217,7 @@ class Chat(TelegramObject): | ||
'has_private_forwards', | ||
'join_to_send_messages', | ||
'join_by_request', | ||
'has_restricted_voice_and_video_messages', | ||
'_id_attrs', | ||
) | ||
@@ -249,6 +260,7 @@ def __init__( | ||
has_protected_content: bool = None, | ||
join_to_send_messages: bool = None, | ||
join_by_request: bool = None, | ||
has_restricted_voice_and_video_messages: bool = None, | ||
**_kwargs: Any, | ||
): | ||
# Required | ||
@@ -279,6 +291,7 @@ def __init__( | ||
self.location = location | ||
self.join_to_send_messages = join_to_send_messages | ||
self.join_by_request = join_by_request | ||
self.has_restricted_voice_and_video_messages = has_restricted_voice_and_video_messages | ||
self.bot = bot | ||
self._id_attrs = (self.id,) | ||
26 changes: 24 additions & 2 deletionstelegram/constants.py
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
2 changes: 1 addition & 1 deletiontelegram/error.py
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
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
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.