Added full support of Bot API 8.2 (#1623)

* Added full support of Bot API 8.2

* Added changelog

* Try to add port

* Add port to the `test_reset_connector`
This commit is contained in:
Alex Root Junior 2025-01-02 02:38:18 +02:00 committed by GitHub
parent 81550997f7
commit afccd8a38f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
41 changed files with 811 additions and 85 deletions

View file

@ -70,6 +70,8 @@ from .log_out import LogOut
from .pin_chat_message import PinChatMessage
from .promote_chat_member import PromoteChatMember
from .refund_star_payment import RefundStarPayment
from .remove_chat_verification import RemoveChatVerification
from .remove_user_verification import RemoveUserVerification
from .reopen_forum_topic import ReopenForumTopic
from .reopen_general_forum_topic import ReopenGeneralForumTopic
from .replace_sticker_in_set import ReplaceStickerInSet
@ -130,6 +132,8 @@ from .unpin_all_forum_topic_messages import UnpinAllForumTopicMessages
from .unpin_all_general_forum_topic_messages import UnpinAllGeneralForumTopicMessages
from .unpin_chat_message import UnpinChatMessage
from .upload_sticker_file import UploadStickerFile
from .verify_chat import VerifyChat
from .verify_user import VerifyUser
__all__ = (
"AddStickerToSet",
@ -203,6 +207,8 @@ __all__ = (
"PinChatMessage",
"PromoteChatMember",
"RefundStarPayment",
"RemoveChatVerification",
"RemoveUserVerification",
"ReopenForumTopic",
"ReopenGeneralForumTopic",
"ReplaceStickerInSet",
@ -266,4 +272,6 @@ __all__ = (
"UnpinAllGeneralForumTopicMessages",
"UnpinChatMessage",
"UploadStickerFile",
"VerifyChat",
"VerifyUser",
)

View file

@ -0,0 +1,32 @@
from __future__ import annotations
from typing import TYPE_CHECKING, Any, Union
from .base import TelegramMethod
class RemoveChatVerification(TelegramMethod[bool]):
"""
Removes verification from a chat that is currently verified on behalf of the organization represented by the bot. Returns :code:`True` on success.
Source: https://core.telegram.org/bots/api#removechatverification
"""
__returning__ = bool
__api_method__ = "removeChatVerification"
chat_id: Union[int, str]
"""Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)"""
if TYPE_CHECKING:
# DO NOT EDIT MANUALLY!!!
# This section was auto-generated via `butcher`
def __init__(
__pydantic__self__, *, chat_id: Union[int, str], **__pydantic_kwargs: Any
) -> None:
# DO NOT EDIT MANUALLY!!!
# 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, **__pydantic_kwargs)

View file

@ -0,0 +1,30 @@
from __future__ import annotations
from typing import TYPE_CHECKING, Any
from .base import TelegramMethod
class RemoveUserVerification(TelegramMethod[bool]):
"""
Removes verification from a user who is currently verified on behalf of the organization represented by the bot. Returns :code:`True` on success.
Source: https://core.telegram.org/bots/api#removeuserverification
"""
__returning__ = bool
__api_method__ = "removeUserVerification"
user_id: int
"""Unique identifier of the target user"""
if TYPE_CHECKING:
# DO NOT EDIT MANUALLY!!!
# This section was auto-generated via `butcher`
def __init__(__pydantic__self__, *, user_id: int, **__pydantic_kwargs: Any) -> None:
# DO NOT EDIT MANUALLY!!!
# This method was auto-generated via `butcher`
# Is needed only for type checking and IDE support without any additional plugins
super().__init__(user_id=user_id, **__pydantic_kwargs)

View file

@ -20,6 +20,8 @@ class SendGift(TelegramMethod[bool]):
"""Unique identifier of the target user that will receive the gift"""
gift_id: str
"""Identifier of the gift"""
pay_for_upgrade: Optional[bool] = None
"""Pass :code:`True` to pay for the gift upgrade from the bot's balance, thereby making the upgrade free for the receiver"""
text: Optional[str] = None
"""Text that will be shown along with the gift; 0-255 characters"""
text_parse_mode: Optional[str] = None
@ -36,6 +38,7 @@ class SendGift(TelegramMethod[bool]):
*,
user_id: int,
gift_id: str,
pay_for_upgrade: Optional[bool] = None,
text: Optional[str] = None,
text_parse_mode: Optional[str] = None,
text_entities: Optional[list[MessageEntity]] = None,
@ -48,6 +51,7 @@ class SendGift(TelegramMethod[bool]):
super().__init__(
user_id=user_id,
gift_id=gift_id,
pay_for_upgrade=pay_for_upgrade,
text=text,
text_parse_mode=text_parse_mode,
text_entities=text_entities,

View file

@ -21,9 +21,9 @@ class SetStickerSetThumbnail(TelegramMethod[bool]):
user_id: int
"""User identifier of the sticker set owner"""
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"""
"""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#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."""
"""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

@ -8,7 +8,7 @@ from .base import TelegramMethod
class SetWebhook(TelegramMethod[bool]):
"""
Use this method to specify a URL and receive incoming updates via an outgoing webhook. Whenever there is an update for the bot, we will send an HTTPS POST request to the specified URL, containing a JSON-serialized :class:`aiogram.types.update.Update`. In case of an unsuccessful request, we will give up after a reasonable amount of attempts. Returns :code:`True` on success.
Use this method to specify a URL and receive incoming updates via an outgoing webhook. Whenever there is an update for the bot, we will send an HTTPS POST request to the specified URL, containing a JSON-serialized :class:`aiogram.types.update.Update`. In case of an unsuccessful request (a request with response `HTTP status code <https://en.wikipedia.org/wiki/List_of_HTTP_status_codes>`_ different from :code:`2XY`), we will repeat the request and give up after a reasonable amount of attempts. Returns :code:`True` on success.
If you'd like to make sure that the webhook was set by you, you can specify secret data in the parameter *secret_token*. If specified, the request will contain a header 'X-Telegram-Bot-Api-Secret-Token' with the secret token as content.
**Notes**

View file

@ -0,0 +1,40 @@
from __future__ import annotations
from typing import TYPE_CHECKING, Any, Optional, Union
from .base import TelegramMethod
class VerifyChat(TelegramMethod[bool]):
"""
Verifies a chat on behalf of the organization which is represented by the bot. Returns :code:`True` on success.
Source: https://core.telegram.org/bots/api#verifychat
"""
__returning__ = bool
__api_method__ = "verifyChat"
chat_id: Union[int, str]
"""Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)"""
custom_description: Optional[str] = None
"""Custom description for the verification; 0-70 characters. Must be empty if the organization isn't allowed to provide a custom verification description."""
if TYPE_CHECKING:
# DO NOT EDIT MANUALLY!!!
# This section was auto-generated via `butcher`
def __init__(
__pydantic__self__,
*,
chat_id: Union[int, str],
custom_description: Optional[str] = None,
**__pydantic_kwargs: Any,
) -> None:
# DO NOT EDIT MANUALLY!!!
# 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, custom_description=custom_description, **__pydantic_kwargs
)

View file

@ -0,0 +1,40 @@
from __future__ import annotations
from typing import TYPE_CHECKING, Any, Optional
from .base import TelegramMethod
class VerifyUser(TelegramMethod[bool]):
"""
Verifies a user on behalf of the organization which is represented by the bot. Returns :code:`True` on success.
Source: https://core.telegram.org/bots/api#verifyuser
"""
__returning__ = bool
__api_method__ = "verifyUser"
user_id: int
"""Unique identifier of the target user"""
custom_description: Optional[str] = None
"""Custom description for the verification; 0-70 characters. Must be empty if the organization isn't allowed to provide a custom verification description."""
if TYPE_CHECKING:
# DO NOT EDIT MANUALLY!!!
# This section was auto-generated via `butcher`
def __init__(
__pydantic__self__,
*,
user_id: int,
custom_description: Optional[str] = None,
**__pydantic_kwargs: Any,
) -> None:
# DO NOT EDIT MANUALLY!!!
# This method was auto-generated via `butcher`
# Is needed only for type checking and IDE support without any additional plugins
super().__init__(
user_id=user_id, custom_description=custom_description, **__pydantic_kwargs
)