mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Add support for Telegram Bot API 9.1 (#1704)
* Add support for Telegram Bot API 9.1 features, including checklists, gifts, and new methods like `SendChecklist`, `EditMessageChecklist`, and `GetMyStarBalance`. Update changelog and improve `True` field descriptions. * Bump API Version * Refactor profile photo types to use `InputProfilePhotoType` enums instead of hardcoded literals * Refactor imports and clean up redundant code across methods, types, and webhook server classes
This commit is contained in:
parent
77ca49518e
commit
f060c08d16
117 changed files with 2565 additions and 466 deletions
|
|
@ -36,6 +36,7 @@ from .edit_chat_subscription_invite_link import EditChatSubscriptionInviteLink
|
|||
from .edit_forum_topic import EditForumTopic
|
||||
from .edit_general_forum_topic import EditGeneralForumTopic
|
||||
from .edit_message_caption import EditMessageCaption
|
||||
from .edit_message_checklist import EditMessageChecklist
|
||||
from .edit_message_live_location import EditMessageLiveLocation
|
||||
from .edit_message_media import EditMessageMedia
|
||||
from .edit_message_reply_markup import EditMessageReplyMarkup
|
||||
|
|
@ -64,6 +65,7 @@ from .get_my_default_administrator_rights import GetMyDefaultAdministratorRights
|
|||
from .get_my_description import GetMyDescription
|
||||
from .get_my_name import GetMyName
|
||||
from .get_my_short_description import GetMyShortDescription
|
||||
from .get_my_star_balance import GetMyStarBalance
|
||||
from .get_star_transactions import GetStarTransactions
|
||||
from .get_sticker_set import GetStickerSet
|
||||
from .get_updates import GetUpdates
|
||||
|
|
@ -91,6 +93,7 @@ from .save_prepared_inline_message import SavePreparedInlineMessage
|
|||
from .send_animation import SendAnimation
|
||||
from .send_audio import SendAudio
|
||||
from .send_chat_action import SendChatAction
|
||||
from .send_checklist import SendChecklist
|
||||
from .send_contact import SendContact
|
||||
from .send_dice import SendDice
|
||||
from .send_document import SendDocument
|
||||
|
|
@ -191,6 +194,7 @@ __all__ = (
|
|||
"EditForumTopic",
|
||||
"EditGeneralForumTopic",
|
||||
"EditMessageCaption",
|
||||
"EditMessageChecklist",
|
||||
"EditMessageLiveLocation",
|
||||
"EditMessageMedia",
|
||||
"EditMessageReplyMarkup",
|
||||
|
|
@ -219,6 +223,7 @@ __all__ = (
|
|||
"GetMyDescription",
|
||||
"GetMyName",
|
||||
"GetMyShortDescription",
|
||||
"GetMyStarBalance",
|
||||
"GetStarTransactions",
|
||||
"GetStickerSet",
|
||||
"GetUpdates",
|
||||
|
|
@ -248,6 +253,7 @@ __all__ = (
|
|||
"SendAnimation",
|
||||
"SendAudio",
|
||||
"SendChatAction",
|
||||
"SendChecklist",
|
||||
"SendContact",
|
||||
"SendDice",
|
||||
"SendDocument",
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ from .base import TelegramMethod
|
|||
|
||||
class DeleteBusinessMessages(TelegramMethod[bool]):
|
||||
"""
|
||||
Delete messages on behalf of a business account. Requires the *can_delete_outgoing_messages* business bot right to delete messages sent by the bot itself, or the *can_delete_all_messages* business bot right to delete any message. Returns :code:`True` on success.
|
||||
Delete messages on behalf of a business account. Requires the *can_delete_sent_messages* business bot right to delete messages sent by the bot itself, or the *can_delete_all_messages* business bot right to delete any message. Returns :code:`True` on success.
|
||||
|
||||
Source: https://core.telegram.org/bots/api#deletebusinessmessages
|
||||
"""
|
||||
|
|
|
|||
55
aiogram/methods/edit_message_checklist.py
Normal file
55
aiogram/methods/edit_message_checklist.py
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Optional
|
||||
|
||||
from ..types import InlineKeyboardMarkup, InputChecklist, Message
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class EditMessageChecklist(TelegramMethod[Message]):
|
||||
"""
|
||||
Use this method to edit a checklist on behalf of a connected business account. On success, the edited :class:`aiogram.types.message.Message` is returned.
|
||||
|
||||
Source: https://core.telegram.org/bots/api#editmessagechecklist
|
||||
"""
|
||||
|
||||
__returning__ = Message
|
||||
__api_method__ = "editMessageChecklist"
|
||||
|
||||
business_connection_id: str
|
||||
"""Unique identifier of the business connection on behalf of which the message will be sent"""
|
||||
chat_id: int
|
||||
"""Unique identifier for the target chat"""
|
||||
message_id: int
|
||||
"""Unique identifier for the target message"""
|
||||
checklist: InputChecklist
|
||||
"""A JSON-serialized object for the new checklist"""
|
||||
reply_markup: Optional[InlineKeyboardMarkup] = None
|
||||
"""A JSON-serialized object for the new inline keyboard for the message"""
|
||||
|
||||
if TYPE_CHECKING:
|
||||
# DO NOT EDIT MANUALLY!!!
|
||||
# This section was auto-generated via `butcher`
|
||||
|
||||
def __init__(
|
||||
__pydantic__self__,
|
||||
*,
|
||||
business_connection_id: str,
|
||||
chat_id: int,
|
||||
message_id: int,
|
||||
checklist: InputChecklist,
|
||||
reply_markup: Optional[InlineKeyboardMarkup] = 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__(
|
||||
business_connection_id=business_connection_id,
|
||||
chat_id=chat_id,
|
||||
message_id=message_id,
|
||||
checklist=checklist,
|
||||
reply_markup=reply_markup,
|
||||
**__pydantic_kwargs,
|
||||
)
|
||||
|
|
@ -19,17 +19,17 @@ class GetBusinessAccountGifts(TelegramMethod[OwnedGifts]):
|
|||
business_connection_id: str
|
||||
"""Unique identifier of the business connection"""
|
||||
exclude_unsaved: Optional[bool] = None
|
||||
"""Pass True to exclude gifts that aren't saved to the account's profile page"""
|
||||
"""Pass :code:`True` to exclude gifts that aren't saved to the account's profile page"""
|
||||
exclude_saved: Optional[bool] = None
|
||||
"""Pass True to exclude gifts that are saved to the account's profile page"""
|
||||
"""Pass :code:`True` to exclude gifts that are saved to the account's profile page"""
|
||||
exclude_unlimited: Optional[bool] = None
|
||||
"""Pass True to exclude gifts that can be purchased an unlimited number of times"""
|
||||
"""Pass :code:`True` to exclude gifts that can be purchased an unlimited number of times"""
|
||||
exclude_limited: Optional[bool] = None
|
||||
"""Pass True to exclude gifts that can be purchased a limited number of times"""
|
||||
"""Pass :code:`True` to exclude gifts that can be purchased a limited number of times"""
|
||||
exclude_unique: Optional[bool] = None
|
||||
"""Pass True to exclude unique gifts"""
|
||||
"""Pass :code:`True` to exclude unique gifts"""
|
||||
sort_by_price: Optional[bool] = None
|
||||
"""Pass True to sort results by gift price instead of send date. Sorting is applied before pagination."""
|
||||
"""Pass :code:`True` to sort results by gift price instead of send date. Sorting is applied before pagination."""
|
||||
offset: Optional[str] = None
|
||||
"""Offset of the first entry to return as received from the previous request; use empty string to get the first chunk of results"""
|
||||
limit: Optional[int] = None
|
||||
|
|
|
|||
15
aiogram/methods/get_my_star_balance.py
Normal file
15
aiogram/methods/get_my_star_balance.py
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from ..types import StarAmount
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class GetMyStarBalance(TelegramMethod[StarAmount]):
|
||||
"""
|
||||
A method to get the current Telegram Stars balance of the bot. Requires no parameters. On success, returns a :class:`aiogram.types.star_amount.StarAmount` object.
|
||||
|
||||
Source: https://core.telegram.org/bots/api#getmystarbalance
|
||||
"""
|
||||
|
||||
__returning__ = StarAmount
|
||||
__api_method__ = "getMyStarBalance"
|
||||
|
|
@ -23,7 +23,7 @@ class PromoteChatMember(TelegramMethod[bool]):
|
|||
is_anonymous: Optional[bool] = None
|
||||
"""Pass :code:`True` if the administrator's presence in the chat is hidden"""
|
||||
can_manage_chat: Optional[bool] = None
|
||||
"""Pass :code:`True` if the administrator can access the chat event log, get boost list, see hidden supergroup and channel members, report spam messages and ignore slow mode. Implied by any other administrator privilege."""
|
||||
"""Pass :code:`True` if the administrator can access the chat event log, get boost list, see hidden supergroup and channel members, report spam messages, ignore slow mode, and send messages to the chat without paying Telegram Stars. Implied by any other administrator privilege."""
|
||||
can_delete_messages: Optional[bool] = None
|
||||
"""Pass :code:`True` if the administrator can delete messages of other users"""
|
||||
can_manage_video_chats: Optional[bool] = None
|
||||
|
|
@ -43,7 +43,7 @@ class PromoteChatMember(TelegramMethod[bool]):
|
|||
can_delete_stories: Optional[bool] = None
|
||||
"""Pass :code:`True` if the administrator can delete stories posted by other users"""
|
||||
can_post_messages: Optional[bool] = None
|
||||
"""Pass :code:`True` if the administrator can post messages in the channel, or access channel statistics; for channels only"""
|
||||
"""Pass :code:`True` if the administrator can post messages in the channel, approve suggested posts, or access channel statistics; for channels only"""
|
||||
can_edit_messages: Optional[bool] = None
|
||||
"""Pass :code:`True` if the administrator can edit messages of other users and can pin messages; for channels only"""
|
||||
can_pin_messages: Optional[bool] = None
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ class RemoveBusinessAccountProfilePhoto(TelegramMethod[bool]):
|
|||
business_connection_id: str
|
||||
"""Unique identifier of the business connection"""
|
||||
is_public: Optional[bool] = None
|
||||
"""Pass True to remove the public photo, which is visible even if the main photo is hidden by the business account's privacy settings. After the main photo is removed, the previous profile photo (if present) becomes the main photo."""
|
||||
"""Pass :code:`True` to remove the public photo, which is visible even if the main photo is hidden by the business account's privacy settings. After the main photo is removed, the previous profile photo (if present) becomes the main photo."""
|
||||
|
||||
if TYPE_CHECKING:
|
||||
# DO NOT EDIT MANUALLY!!!
|
||||
|
|
|
|||
67
aiogram/methods/send_checklist.py
Normal file
67
aiogram/methods/send_checklist.py
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Optional
|
||||
|
||||
from ..types import InlineKeyboardMarkup, InputChecklist, Message, ReplyParameters
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class SendChecklist(TelegramMethod[Message]):
|
||||
"""
|
||||
Use this method to send a checklist on behalf of a connected business account. On success, the sent :class:`aiogram.types.message.Message` is returned.
|
||||
|
||||
Source: https://core.telegram.org/bots/api#sendchecklist
|
||||
"""
|
||||
|
||||
__returning__ = Message
|
||||
__api_method__ = "sendChecklist"
|
||||
|
||||
business_connection_id: str
|
||||
"""Unique identifier of the business connection on behalf of which the message will be sent"""
|
||||
chat_id: int
|
||||
"""Unique identifier for the target chat"""
|
||||
checklist: InputChecklist
|
||||
"""A JSON-serialized object for the checklist to send"""
|
||||
disable_notification: Optional[bool] = None
|
||||
"""Sends the message silently. Users will receive a notification with no sound."""
|
||||
protect_content: Optional[bool] = None
|
||||
"""Protects the contents of the sent message from forwarding and saving"""
|
||||
message_effect_id: Optional[str] = None
|
||||
"""Unique identifier of the message effect to be added to the message"""
|
||||
reply_parameters: Optional[ReplyParameters] = None
|
||||
"""A JSON-serialized object for description of the message to reply to"""
|
||||
reply_markup: Optional[InlineKeyboardMarkup] = None
|
||||
"""A JSON-serialized object for an inline keyboard"""
|
||||
|
||||
if TYPE_CHECKING:
|
||||
# DO NOT EDIT MANUALLY!!!
|
||||
# This section was auto-generated via `butcher`
|
||||
|
||||
def __init__(
|
||||
__pydantic__self__,
|
||||
*,
|
||||
business_connection_id: str,
|
||||
chat_id: int,
|
||||
checklist: InputChecklist,
|
||||
disable_notification: Optional[bool] = None,
|
||||
protect_content: Optional[bool] = None,
|
||||
message_effect_id: Optional[str] = None,
|
||||
reply_parameters: Optional[ReplyParameters] = None,
|
||||
reply_markup: Optional[InlineKeyboardMarkup] = 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__(
|
||||
business_connection_id=business_connection_id,
|
||||
chat_id=chat_id,
|
||||
checklist=checklist,
|
||||
disable_notification=disable_notification,
|
||||
protect_content=protect_content,
|
||||
message_effect_id=message_effect_id,
|
||||
reply_parameters=reply_parameters,
|
||||
reply_markup=reply_markup,
|
||||
**__pydantic_kwargs,
|
||||
)
|
||||
|
|
@ -32,7 +32,7 @@ class SendPoll(TelegramMethod[Message]):
|
|||
question: str
|
||||
"""Poll question, 1-300 characters"""
|
||||
options: list[InputPollOptionUnion]
|
||||
"""A JSON-serialized list of 2-10 answer options"""
|
||||
"""A JSON-serialized list of 2-12 answer options"""
|
||||
business_connection_id: Optional[str] = None
|
||||
"""Unique identifier of the business connection on behalf of which the message will be sent"""
|
||||
message_thread_id: Optional[int] = None
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ class SetBusinessAccountGiftSettings(TelegramMethod[bool]):
|
|||
business_connection_id: str
|
||||
"""Unique identifier of the business connection"""
|
||||
show_gift_button: bool
|
||||
"""Pass True, if a button for sending a gift to the user or by the business account must always be shown in the input field"""
|
||||
"""Pass :code:`True`, if a button for sending a gift to the user or by the business account must always be shown in the input field"""
|
||||
accepted_gift_types: AcceptedGiftTypes
|
||||
"""Types of gifts accepted by the business account"""
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ class SetBusinessAccountProfilePhoto(TelegramMethod[bool]):
|
|||
photo: InputProfilePhotoUnion
|
||||
"""The new profile photo to set"""
|
||||
is_public: Optional[bool] = None
|
||||
"""Pass True to set the public photo, which will be visible even if the main photo is hidden by the business account's privacy settings. An account can have only one public photo."""
|
||||
"""Pass :code:`True` to set the public photo, which will be visible even if the main photo is hidden by the business account's privacy settings. An account can have only one public photo."""
|
||||
|
||||
if TYPE_CHECKING:
|
||||
# DO NOT EDIT MANUALLY!!!
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ class UpgradeGift(TelegramMethod[bool]):
|
|||
owned_gift_id: str
|
||||
"""Unique identifier of the regular gift that should be upgraded to a unique one"""
|
||||
keep_original_details: Optional[bool] = None
|
||||
"""Pass True to keep the original gift text, sender and receiver in the upgraded gift"""
|
||||
"""Pass :code:`True` to keep the original gift text, sender and receiver in the upgraded gift"""
|
||||
star_count: Optional[int] = None
|
||||
"""The amount of Telegram Stars that will be paid for the upgrade from the business account balance. If :code:`gift.prepaid_upgrade_star_count > 0`, then pass 0, otherwise, the *can_transfer_stars* business bot right is required and :code:`gift.upgrade_star_count` must be passed."""
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue