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

Api 7.8#4408

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 4 commits intomasterfromapi-7.8
Aug 2, 2024
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@@ -11,7 +11,7 @@
:target: https://pypi.org/project/python-telegram-bot/
:alt: Supported Python versions

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

Expand DownExpand Up@@ -81,7 +81,7 @@ After installing_ the library, be sure to check out the section on `working with
Telegram API support
~~~~~~~~~~~~~~~~~~~~

All types and methods of the Telegram Bot API **7.7** are natively supported by this library.
All types and methods of the Telegram Bot API **7.8** are natively supported by this library.
In addition, Bot API functionality not yet natively included can still be used as described `in our wiki <https://github.com/python-telegram-bot/python-telegram-bot/wiki/Bot-API-Forward-Compatibility>`_.

Notable Features
Expand Down
20 changes: 18 additions & 2 deletionstelegram/_bot.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -6131,6 +6131,7 @@ async def pin_chat_message(
chat_id: Union[str, int],
message_id: int,
disable_notification: ODVInput[bool] = DEFAULT_NONE,
business_connection_id: Optional[str] = None,
*,
read_timeout: ODVInput[float] = DEFAULT_NONE,
write_timeout: ODVInput[float] = DEFAULT_NONE,
Expand All@@ -6151,6 +6152,10 @@ async def pin_chat_message(
disable_notification (:obj:`bool`, optional): Pass :obj:`True`, if 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 (:obj:`str`, optional): Unique identifier of the business
connection on behalf of which the message will be pinned.

.. versionadded:: NEXT.VERSION

Returns:
:obj:`bool`: On success, :obj:`True` is returned.
Expand All@@ -6163,6 +6168,7 @@ async def pin_chat_message(
"chat_id": chat_id,
"message_id": message_id,
"disable_notification": disable_notification,
"business_connection_id": business_connection_id,
}

return await self._post(
Expand All@@ -6179,6 +6185,7 @@ async def unpin_chat_message(
self,
chat_id: Union[str, int],
message_id: Optional[int] = None,
business_connection_id: Optional[str] = None,
*,
read_timeout: ODVInput[float] = DEFAULT_NONE,
write_timeout: ODVInput[float] = DEFAULT_NONE,
Expand All@@ -6195,8 +6202,13 @@ async def unpin_chat_message(

Args:
chat_id (:obj:`int` | :obj:`str`): |chat_id_channel|
message_id (:obj:`int`, optional): Identifier of a message to unpin. If not specified,
message_id (:obj:`int`, optional): Identifier of the message to unpin. Required if
:paramref:`business_connection_id` is specified. If not specified,
the most recent pinned message (by sending date) will be unpinned.
business_connection_id (:obj:`str`, optional): Unique identifier of the business
connection on behalf of which the message will be unpinned.

.. versionadded:: NEXT.VERSION

Returns:
:obj:`bool`: On success, :obj:`True` is returned.
Expand All@@ -6205,7 +6217,11 @@ async def unpin_chat_message(
:class:`telegram.error.TelegramError`

"""
data: JSONDict = {"chat_id": chat_id, "message_id": message_id}
data: JSONDict = {
"chat_id": chat_id,
"message_id": message_id,
"business_connection_id": business_connection_id,
}

return await self._post(
"unpinChatMessage",
Expand Down
4 changes: 4 additions & 0 deletionstelegram/_chat.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -905,6 +905,7 @@ async def pin_message(
self,
message_id: int,
disable_notification: ODVInput[bool] = DEFAULT_NONE,
business_connection_id: Optional[str] = None,
*,
read_timeout: ODVInput[float] = DEFAULT_NONE,
write_timeout: ODVInput[float] = DEFAULT_NONE,
Expand DownExpand Up@@ -932,11 +933,13 @@ async def pin_message(
connect_timeout=connect_timeout,
pool_timeout=pool_timeout,
api_kwargs=api_kwargs,
business_connection_id=business_connection_id,
)

async def unpin_message(
self,
message_id: Optional[int] = None,
business_connection_id: Optional[str] = None,
*,
read_timeout: ODVInput[float] = DEFAULT_NONE,
write_timeout: ODVInput[float] = DEFAULT_NONE,
Expand All@@ -963,6 +966,7 @@ async def unpin_message(
pool_timeout=pool_timeout,
api_kwargs=api_kwargs,
message_id=message_id,
business_connection_id=business_connection_id,
)

async def unpin_all_messages(
Expand Down
20 changes: 18 additions & 2 deletionstelegram/_message.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4106,18 +4106,26 @@ async def pin(
"""Shortcut for::

await bot.pin_chat_message(
chat_id=message.chat_id, message_id=message.message_id, *args, **kwargs
chat_id=message.chat_id,
message_id=message.message_id,
business_connection_id=message.business_connection_id,
*args, **kwargs
)

For the documentation of the arguments, please see :meth:`telegram.Bot.pin_chat_message`.

.. versionchanged:: NEXT.VERSION
Now also passes :attr:`business_connection_id` to
:meth:`telegram.Bot.pin_chat_message`.

Returns:
:obj:`bool`: On success, :obj:`True` is returned.

"""
return await self.get_bot().pin_chat_message(
chat_id=self.chat_id,
message_id=self.message_id,
business_connection_id=self.business_connection_id,
disable_notification=disable_notification,
read_timeout=read_timeout,
write_timeout=write_timeout,
Expand All@@ -4138,18 +4146,26 @@ async def unpin(
"""Shortcut for::

await bot.unpin_chat_message(
chat_id=message.chat_id, message_id=message.message_id, *args, **kwargs
chat_id=message.chat_id,
message_id=message.message_id,
business_connection_id=message.business_connection_id,
*args, **kwargs
)

For the documentation of the arguments, please see :meth:`telegram.Bot.unpin_chat_message`.

.. versionchanged:: NEXT.VERSION
Now also passes :attr:`business_connection_id` to
:meth:`telegram.Bot.pin_chat_message`.

Returns:
:obj:`bool`: On success, :obj:`True` is returned.

"""
return await self.get_bot().unpin_chat_message(
chat_id=self.chat_id,
message_id=self.message_id,
business_connection_id=self.business_connection_id,
read_timeout=read_timeout,
write_timeout=write_timeout,
connect_timeout=connect_timeout,
Expand Down
16 changes: 16 additions & 0 deletionstelegram/_user.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -97,6 +97,10 @@ class User(TelegramObject):
:meth:`telegram.Bot.get_me`.

.. versionadded:: 21.1
has_main_web_app (:obj:`bool`, optional): :obj:`True`, if the bot has the main Web App.
Returned only in :meth:`telegram.Bot.get_me`.

.. versionadded:: NEXT.VERSION

Attributes:
id (:obj:`int`): Unique identifier for this user or bot.
Expand DownExpand Up@@ -124,6 +128,11 @@ class User(TelegramObject):
:meth:`telegram.Bot.get_me`.

.. versionadded:: 21.1
has_main_web_app (:obj:`bool`) Optional. :obj:`True`, if the bot has the main Web App.
Returned only in :meth:`telegram.Bot.get_me`.

.. versionadded:: NEXT.VERSION

.. |user_chat_id_note| replace:: This shortcuts build on the assumption that :attr:`User.id`
coincides with the :attr:`Chat.id` of the private chat with the user. This has been the
case so far, but Telegram does not guarantee that this stays this way.
Expand All@@ -135,6 +144,7 @@ class User(TelegramObject):
"can_join_groups",
"can_read_all_group_messages",
"first_name",
"has_main_web_app",
"id",
"is_bot",
"is_premium",
Expand All@@ -158,6 +168,7 @@ def __init__(
is_premium: Optional[bool] = None,
added_to_attachment_menu: Optional[bool] = None,
can_connect_to_business: Optional[bool] = None,
has_main_web_app: Optional[bool] = None,
*,
api_kwargs: Optional[JSONDict] = None,
):
Expand All@@ -176,6 +187,7 @@ def __init__(
self.is_premium: Optional[bool] = is_premium
self.added_to_attachment_menu: Optional[bool] = added_to_attachment_menu
self.can_connect_to_business: Optional[bool] = can_connect_to_business
self.has_main_web_app: Optional[bool] = has_main_web_app

self._id_attrs = (self.id,)

Expand DownExpand Up@@ -301,6 +313,7 @@ async def pin_message(
self,
message_id: int,
disable_notification: ODVInput[bool] = DEFAULT_NONE,
business_connection_id: Optional[str] = None,
*,
read_timeout: ODVInput[float] = DEFAULT_NONE,
write_timeout: ODVInput[float] = DEFAULT_NONE,
Expand DownExpand Up@@ -329,12 +342,14 @@ async def pin_message(
write_timeout=write_timeout,
connect_timeout=connect_timeout,
pool_timeout=pool_timeout,
business_connection_id=business_connection_id,
api_kwargs=api_kwargs,
)

async def unpin_message(
self,
message_id: Optional[int] = None,
business_connection_id: Optional[str] = None,
*,
read_timeout: ODVInput[float] = DEFAULT_NONE,
write_timeout: ODVInput[float] = DEFAULT_NONE,
Expand DownExpand Up@@ -363,6 +378,7 @@ async def unpin_message(
pool_timeout=pool_timeout,
api_kwargs=api_kwargs,
message_id=message_id,
business_connection_id=business_connection_id,
)

async def unpin_all_messages(
Expand Down
2 changes: 1 addition & 1 deletiontelegram/constants.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -151,7 +151,7 @@ class _AccentColor(NamedTuple):
#: :data:`telegram.__bot_api_version_info__`.
#:
#: .. versionadded:: 20.0
BOT_API_VERSION_INFO: Final[_BotAPIVersion] = _BotAPIVersion(major=7, minor=7)
BOT_API_VERSION_INFO: Final[_BotAPIVersion] = _BotAPIVersion(major=7, minor=8)
#: :obj:`str`: Telegram Bot API
#: version supported by this version of `python-telegram-bot`. Also available as
#: :data:`telegram.__bot_api_version__`.
Expand Down
4 changes: 4 additions & 0 deletionstelegram/ext/_extbot.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2238,6 +2238,7 @@ async def pin_chat_message(
chat_id: Union[str, int],
message_id: int,
disable_notification: ODVInput[bool] = DEFAULT_NONE,
business_connection_id: Optional[str] = None,
*,
read_timeout: ODVInput[float] = DEFAULT_NONE,
write_timeout: ODVInput[float] = DEFAULT_NONE,
Expand All@@ -2254,6 +2255,7 @@ async def pin_chat_message(
write_timeout=write_timeout,
connect_timeout=connect_timeout,
pool_timeout=pool_timeout,
business_connection_id=business_connection_id,
api_kwargs=self._merge_api_rl_kwargs(api_kwargs, rate_limit_args),
)

Expand DownExpand Up@@ -3739,6 +3741,7 @@ async def unpin_chat_message(
self,
chat_id: Union[str, int],
message_id: Optional[int] = None,
business_connection_id: Optional[str] = None,
*,
read_timeout: ODVInput[float] = DEFAULT_NONE,
write_timeout: ODVInput[float] = DEFAULT_NONE,
Expand All@@ -3754,6 +3757,7 @@ async def unpin_chat_message(
write_timeout=write_timeout,
connect_timeout=connect_timeout,
pool_timeout=pool_timeout,
business_connection_id=business_connection_id,
api_kwargs=self._merge_api_rl_kwargs(api_kwargs, rate_limit_args),
)

Expand Down
2 changes: 2 additions & 0 deletionstests/test_bot.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2207,6 +2207,8 @@ async def make_assertion(url, request_data: RequestData, *args, **kwargs):

await bot.send_message(2, "text", business_connection_id=42)
await bot.stop_poll(chat_id=1, message_id=2, business_connection_id=42)
await bot.pin_chat_message(chat_id=1, message_id=2, business_connection_id=42)
await bot.unpin_chat_message(chat_id=1, business_connection_id=42)

async def test_message_effect_id_argument(self, bot, monkeypatch):
"""We can't test every single method easily, so we just test one. Our linting will catch
Expand Down
12 changes: 8 additions & 4 deletionstests/test_callbackquery.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -465,11 +465,14 @@ async def make_assertion(*args, **kwargs):
assert check_shortcut_signature(
CallbackQuery.pin_message,
Bot.pin_chat_message,
["message_id", "chat_id"],
["message_id", "chat_id", "business_connection_id"],
[],
)
assert await check_shortcut_call(
callback_query.pin_message, callback_query.get_bot(), "pin_chat_message"
callback_query.pin_message,
callback_query.get_bot(),
"pin_chat_message",
["business_connection_id"],
)
assert await check_defaults_handling(callback_query.pin_message, callback_query.get_bot())

Expand All@@ -490,14 +493,15 @@ async def make_assertion(*args, **kwargs):
assert check_shortcut_signature(
CallbackQuery.unpin_message,
Bot.unpin_chat_message,
["message_id", "chat_id"],
["message_id", "chat_id", "business_connection_id"],
[],
)
assert await check_shortcut_call(
callback_query.unpin_message,
callback_query.get_bot(),
"unpin_chat_message",
shortcut_kwargs=["message_id", "chat_id"],
shortcut_kwargs=["message_id"],
skip_params=["business_connection_id"],
)
assert await check_defaults_handling(
callback_query.unpin_message, callback_query.get_bot()
Expand Down
19 changes: 15 additions & 4 deletionstests/test_message.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2592,9 +2592,17 @@ async def make_assertion(*args, **kwargs):
return chat_id and message_id

assert check_shortcut_signature(
Message.pin, Bot.pin_chat_message, ["chat_id", "message_id"], []
Message.pin,
Bot.pin_chat_message,
["chat_id", "message_id", "business_connection_id"],
[],
)
assert await check_shortcut_call(
message.pin,
message.get_bot(),
"pin_chat_message",
shortcut_kwargs=["chat_id", "message_id", "business_connection_id"],
)
assert await check_shortcut_call(message.pin, message.get_bot(), "pin_chat_message")
assert await check_defaults_handling(message.pin, message.get_bot())

monkeypatch.setattr(message.get_bot(), "pin_chat_message", make_assertion)
Expand All@@ -2607,13 +2615,16 @@ async def make_assertion(*args, **kwargs):
return chat_id and message_id

assert check_shortcut_signature(
Message.unpin, Bot.unpin_chat_message, ["chat_id", "message_id"], []
Message.unpin,
Bot.unpin_chat_message,
["chat_id", "message_id", "business_connection_id"],
[],
)
assert await check_shortcut_call(
message.unpin,
message.get_bot(),
"unpin_chat_message",
shortcut_kwargs=["chat_id", "message_id"],
shortcut_kwargs=["chat_id", "message_id", "business_connection_id"],
)
assert await check_defaults_handling(message.unpin, message.get_bot())

Expand Down
Loading
Loading

[8]ページ先頭

©2009-2025 Movatter.jp