Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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
Bibo-Joshi merged 7 commits intov13.xfromv13-api6.2
Sep 4, 2022
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletionsREADME.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -20,7 +20,7 @@ We have a vibrant community of developers helping each other in our `Telegram gr
:target: https://pypi.org/project/python-telegram-bot/
:alt: Supported Python versions

.. image:: https://img.shields.io/badge/Bot%20API-6.1-blue?logo=telegram
.. image:: https://img.shields.io/badge/Bot%20API-6.2-blue?logo=telegram
:target: https://core.telegram.org/bots/api-changelog
:alt: Supported Bot API versions

Expand DownExpand Up@@ -112,7 +112,7 @@ Installing both ``python-telegram-bot`` and ``python-telegram-bot-raw`` in conju
Telegram API support
====================

All types and methods of the Telegram Bot API **6.1** are supported.
All types and methods of the Telegram Bot API **6.2** are supported.

==========
Installing
Expand Down
4 changes: 2 additions & 2 deletionsREADME_RAW.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -20,7 +20,7 @@ We have a vibrant community of developers helping each other in our `Telegram gr
:target: https://pypi.org/project/python-telegram-bot-raw/
:alt: Supported Python versions

.. image:: https://img.shields.io/badge/Bot%20API-6.1-blue?logo=telegram
.. image:: https://img.shields.io/badge/Bot%20API-6.2-blue?logo=telegram
:target: https://core.telegram.org/bots/api-changelog
:alt: Supported Bot API versions

Expand DownExpand Up@@ -105,7 +105,7 @@ Installing both ``python-telegram-bot`` and ``python-telegram-bot-raw`` in conju
Telegram API support
====================

All types and methods of the Telegram Bot API **6.1** are supported.
All types and methods of the Telegram Bot API **6.2** are supported.

==========
Installing
Expand Down
2 changes: 2 additions & 0 deletionsdocs/requirements-docs.txt
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
sphinx==3.5.4
# sphinx breaks because it relies on an removed param from jinja2, so pinning to old version
Jinja2<3.1
sphinx-pypi-upload
# When bumping this, make sure to rebuild the dark-mode CSS
# More instructions at source/_static/dark.css
Expand Down
51 changes: 48 additions & 3 deletionstelegram/bot.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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'] ='{}/{}'.format( # type: ignore[index]
self.base_file_url,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]
Expand DownExpand Up@@ -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.

.. 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,
Expand DownExpand Up@@ -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.
Expand All@@ -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
Expand DownExpand Up@@ -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).
Expand DownExpand Up@@ -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]
Expand DownExpand Up@@ -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
Expand Down
13 changes: 13 additions & 0 deletionstelegram/chat.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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
**kwargs (:obj:`dict`): Arbitrary keyword arguments.

Attributes:
Expand DownExpand Up@@ -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__ = (
Expand DownExpand Up@@ -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',
)

Expand DownExpand Up@@ -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
Expand DownExpand Up@@ -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,)
Expand Down
26 changes: 24 additions & 2 deletionstelegram/constants.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -21,7 +21,7 @@
`Telegram Bots API <https://core.telegram.org/bots/api>`_.

Attributes:
BOT_API_VERSION (:obj:`str`): `6.1`. Telegram Bot API version supported by this
BOT_API_VERSION (:obj:`str`): `6.2`. Telegram Bot API version supported by this
version of `python-telegram-bot`. Also available as ``telegram.bot_api_version``.

.. versionadded:: 13.4
Expand DownExpand Up@@ -144,6 +144,9 @@
MESSAGEENTITY_SPOILER (:obj:`str`): ``'spoiler'``

.. versionadded:: 13.10
MESSAGEENTITY_CUSTOM_EMOJI (:obj:`str`): ``'custom_emoji'``

.. versionadded:: 13.14
MESSAGEENTITY_ALL_TYPES (List[:obj:`str`]): List of all the types of message entity.

:class:`telegram.ParseMode`:
Expand All@@ -160,6 +163,19 @@
POLL_QUIZ (:obj:`str`): ``'quiz'``
MAX_POLL_QUESTION_LENGTH (:obj:`int`): 300
MAX_POLL_OPTION_LENGTH (:obj:`int`): 100
:class:`telegram.Sticker`:

Attributes:

STICKER_REGULAR (:obj:`str`)= ``'regular'``

.. versionadded:: 13.14
STICKER_MASK (:obj:`str`) = ``'mask'``

.. versionadded:: 13.14
STICKER_CUSTOM_EMOJI (:obj:`str`) = ``'custom_emoji'``

.. versionadded:: 13.14

:class:`telegram.MaskPosition`:

Expand DownExpand Up@@ -247,7 +263,7 @@
"""
from typing import List

BOT_API_VERSION: str = '6.1'
BOT_API_VERSION: str = '6.2'
MAX_MESSAGE_LENGTH: int = 4096
MAX_CAPTION_LENGTH: int = 1024
ANONYMOUS_ADMIN_ID: int = 1087968824
Expand DownExpand Up@@ -325,6 +341,7 @@
MESSAGEENTITY_UNDERLINE: str = 'underline'
MESSAGEENTITY_STRIKETHROUGH: str = 'strikethrough'
MESSAGEENTITY_SPOILER: str = 'spoiler'
MESSAGEENTITY_CUSTOM_EMOJI: str = 'custom_emoji'
MESSAGEENTITY_ALL_TYPES: List[str] = [
MESSAGEENTITY_MENTION,
MESSAGEENTITY_HASHTAG,
Expand All@@ -342,6 +359,7 @@
MESSAGEENTITY_UNDERLINE,
MESSAGEENTITY_STRIKETHROUGH,
MESSAGEENTITY_SPOILER,
MESSAGEENTITY_CUSTOM_EMOJI,
]

PARSEMODE_MARKDOWN: str = 'Markdown'
Expand All@@ -353,6 +371,10 @@
MAX_POLL_QUESTION_LENGTH: int = 300
MAX_POLL_OPTION_LENGTH: int = 100

STICKER_REGULAR: str = "regular"
STICKER_MASK: str = "mask"
STICKER_CUSTOM_EMOJI: str = "custom_emoji"

STICKER_FOREHEAD: str = 'forehead'
STICKER_EYES: str = 'eyes'
STICKER_MOUTH: str = 'mouth'
Expand Down
2 changes: 1 addition & 1 deletiontelegram/error.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -56,7 +56,7 @@ def __init__(self, message: str):
self.message = msg

def __str__(self) -> str:
return'%s' %self.message
returnf'{self.message}'

def __reduce__(self) -> Tuple[type, Tuple[str]]:
return self.__class__, (self.message,)
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp