Added full support of Bot API 7.8 (#1551)

* Added full support of Bot API 7.8

* Added changelog

* Try to fix tests on Windows

* scope=session?

* Try another way

* Just try to set custom event loop policy manually

* Revert "Just try to set custom event loop policy manually"

This reverts commit 04ee60d878.

* Just try to set custom event loop policy manually
This commit is contained in:
Alex Root Junior 2024-08-09 19:10:39 +03:00 committed by GitHub
parent 3ba724e2fa
commit cf3a6c3d59
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 132 additions and 30 deletions

View file

@ -1,2 +1,2 @@
__version__ = "3.10.0"
__api_version__ = "7.7"
__api_version__ = "7.8"

View file

@ -2033,6 +2033,7 @@ class Bot:
self,
chat_id: Union[int, str],
message_id: int,
business_connection_id: Optional[str] = None,
disable_notification: Optional[bool] = None,
request_timeout: Optional[int] = None,
) -> bool:
@ -2043,6 +2044,7 @@ class Bot:
:param chat_id: Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)
:param message_id: Identifier of a message to pin
:param business_connection_id: Unique identifier of the business connection on behalf of which the message will be pinned
:param disable_notification: Pass :code:`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.
:param request_timeout: Request timeout
:return: Returns :code:`True` on success.
@ -2051,6 +2053,7 @@ class Bot:
call = PinChatMessage(
chat_id=chat_id,
message_id=message_id,
business_connection_id=business_connection_id,
disable_notification=disable_notification,
)
return await self(call, request_timeout=request_timeout)
@ -3934,6 +3937,7 @@ class Bot:
async def unpin_chat_message(
self,
chat_id: Union[int, str],
business_connection_id: Optional[str] = None,
message_id: Optional[int] = None,
request_timeout: Optional[int] = None,
) -> bool:
@ -3943,13 +3947,15 @@ class Bot:
Source: https://core.telegram.org/bots/api#unpinchatmessage
:param chat_id: Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)
:param message_id: Identifier of a message to unpin. If not specified, the most recent pinned message (by sending date) will be unpinned.
:param business_connection_id: Unique identifier of the business connection on behalf of which the message will be unpinned
:param message_id: Identifier of the message to unpin. Required if *business_connection_id* is specified. If not specified, the most recent pinned message (by sending date) will be unpinned.
:param request_timeout: Request timeout
:return: Returns :code:`True` on success.
"""
call = UnpinChatMessage(
chat_id=chat_id,
business_connection_id=business_connection_id,
message_id=message_id,
)
return await self(call, request_timeout=request_timeout)
@ -4297,7 +4303,7 @@ class Bot:
:param name: Sticker set name
:param user_id: User identifier of the sticker set owner
:param format: 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
:param thumbnail: 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 <https://core.telegram.org/stickers#animated-sticker-requirements>`_`https://core.telegram.org/stickers#animated-sticker-requirements <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 <https://core.telegram.org/stickers#video-sticker-requirements>`_`https://core.telegram.org/stickers#video-sticker-requirements <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. :ref:`More information on Sending Files » <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.
:param thumbnail: 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#animation-requirements <https://core.telegram.org/stickers#animation-requirements>`_`https://core.telegram.org/stickers#animation-requirements <https://core.telegram.org/stickers#animation-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-requirements <https://core.telegram.org/stickers#video-requirements>`_`https://core.telegram.org/stickers#video-requirements <https://core.telegram.org/stickers#video-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. :ref:`More information on Sending Files » <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.
:param request_timeout: Request timeout
:return: Returns :code:`True` on success.
"""

View file

@ -19,6 +19,8 @@ class PinChatMessage(TelegramMethod[bool]):
"""Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)"""
message_id: int
"""Identifier of a message to pin"""
business_connection_id: Optional[str] = None
"""Unique identifier of the business connection on behalf of which the message will be pinned"""
disable_notification: Optional[bool] = None
"""Pass :code:`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."""
@ -31,6 +33,7 @@ class PinChatMessage(TelegramMethod[bool]):
*,
chat_id: Union[int, str],
message_id: int,
business_connection_id: Optional[str] = None,
disable_notification: Optional[bool] = None,
**__pydantic_kwargs: Any,
) -> None:
@ -41,6 +44,7 @@ class PinChatMessage(TelegramMethod[bool]):
super().__init__(
chat_id=chat_id,
message_id=message_id,
business_connection_id=business_connection_id,
disable_notification=disable_notification,
**__pydantic_kwargs,
)

View file

@ -23,7 +23,7 @@ class SetStickerSetThumbnail(TelegramMethod[bool]):
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: Optional[Union[InputFile, str]] = None
"""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 <https://core.telegram.org/stickers#animated-sticker-requirements>`_`https://core.telegram.org/stickers#animated-sticker-requirements <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 <https://core.telegram.org/stickers#video-sticker-requirements>`_`https://core.telegram.org/stickers#video-sticker-requirements <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. :ref:`More information on Sending Files » <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."""
"""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#animation-requirements <https://core.telegram.org/stickers#animation-requirements>`_`https://core.telegram.org/stickers#animation-requirements <https://core.telegram.org/stickers#animation-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-requirements <https://core.telegram.org/stickers#video-requirements>`_`https://core.telegram.org/stickers#video-requirements <https://core.telegram.org/stickers#video-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. :ref:`More information on Sending Files » <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."""
if TYPE_CHECKING:
# DO NOT EDIT MANUALLY!!!

View file

@ -17,8 +17,10 @@ class UnpinChatMessage(TelegramMethod[bool]):
chat_id: Union[int, str]
"""Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)"""
business_connection_id: Optional[str] = None
"""Unique identifier of the business connection on behalf of which the message will be unpinned"""
message_id: Optional[int] = None
"""Identifier of a message to unpin. If not specified, the most recent pinned message (by sending date) will be unpinned."""
"""Identifier of the message to unpin. Required if *business_connection_id* is specified. If not specified, the most recent pinned message (by sending date) will be unpinned."""
if TYPE_CHECKING:
# DO NOT EDIT MANUALLY!!!
@ -28,6 +30,7 @@ class UnpinChatMessage(TelegramMethod[bool]):
__pydantic__self__,
*,
chat_id: Union[int, str],
business_connection_id: Optional[str] = None,
message_id: Optional[int] = None,
**__pydantic_kwargs: Any,
) -> None:
@ -35,4 +38,9 @@ class UnpinChatMessage(TelegramMethod[bool]):
# This method was auto-generated via `butcher`
# Is needed only for type checking and IDE support without any additional plugins
super().__init__(chat_id=chat_id, message_id=message_id, **__pydantic_kwargs)
super().__init__(
chat_id=chat_id,
business_connection_id=business_connection_id,
message_id=message_id,
**__pydantic_kwargs,
)

View file

@ -871,6 +871,7 @@ class Chat(TelegramObject):
def unpin_message(
self,
business_connection_id: Optional[str] = None,
message_id: Optional[int] = None,
**kwargs: Any,
) -> UnpinChatMessage:
@ -884,7 +885,8 @@ class Chat(TelegramObject):
Source: https://core.telegram.org/bots/api#unpinchatmessage
:param message_id: Identifier of a message to unpin. If not specified, the most recent pinned message (by sending date) will be unpinned.
:param business_connection_id: Unique identifier of the business connection on behalf of which the message will be unpinned
:param message_id: Identifier of the message to unpin. Required if *business_connection_id* is specified. If not specified, the most recent pinned message (by sending date) will be unpinned.
:return: instance of method :class:`aiogram.methods.unpin_chat_message.UnpinChatMessage`
"""
# DO NOT EDIT MANUALLY!!!
@ -894,6 +896,7 @@ class Chat(TelegramObject):
return UnpinChatMessage(
chat_id=self.id,
business_connection_id=business_connection_id,
message_id=message_id,
**kwargs,
).as_(self._bot)
@ -901,6 +904,7 @@ class Chat(TelegramObject):
def pin_message(
self,
message_id: int,
business_connection_id: Optional[str] = None,
disable_notification: Optional[bool] = None,
**kwargs: Any,
) -> PinChatMessage:
@ -915,6 +919,7 @@ class Chat(TelegramObject):
Source: https://core.telegram.org/bots/api#pinchatmessage
:param message_id: Identifier of a message to pin
:param business_connection_id: Unique identifier of the business connection on behalf of which the message will be pinned
:param disable_notification: Pass :code:`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.
:return: instance of method :class:`aiogram.methods.pin_chat_message.PinChatMessage`
"""
@ -926,6 +931,7 @@ class Chat(TelegramObject):
return PinChatMessage(
chat_id=self.id,
message_id=message_id,
business_connection_id=business_connection_id,
disable_notification=disable_notification,
**kwargs,
).as_(self._bot)

View file

@ -3956,6 +3956,7 @@ class Message(MaybeInaccessibleMessage):
def pin(
self,
business_connection_id: Optional[str] = None,
disable_notification: Optional[bool] = None,
**kwargs: Any,
) -> PinChatMessage:
@ -3970,6 +3971,7 @@ class Message(MaybeInaccessibleMessage):
Source: https://core.telegram.org/bots/api#pinchatmessage
:param business_connection_id: Unique identifier of the business connection on behalf of which the message will be pinned
:param disable_notification: Pass :code:`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.
:return: instance of method :class:`aiogram.methods.pin_chat_message.PinChatMessage`
"""
@ -3985,12 +3987,14 @@ class Message(MaybeInaccessibleMessage):
return PinChatMessage(
chat_id=self.chat.id,
message_id=self.message_id,
business_connection_id=business_connection_id,
disable_notification=disable_notification,
**kwargs,
).as_(self._bot)
def unpin(
self,
business_connection_id: Optional[str] = None,
**kwargs: Any,
) -> UnpinChatMessage:
"""
@ -4004,6 +4008,7 @@ class Message(MaybeInaccessibleMessage):
Source: https://core.telegram.org/bots/api#unpinchatmessage
:param business_connection_id: Unique identifier of the business connection on behalf of which the message will be unpinned
:return: instance of method :class:`aiogram.methods.unpin_chat_message.UnpinChatMessage`
"""
# DO NOT EDIT MANUALLY!!!
@ -4018,6 +4023,7 @@ class Message(MaybeInaccessibleMessage):
return UnpinChatMessage(
chat_id=self.chat.id,
message_id=self.message_id,
business_connection_id=business_connection_id,
**kwargs,
).as_(self._bot)

View file

@ -41,6 +41,8 @@ class User(TelegramObject):
"""*Optional*. :code:`True`, if the bot supports inline queries. Returned only in :class:`aiogram.methods.get_me.GetMe`."""
can_connect_to_business: Optional[bool] = None
"""*Optional*. :code:`True`, if the bot can be connected to a Telegram Business account to receive its messages. Returned only in :class:`aiogram.methods.get_me.GetMe`."""
has_main_web_app: Optional[bool] = None
"""*Optional*. :code:`True`, if the bot has a main Web App. Returned only in :class:`aiogram.methods.get_me.GetMe`."""
if TYPE_CHECKING:
# DO NOT EDIT MANUALLY!!!
@ -61,6 +63,7 @@ class User(TelegramObject):
can_read_all_group_messages: Optional[bool] = None,
supports_inline_queries: Optional[bool] = None,
can_connect_to_business: Optional[bool] = None,
has_main_web_app: Optional[bool] = None,
**__pydantic_kwargs: Any,
) -> None:
# DO NOT EDIT MANUALLY!!!
@ -80,6 +83,7 @@ class User(TelegramObject):
can_read_all_group_messages=can_read_all_group_messages,
supports_inline_queries=supports_inline_queries,
can_connect_to_business=can_connect_to_business,
has_main_web_app=has_main_web_app,
**__pydantic_kwargs,
)