Added full support for the Bot API 8.3 (#1638)

* Added full support for the Bot API 8.3

* Added changelog

* Ignore typing for aiohttp_socks
This commit is contained in:
Alex Root Junior 2025-02-16 22:37:18 +02:00 committed by GitHub
parent 25833b830e
commit d8b9ce1be9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
65 changed files with 660 additions and 118 deletions

View file

@ -23,7 +23,7 @@ class AnswerShippingQuery(TelegramMethod[bool]):
shipping_options: Optional[list[ShippingOption]] = None
"""Required if *ok* is :code:`True`. A JSON-serialized array of available shipping options."""
error_message: Optional[str] = None
"""Required if *ok* is :code:`False`. Error message in human readable form that explains why it is impossible to complete the order (e.g. "Sorry, delivery to your desired address is unavailable'). Telegram will display this message to the user."""
"""Required if *ok* is :code:`False`. Error message in human readable form that explains why it is impossible to complete the order (e.g. 'Sorry, delivery to your desired address is unavailable'). Telegram will display this message to the user."""
if TYPE_CHECKING:
# DO NOT EDIT MANUALLY!!!

View file

@ -1,5 +1,6 @@
from __future__ import annotations
import datetime
from typing import TYPE_CHECKING, Any, Optional, Union
from pydantic import Field
@ -35,6 +36,8 @@ class CopyMessage(TelegramMethod[MessageId]):
"""Message identifier in the chat specified in *from_chat_id*"""
message_thread_id: Optional[int] = None
"""Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"""
video_start_timestamp: Optional[Union[datetime.datetime, datetime.timedelta, int]] = None
"""New start timestamp for the copied video in the message"""
caption: Optional[str] = None
"""New caption for media, 0-1024 characters after entities parsing. If not specified, the original caption is kept"""
parse_mode: Optional[Union[str, Default]] = Default("parse_mode")
@ -79,6 +82,9 @@ class CopyMessage(TelegramMethod[MessageId]):
from_chat_id: Union[int, str],
message_id: int,
message_thread_id: Optional[int] = None,
video_start_timestamp: Optional[
Union[datetime.datetime, datetime.timedelta, int]
] = None,
caption: Optional[str] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
caption_entities: Optional[list[MessageEntity]] = None,
@ -105,6 +111,7 @@ class CopyMessage(TelegramMethod[MessageId]):
from_chat_id=from_chat_id,
message_id=message_id,
message_thread_id=message_thread_id,
video_start_timestamp=video_start_timestamp,
caption=caption,
parse_mode=parse_mode,
caption_entities=caption_entities,

View file

@ -1,5 +1,6 @@
from __future__ import annotations
import datetime
from typing import TYPE_CHECKING, Any, Optional, Union
from ..client.default import Default
@ -25,6 +26,8 @@ class ForwardMessage(TelegramMethod[Message]):
"""Message identifier in the chat specified in *from_chat_id*"""
message_thread_id: Optional[int] = None
"""Unique identifier for the target message thread (topic) of the forum; for forum supergroups only"""
video_start_timestamp: Optional[Union[datetime.datetime, datetime.timedelta, int]] = None
"""New start timestamp for the forwarded video in the message"""
disable_notification: Optional[bool] = None
"""Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound."""
protect_content: Optional[Union[bool, Default]] = Default("protect_content")
@ -41,6 +44,9 @@ class ForwardMessage(TelegramMethod[Message]):
from_chat_id: Union[int, str],
message_id: int,
message_thread_id: Optional[int] = None,
video_start_timestamp: Optional[
Union[datetime.datetime, datetime.timedelta, int]
] = None,
disable_notification: Optional[bool] = None,
protect_content: Optional[Union[bool, Default]] = Default("protect_content"),
**__pydantic_kwargs: Any,
@ -54,6 +60,7 @@ class ForwardMessage(TelegramMethod[Message]):
from_chat_id=from_chat_id,
message_id=message_id,
message_thread_id=message_thread_id,
video_start_timestamp=video_start_timestamp,
disable_notification=disable_notification,
protect_content=protect_content,
**__pydantic_kwargs,

View file

@ -6,7 +6,7 @@ from .base import TelegramMethod
class GetAvailableGifts(TelegramMethod[Gifts]):
"""
Returns the list of gifts that can be sent by the bot to users. Requires no parameters. Returns a :class:`aiogram.types.gifts.Gifts` object.
Returns the list of gifts that can be sent by the bot to users and channel chats. Requires no parameters. Returns a :class:`aiogram.types.gifts.Gifts` object.
Source: https://core.telegram.org/bots/api#getavailablegifts
"""

View file

@ -7,7 +7,7 @@ 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.
Removes verification from a chat that is currently verified `on behalf of the organization <https://telegram.org/verify#third-party-verification>`_ represented by the bot. Returns :code:`True` on success.
Source: https://core.telegram.org/bots/api#removechatverification
"""

View file

@ -7,7 +7,7 @@ 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.
Removes verification from a user who is currently verified `on behalf of the organization <https://telegram.org/verify#third-party-verification>`_ represented by the bot. Returns :code:`True` on success.
Source: https://core.telegram.org/bots/api#removeuserverification
"""

View file

@ -1,6 +1,6 @@
from __future__ import annotations
from typing import TYPE_CHECKING, Any, Optional
from typing import TYPE_CHECKING, Any, Optional, Union
from ..types.message_entity import MessageEntity
from .base import TelegramMethod
@ -8,7 +8,7 @@ from .base import TelegramMethod
class SendGift(TelegramMethod[bool]):
"""
Sends a gift to the given user. The gift can't be converted to Telegram Stars by the user. Returns :code:`True` on success.
Sends a gift to the given user or channel chat. The gift can't be converted to Telegram Stars by the receiver. Returns :code:`True` on success.
Source: https://core.telegram.org/bots/api#sendgift
"""
@ -16,10 +16,12 @@ class SendGift(TelegramMethod[bool]):
__returning__ = bool
__api_method__ = "sendGift"
user_id: int
"""Unique identifier of the target user that will receive the gift"""
gift_id: str
"""Identifier of the gift"""
user_id: Optional[int] = None
"""Required if *chat_id* is not specified. Unique identifier of the target user who will receive the gift."""
chat_id: Optional[Union[int, str]] = None
"""Required if *user_id* is not specified. Unique identifier for the chat or username of the channel (in the format :code:`@channelusername`) that will receive 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
@ -36,8 +38,9 @@ class SendGift(TelegramMethod[bool]):
def __init__(
__pydantic__self__,
*,
user_id: int,
gift_id: str,
user_id: Optional[int] = None,
chat_id: Optional[Union[int, str]] = None,
pay_for_upgrade: Optional[bool] = None,
text: Optional[str] = None,
text_parse_mode: Optional[str] = None,
@ -49,8 +52,9 @@ class SendGift(TelegramMethod[bool]):
# Is needed only for type checking and IDE support without any additional plugins
super().__init__(
user_id=user_id,
gift_id=gift_id,
user_id=user_id,
chat_id=chat_id,
pay_for_upgrade=pay_for_upgrade,
text=text,
text_parse_mode=text_parse_mode,

View file

@ -1,5 +1,6 @@
from __future__ import annotations
import datetime
from typing import TYPE_CHECKING, Any, Optional, Union
from pydantic import Field
@ -44,6 +45,10 @@ class SendVideo(TelegramMethod[Message]):
"""Video height"""
thumbnail: Optional[InputFile] = None
"""Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass 'attach://<file_attach_name>' if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. :ref:`More information on Sending Files » <sending-files>`"""
cover: Optional[Union[InputFile, str]] = None
"""Cover for the video in the message. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass 'attach://<file_attach_name>' to upload a new one using multipart/form-data under <file_attach_name> name. :ref:`More information on Sending Files » <sending-files>`"""
start_timestamp: Optional[Union[datetime.datetime, datetime.timedelta, int]] = None
"""Start timestamp for the video in the message"""
caption: Optional[str] = None
"""Video caption (may also be used when resending videos by *file_id*), 0-1024 characters after entities parsing"""
parse_mode: Optional[Union[str, Default]] = Default("parse_mode")
@ -98,6 +103,8 @@ class SendVideo(TelegramMethod[Message]):
width: Optional[int] = None,
height: Optional[int] = None,
thumbnail: Optional[InputFile] = None,
cover: Optional[Union[InputFile, str]] = None,
start_timestamp: Optional[Union[datetime.datetime, datetime.timedelta, int]] = None,
caption: Optional[str] = None,
parse_mode: Optional[Union[str, Default]] = Default("parse_mode"),
caption_entities: Optional[list[MessageEntity]] = None,
@ -131,6 +138,8 @@ class SendVideo(TelegramMethod[Message]):
width=width,
height=height,
thumbnail=thumbnail,
cover=cover,
start_timestamp=start_timestamp,
caption=caption,
parse_mode=parse_mode,
caption_entities=caption_entities,

View file

@ -6,7 +6,7 @@ from .base import TelegramMethod
class SetMessageReaction(TelegramMethod[bool]):
"""
Use this method to change the chosen reactions on a message. Service messages can't be reacted to. Automatically forwarded messages from a channel to its discussion group have the same available reactions as messages in the channel. Bots can't use paid reactions. Returns :code:`True` on success.
Use this method to change the chosen reactions on a message. Service messages of some types can't be reacted to. Automatically forwarded messages from a channel to its discussion group have the same available reactions as messages in the channel. Bots can't use paid reactions. Returns :code:`True` on success.
Source: https://core.telegram.org/bots/api#setmessagereaction
"""

View file

@ -7,7 +7,7 @@ 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.
Verifies a chat `on behalf of the organization <https://telegram.org/verify#third-party-verification>`_ which is represented by the bot. Returns :code:`True` on success.
Source: https://core.telegram.org/bots/api#verifychat
"""

View file

@ -7,7 +7,7 @@ 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.
Verifies a user `on behalf of the organization <https://telegram.org/verify#third-party-verification>`_ which is represented by the bot. Returns :code:`True` on success.
Source: https://core.telegram.org/bots/api#verifyuser
"""