Added full support of Bot API 7.9 (#1560)

* Added full support of Bot API 7.9

* Added changelog

* Try to fix towncrier

* Fixed towncrier check
This commit is contained in:
Alex Root Junior 2024-08-16 00:44:40 +03:00 committed by GitHub
parent 1c323ecc97
commit c3a08664d3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
48 changed files with 817 additions and 114 deletions

View file

@ -1,2 +1,2 @@
__version__ = "3.11.0"
__api_version__ = "7.8"
__api_version__ = "7.9"

View file

@ -38,6 +38,7 @@ from ..methods import (
CopyMessage,
CopyMessages,
CreateChatInviteLink,
CreateChatSubscriptionInviteLink,
CreateForumTopic,
CreateInvoiceLink,
CreateNewStickerSet,
@ -52,6 +53,7 @@ from ..methods import (
DeleteStickerSet,
DeleteWebhook,
EditChatInviteLink,
EditChatSubscriptionInviteLink,
EditForumTopic,
EditGeneralForumTopic,
EditMessageCaption,
@ -230,6 +232,7 @@ from ..types import (
Poll,
ReactionTypeCustomEmoji,
ReactionTypeEmoji,
ReactionTypePaid,
ReplyKeyboardMarkup,
ReplyKeyboardRemove,
ReplyParameters,
@ -1325,7 +1328,7 @@ class Bot:
request_timeout: Optional[int] = None,
) -> bool:
"""
Use this method to edit name and icon of a topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have *can_manage_topics* administrator rights, unless it is the creator of the topic. Returns :code:`True` on success.
Use this method to edit name and icon of a topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the *can_manage_topics* administrator rights, unless it is the creator of the topic. Returns :code:`True` on success.
Source: https://core.telegram.org/bots/api#editforumtopic
@ -4013,7 +4016,7 @@ class Bot:
request_timeout: Optional[int] = None,
) -> bool:
"""
Use this method to edit the name of the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have *can_manage_topics* administrator rights. Returns :code:`True` on success.
Use this method to edit the name of the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the *can_manage_topics* administrator rights. Returns :code:`True` on success.
Source: https://core.telegram.org/bots/api#editgeneralforumtopic
@ -4525,18 +4528,20 @@ class Bot:
self,
chat_id: Union[int, str],
message_id: int,
reaction: Optional[List[Union[ReactionTypeEmoji, ReactionTypeCustomEmoji]]] = None,
reaction: Optional[
List[Union[ReactionTypeEmoji, ReactionTypeCustomEmoji, ReactionTypePaid]]
] = None,
is_big: Optional[bool] = None,
request_timeout: Optional[int] = None,
) -> 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. Returns :code:`True` on success.
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.
Source: https://core.telegram.org/bots/api#setmessagereaction
: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 the target message. If the message belongs to a media group, the reaction is set to the first non-deleted message in the group instead.
:param reaction: A JSON-serialized list of reaction types to set on the message. Currently, as non-premium users, bots can set up to one reaction per message. A custom emoji reaction can be used if it is either already present on the message or explicitly allowed by chat administrators.
:param reaction: A JSON-serialized list of reaction types to set on the message. Currently, as non-premium users, bots can set up to one reaction per message. A custom emoji reaction can be used if it is either already present on the message or explicitly allowed by chat administrators. Paid reactions can't be used by bots.
:param is_big: Pass :code:`True` to set the reaction with a big animation
:param request_timeout: Request timeout
:return: Returns :code:`True` on success.
@ -4650,6 +4655,7 @@ class Bot:
chat_id: Union[int, str],
star_count: int,
media: List[Union[InputPaidMediaPhoto, InputPaidMediaVideo]],
business_connection_id: Optional[str] = None,
caption: Optional[str] = None,
parse_mode: Optional[str] = None,
caption_entities: Optional[List[MessageEntity]] = None,
@ -4663,13 +4669,14 @@ class Bot:
request_timeout: Optional[int] = None,
) -> Message:
"""
Use this method to send paid media to channel chats. On success, the sent :class:`aiogram.types.message.Message` is returned.
Use this method to send paid media. On success, the sent :class:`aiogram.types.message.Message` is returned.
Source: https://core.telegram.org/bots/api#sendpaidmedia
:param chat_id: Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)
:param chat_id: Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`). If the chat is a channel, all Telegram Star proceeds from this media will be credited to the chat's balance. Otherwise, they will be credited to the bot's balance.
:param star_count: The number of Telegram Stars that must be paid to buy access to the media
:param media: A JSON-serialized array describing the media to be sent; up to 10 items
:param business_connection_id: Unique identifier of the business connection on behalf of which the message will be sent
:param caption: Media caption, 0-1024 characters after entities parsing
:param parse_mode: Mode for parsing entities in the media caption. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details.
:param caption_entities: A JSON-serialized list of special entities that appear in the caption, which can be specified instead of *parse_mode*
@ -4686,6 +4693,7 @@ class Bot:
chat_id=chat_id,
star_count=star_count,
media=media,
business_connection_id=business_connection_id,
caption=caption,
parse_mode=parse_mode,
caption_entities=caption_entities,
@ -4696,3 +4704,58 @@ class Bot:
reply_markup=reply_markup,
)
return await self(call, request_timeout=request_timeout)
async def create_chat_subscription_invite_link(
self,
chat_id: Union[int, str],
subscription_period: Union[datetime.datetime, datetime.timedelta, int],
subscription_price: int,
name: Optional[str] = None,
request_timeout: Optional[int] = None,
) -> ChatInviteLink:
"""
Use this method to create a `subscription invite link <https://telegram.org/blog/superchannels-star-reactions-subscriptions#star-subscriptions>`_ for a channel chat. The bot must have the *can_invite_users* administrator rights. The link can be edited using the method :class:`aiogram.methods.edit_chat_subscription_invite_link.EditChatSubscriptionInviteLink` or revoked using the method :class:`aiogram.methods.revoke_chat_invite_link.RevokeChatInviteLink`. Returns the new invite link as a :class:`aiogram.types.chat_invite_link.ChatInviteLink` object.
Source: https://core.telegram.org/bots/api#createchatsubscriptioninvitelink
:param chat_id: Unique identifier for the target channel chat or username of the target channel (in the format :code:`@channelusername`)
:param subscription_period: The number of seconds the subscription will be active for before the next payment. Currently, it must always be 2592000 (30 days).
:param subscription_price: The amount of Telegram Stars a user must pay initially and after each subsequent subscription period to be a member of the chat; 1-2500
:param name: Invite link name; 0-32 characters
:param request_timeout: Request timeout
:return: Returns the new invite link as a :class:`aiogram.types.chat_invite_link.ChatInviteLink` object.
"""
call = CreateChatSubscriptionInviteLink(
chat_id=chat_id,
subscription_period=subscription_period,
subscription_price=subscription_price,
name=name,
)
return await self(call, request_timeout=request_timeout)
async def edit_chat_subscription_invite_link(
self,
chat_id: Union[int, str],
invite_link: str,
name: Optional[str] = None,
request_timeout: Optional[int] = None,
) -> ChatInviteLink:
"""
Use this method to edit a subscription invite link created by the bot. The bot must have the *can_invite_users* administrator rights. Returns the edited invite link as a :class:`aiogram.types.chat_invite_link.ChatInviteLink` object.
Source: https://core.telegram.org/bots/api#editchatsubscriptioninvitelink
:param chat_id: Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)
:param invite_link: The invite link to edit
:param name: Invite link name; 0-32 characters
:param request_timeout: Request timeout
:return: Returns the edited invite link as a :class:`aiogram.types.chat_invite_link.ChatInviteLink` object.
"""
call = EditChatSubscriptionInviteLink(
chat_id=chat_id,
invite_link=invite_link,
name=name,
)
return await self(call, request_timeout=request_timeout)

View file

@ -14,6 +14,7 @@ from .close_general_forum_topic import CloseGeneralForumTopic
from .copy_message import CopyMessage
from .copy_messages import CopyMessages
from .create_chat_invite_link import CreateChatInviteLink
from .create_chat_subscription_invite_link import CreateChatSubscriptionInviteLink
from .create_forum_topic import CreateForumTopic
from .create_invoice_link import CreateInvoiceLink
from .create_new_sticker_set import CreateNewStickerSet
@ -28,6 +29,7 @@ from .delete_sticker_from_set import DeleteStickerFromSet
from .delete_sticker_set import DeleteStickerSet
from .delete_webhook import DeleteWebhook
from .edit_chat_invite_link import EditChatInviteLink
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
@ -140,6 +142,7 @@ __all__ = (
"CopyMessage",
"CopyMessages",
"CreateChatInviteLink",
"CreateChatSubscriptionInviteLink",
"CreateForumTopic",
"CreateInvoiceLink",
"CreateNewStickerSet",
@ -154,6 +157,7 @@ __all__ = (
"DeleteStickerSet",
"DeleteWebhook",
"EditChatInviteLink",
"EditChatSubscriptionInviteLink",
"EditForumTopic",
"EditGeneralForumTopic",
"EditMessageCaption",

View file

@ -0,0 +1,52 @@
from __future__ import annotations
import datetime
from typing import TYPE_CHECKING, Any, Optional, Union
from ..types import ChatInviteLink
from .base import TelegramMethod
class CreateChatSubscriptionInviteLink(TelegramMethod[ChatInviteLink]):
"""
Use this method to create a `subscription invite link <https://telegram.org/blog/superchannels-star-reactions-subscriptions#star-subscriptions>`_ for a channel chat. The bot must have the *can_invite_users* administrator rights. The link can be edited using the method :class:`aiogram.methods.edit_chat_subscription_invite_link.EditChatSubscriptionInviteLink` or revoked using the method :class:`aiogram.methods.revoke_chat_invite_link.RevokeChatInviteLink`. Returns the new invite link as a :class:`aiogram.types.chat_invite_link.ChatInviteLink` object.
Source: https://core.telegram.org/bots/api#createchatsubscriptioninvitelink
"""
__returning__ = ChatInviteLink
__api_method__ = "createChatSubscriptionInviteLink"
chat_id: Union[int, str]
"""Unique identifier for the target channel chat or username of the target channel (in the format :code:`@channelusername`)"""
subscription_period: Union[datetime.datetime, datetime.timedelta, int]
"""The number of seconds the subscription will be active for before the next payment. Currently, it must always be 2592000 (30 days)."""
subscription_price: int
"""The amount of Telegram Stars a user must pay initially and after each subsequent subscription period to be a member of the chat; 1-2500"""
name: Optional[str] = None
"""Invite link name; 0-32 characters"""
if TYPE_CHECKING:
# DO NOT EDIT MANUALLY!!!
# This section was auto-generated via `butcher`
def __init__(
__pydantic__self__,
*,
chat_id: Union[int, str],
subscription_period: Union[datetime.datetime, datetime.timedelta, int],
subscription_price: int,
name: 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,
subscription_period=subscription_period,
subscription_price=subscription_price,
name=name,
**__pydantic_kwargs,
)

View file

@ -0,0 +1,44 @@
from __future__ import annotations
from typing import TYPE_CHECKING, Any, Optional, Union
from ..types import ChatInviteLink
from .base import TelegramMethod
class EditChatSubscriptionInviteLink(TelegramMethod[ChatInviteLink]):
"""
Use this method to edit a subscription invite link created by the bot. The bot must have the *can_invite_users* administrator rights. Returns the edited invite link as a :class:`aiogram.types.chat_invite_link.ChatInviteLink` object.
Source: https://core.telegram.org/bots/api#editchatsubscriptioninvitelink
"""
__returning__ = ChatInviteLink
__api_method__ = "editChatSubscriptionInviteLink"
chat_id: Union[int, str]
"""Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)"""
invite_link: str
"""The invite link to edit"""
name: Optional[str] = None
"""Invite link name; 0-32 characters"""
if TYPE_CHECKING:
# DO NOT EDIT MANUALLY!!!
# This section was auto-generated via `butcher`
def __init__(
__pydantic__self__,
*,
chat_id: Union[int, str],
invite_link: str,
name: 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, invite_link=invite_link, name=name, **__pydantic_kwargs
)

View file

@ -7,7 +7,7 @@ from .base import TelegramMethod
class EditForumTopic(TelegramMethod[bool]):
"""
Use this method to edit name and icon of a topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have *can_manage_topics* administrator rights, unless it is the creator of the topic. Returns :code:`True` on success.
Use this method to edit name and icon of a topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the *can_manage_topics* administrator rights, unless it is the creator of the topic. Returns :code:`True` on success.
Source: https://core.telegram.org/bots/api#editforumtopic
"""

View file

@ -7,7 +7,7 @@ from .base import TelegramMethod
class EditGeneralForumTopic(TelegramMethod[bool]):
"""
Use this method to edit the name of the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have *can_manage_topics* administrator rights. Returns :code:`True` on success.
Use this method to edit the name of the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the *can_manage_topics* administrator rights. Returns :code:`True` on success.
Source: https://core.telegram.org/bots/api#editgeneralforumtopic
"""

View file

@ -18,7 +18,7 @@ from .base import TelegramMethod
class SendPaidMedia(TelegramMethod[Message]):
"""
Use this method to send paid media to channel chats. On success, the sent :class:`aiogram.types.message.Message` is returned.
Use this method to send paid media. On success, the sent :class:`aiogram.types.message.Message` is returned.
Source: https://core.telegram.org/bots/api#sendpaidmedia
"""
@ -27,11 +27,13 @@ class SendPaidMedia(TelegramMethod[Message]):
__api_method__ = "sendPaidMedia"
chat_id: Union[int, str]
"""Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)"""
"""Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`). If the chat is a channel, all Telegram Star proceeds from this media will be credited to the chat's balance. Otherwise, they will be credited to the bot's balance."""
star_count: int
"""The number of Telegram Stars that must be paid to buy access to the media"""
media: List[Union[InputPaidMediaPhoto, InputPaidMediaVideo]]
"""A JSON-serialized array describing the media to be sent; up to 10 items"""
business_connection_id: Optional[str] = None
"""Unique identifier of the business connection on behalf of which the message will be sent"""
caption: Optional[str] = None
"""Media caption, 0-1024 characters after entities parsing"""
parse_mode: Optional[str] = None
@ -61,6 +63,7 @@ class SendPaidMedia(TelegramMethod[Message]):
chat_id: Union[int, str],
star_count: int,
media: List[Union[InputPaidMediaPhoto, InputPaidMediaVideo]],
business_connection_id: Optional[str] = None,
caption: Optional[str] = None,
parse_mode: Optional[str] = None,
caption_entities: Optional[List[MessageEntity]] = None,
@ -81,6 +84,7 @@ class SendPaidMedia(TelegramMethod[Message]):
chat_id=chat_id,
star_count=star_count,
media=media,
business_connection_id=business_connection_id,
caption=caption,
parse_mode=parse_mode,
caption_entities=caption_entities,

View file

@ -1,12 +1,12 @@
from typing import TYPE_CHECKING, Any, List, Optional, Union
from ..types import ReactionTypeCustomEmoji, ReactionTypeEmoji
from ..types import ReactionTypeCustomEmoji, ReactionTypeEmoji, ReactionTypePaid
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. Returns :code:`True` on success.
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.
Source: https://core.telegram.org/bots/api#setmessagereaction
"""
@ -18,8 +18,10 @@ class SetMessageReaction(TelegramMethod[bool]):
"""Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)"""
message_id: int
"""Identifier of the target message. If the message belongs to a media group, the reaction is set to the first non-deleted message in the group instead."""
reaction: Optional[List[Union[ReactionTypeEmoji, ReactionTypeCustomEmoji]]] = None
"""A JSON-serialized list of reaction types to set on the message. Currently, as non-premium users, bots can set up to one reaction per message. A custom emoji reaction can be used if it is either already present on the message or explicitly allowed by chat administrators."""
reaction: Optional[
List[Union[ReactionTypeEmoji, ReactionTypeCustomEmoji, ReactionTypePaid]]
] = None
"""A JSON-serialized list of reaction types to set on the message. Currently, as non-premium users, bots can set up to one reaction per message. A custom emoji reaction can be used if it is either already present on the message or explicitly allowed by chat administrators. Paid reactions can't be used by bots."""
is_big: Optional[bool] = None
"""Pass :code:`True` to set the reaction with a big animation"""
@ -32,7 +34,9 @@ class SetMessageReaction(TelegramMethod[bool]):
*,
chat_id: Union[int, str],
message_id: int,
reaction: Optional[List[Union[ReactionTypeEmoji, ReactionTypeCustomEmoji]]] = None,
reaction: Optional[
List[Union[ReactionTypeEmoji, ReactionTypeCustomEmoji, ReactionTypePaid]]
] = None,
is_big: Optional[bool] = None,
**__pydantic_kwargs: Any,
) -> None:

View file

@ -187,6 +187,7 @@ from .reaction_count import ReactionCount
from .reaction_type import ReactionType
from .reaction_type_custom_emoji import ReactionTypeCustomEmoji
from .reaction_type_emoji import ReactionTypeEmoji
from .reaction_type_paid import ReactionTypePaid
from .refunded_payment import RefundedPayment
from .reply_keyboard_markup import ReplyKeyboardMarkup
from .reply_keyboard_remove import ReplyKeyboardRemove
@ -419,6 +420,7 @@ __all__ = (
"ReactionType",
"ReactionTypeCustomEmoji",
"ReactionTypeEmoji",
"ReactionTypePaid",
"RefundedPayment",
"ReplyKeyboardMarkup",
"ReplyKeyboardRemove",

View file

@ -50,6 +50,7 @@ if TYPE_CHECKING:
from .message import Message
from .reaction_type_custom_emoji import ReactionTypeCustomEmoji
from .reaction_type_emoji import ReactionTypeEmoji
from .reaction_type_paid import ReactionTypePaid
class Chat(TelegramObject):
@ -83,9 +84,9 @@ class Chat(TelegramObject):
.. deprecated:: API:7.3
https://core.telegram.org/bots/api-changelog#may-6-2024"""
available_reactions: Optional[List[Union[ReactionTypeEmoji, ReactionTypeCustomEmoji]]] = Field(
None, json_schema_extra={"deprecated": True}
)
available_reactions: Optional[
List[Union[ReactionTypeEmoji, ReactionTypeCustomEmoji, ReactionTypePaid]]
] = Field(None, json_schema_extra={"deprecated": True})
"""*Optional*. List of available reactions allowed in the chat. If omitted, then all `emoji reactions <https://core.telegram.org/bots/api#reactiontypeemoji>`_ are allowed. Returned only in :class:`aiogram.methods.get_chat.GetChat`.
.. deprecated:: API:7.3
@ -284,7 +285,7 @@ class Chat(TelegramObject):
accent_color_id: Optional[int] = None,
active_usernames: Optional[List[str]] = None,
available_reactions: Optional[
List[Union[ReactionTypeEmoji, ReactionTypeCustomEmoji]]
List[Union[ReactionTypeEmoji, ReactionTypeCustomEmoji, ReactionTypePaid]]
] = None,
background_custom_emoji_id: Optional[str] = None,
bio: Optional[str] = None,

View file

@ -16,6 +16,7 @@ if TYPE_CHECKING:
from .message import Message
from .reaction_type_custom_emoji import ReactionTypeCustomEmoji
from .reaction_type_emoji import ReactionTypeEmoji
from .reaction_type_paid import ReactionTypePaid
class ChatFullInfo(Chat):
@ -57,7 +58,9 @@ class ChatFullInfo(Chat):
"""*Optional*. For private chats with business accounts, the opening hours of the business"""
personal_chat: Optional[Chat] = None
"""*Optional*. For private chats, the personal channel of the user"""
available_reactions: Optional[List[Union[ReactionTypeEmoji, ReactionTypeCustomEmoji]]] = None
available_reactions: Optional[
List[Union[ReactionTypeEmoji, ReactionTypeCustomEmoji, ReactionTypePaid]]
] = None
"""*Optional*. List of available reactions allowed in the chat. If omitted, then all `emoji reactions <https://core.telegram.org/bots/api#reactiontypeemoji>`_ are allowed."""
background_custom_emoji_id: Optional[str] = None
"""*Optional*. Custom emoji identifier of the emoji chosen by the chat for the reply header and link preview background"""
@ -138,7 +141,7 @@ class ChatFullInfo(Chat):
business_opening_hours: Optional[BusinessOpeningHours] = None,
personal_chat: Optional[Chat] = None,
available_reactions: Optional[
List[Union[ReactionTypeEmoji, ReactionTypeCustomEmoji]]
List[Union[ReactionTypeEmoji, ReactionTypeCustomEmoji, ReactionTypePaid]]
] = None,
background_custom_emoji_id: Optional[str] = None,
profile_accent_color_id: Optional[int] = None,

View file

@ -1,9 +1,10 @@
from __future__ import annotations
from typing import TYPE_CHECKING, Any, Literal
from typing import TYPE_CHECKING, Any, Literal, Optional
from ..enums import ChatMemberStatus
from .chat_member import ChatMember
from .custom import DateTime
if TYPE_CHECKING:
from .user import User
@ -20,6 +21,8 @@ class ChatMemberMember(ChatMember):
"""The member's status in the chat, always 'member'"""
user: User
"""Information about the user"""
until_date: Optional[DateTime] = None
"""*Optional*. Date when the user's subscription will expire; Unix time"""
if TYPE_CHECKING:
# DO NOT EDIT MANUALLY!!!
@ -30,10 +33,11 @@ class ChatMemberMember(ChatMember):
*,
status: Literal[ChatMemberStatus.MEMBER] = ChatMemberStatus.MEMBER,
user: User,
until_date: Optional[DateTime] = 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__(status=status, user=user, **__pydantic_kwargs)
super().__init__(status=status, user=user, until_date=until_date, **__pydantic_kwargs)

View file

@ -100,6 +100,7 @@ if TYPE_CHECKING:
from .proximity_alert_triggered import ProximityAlertTriggered
from .reaction_type_custom_emoji import ReactionTypeCustomEmoji
from .reaction_type_emoji import ReactionTypeEmoji
from .reaction_type_paid import ReactionTypePaid
from .refunded_payment import RefundedPayment
from .reply_keyboard_markup import ReplyKeyboardMarkup
from .reply_keyboard_remove import ReplyKeyboardRemove
@ -138,9 +139,9 @@ class Message(MaybeInaccessibleMessage):
message_thread_id: Optional[int] = None
"""*Optional*. Unique identifier of a message thread to which the message belongs; for supergroups only"""
from_user: Optional[User] = Field(None, alias="from")
"""*Optional*. Sender of the message; empty for messages sent to channels. For backward compatibility, the field contains a fake sender user in non-channel chats, if the message was sent on behalf of a chat."""
"""*Optional*. Sender of the message; may be empty for messages sent to channels. For backward compatibility, if the message was sent on behalf of a chat, the field contains a fake sender user in non-channel chats"""
sender_chat: Optional[Chat] = None
"""*Optional*. Sender of the message, sent on behalf of a chat. For example, the channel itself for channel posts, the supergroup itself for messages from anonymous group administrators, the linked channel for messages automatically forwarded to the discussion group. For backward compatibility, the field *from* contains a fake sender user in non-channel chats, if the message was sent on behalf of a chat."""
"""*Optional*. Sender of the message when sent on behalf of a chat. For example, the supergroup itself for messages sent by its anonymous administrators or a linked channel for messages automatically forwarded to the channel's discussion group. For backward compatibility, if the message was sent on behalf of a chat, the field *from* contains a fake sender user in non-channel chats."""
sender_boost_count: Optional[int] = None
"""*Optional*. If the sender of the message boosted the chat, the number of boosts added by the user"""
sender_business_bot: Optional[User] = None
@ -4058,7 +4059,9 @@ class Message(MaybeInaccessibleMessage):
def react(
self,
reaction: Optional[List[Union[ReactionTypeEmoji, ReactionTypeCustomEmoji]]] = None,
reaction: Optional[
List[Union[ReactionTypeEmoji, ReactionTypeCustomEmoji, ReactionTypePaid]]
] = None,
is_big: Optional[bool] = None,
**kwargs: Any,
) -> SetMessageReaction:
@ -4069,11 +4072,11 @@ class Message(MaybeInaccessibleMessage):
- :code:`chat_id`
- :code:`message_id`
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. Returns :code:`True` on success.
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.
Source: https://core.telegram.org/bots/api#setmessagereaction
:param reaction: A JSON-serialized list of reaction types to set on the message. Currently, as non-premium users, bots can set up to one reaction per message. A custom emoji reaction can be used if it is either already present on the message or explicitly allowed by chat administrators.
:param reaction: A JSON-serialized list of reaction types to set on the message. Currently, as non-premium users, bots can set up to one reaction per message. A custom emoji reaction can be used if it is either already present on the message or explicitly allowed by chat administrators. Paid reactions can't be used by bots.
:param is_big: Pass :code:`True` to set the reaction with a big animation
:return: instance of method :class:`aiogram.methods.set_message_reaction.SetMessageReaction`
"""
@ -4118,7 +4121,7 @@ class Message(MaybeInaccessibleMessage):
- :code:`message_thread_id`
- :code:`business_connection_id`
Use this method to send paid media to channel chats. On success, the sent :class:`aiogram.types.message.Message` is returned.
Use this method to send paid media. On success, the sent :class:`aiogram.types.message.Message` is returned.
Source: https://core.telegram.org/bots/api#sendpaidmedia
@ -4184,7 +4187,7 @@ class Message(MaybeInaccessibleMessage):
- :code:`business_connection_id`
- :code:`reply_parameters`
Use this method to send paid media to channel chats. On success, the sent :class:`aiogram.types.message.Message` is returned.
Use this method to send paid media. On success, the sent :class:`aiogram.types.message.Message` is returned.
Source: https://core.telegram.org/bots/api#sendpaidmedia

View file

@ -9,6 +9,7 @@ if TYPE_CHECKING:
from .custom import DateTime
from .reaction_type_custom_emoji import ReactionTypeCustomEmoji
from .reaction_type_emoji import ReactionTypeEmoji
from .reaction_type_paid import ReactionTypePaid
from .user import User
@ -25,9 +26,9 @@ class MessageReactionUpdated(TelegramObject):
"""Unique identifier of the message inside the chat"""
date: DateTime
"""Date of the change in Unix time"""
old_reaction: List[Union[ReactionTypeEmoji, ReactionTypeCustomEmoji]]
old_reaction: List[Union[ReactionTypeEmoji, ReactionTypeCustomEmoji, ReactionTypePaid]]
"""Previous list of reaction types that were set by the user"""
new_reaction: List[Union[ReactionTypeEmoji, ReactionTypeCustomEmoji]]
new_reaction: List[Union[ReactionTypeEmoji, ReactionTypeCustomEmoji, ReactionTypePaid]]
"""New list of reaction types that have been set by the user"""
user: Optional[User] = None
"""*Optional*. The user that changed the reaction, if the user isn't anonymous"""
@ -44,8 +45,12 @@ class MessageReactionUpdated(TelegramObject):
chat: Chat,
message_id: int,
date: DateTime,
old_reaction: List[Union[ReactionTypeEmoji, ReactionTypeCustomEmoji]],
new_reaction: List[Union[ReactionTypeEmoji, ReactionTypeCustomEmoji]],
old_reaction: List[
Union[ReactionTypeEmoji, ReactionTypeCustomEmoji, ReactionTypePaid]
],
new_reaction: List[
Union[ReactionTypeEmoji, ReactionTypeCustomEmoji, ReactionTypePaid]
],
user: Optional[User] = None,
actor_chat: Optional[Chat] = None,
**__pydantic_kwargs: Any,

View file

@ -7,6 +7,7 @@ from .base import TelegramObject
if TYPE_CHECKING:
from .reaction_type_custom_emoji import ReactionTypeCustomEmoji
from .reaction_type_emoji import ReactionTypeEmoji
from .reaction_type_paid import ReactionTypePaid
class ReactionCount(TelegramObject):
@ -16,7 +17,7 @@ class ReactionCount(TelegramObject):
Source: https://core.telegram.org/bots/api#reactioncount
"""
type: Union[ReactionTypeEmoji, ReactionTypeCustomEmoji]
type: Union[ReactionTypeEmoji, ReactionTypeCustomEmoji, ReactionTypePaid]
"""Type of the reaction"""
total_count: int
"""Number of times the reaction was added"""
@ -28,7 +29,7 @@ class ReactionCount(TelegramObject):
def __init__(
__pydantic__self__,
*,
type: Union[ReactionTypeEmoji, ReactionTypeCustomEmoji],
type: Union[ReactionTypeEmoji, ReactionTypeCustomEmoji, ReactionTypePaid],
total_count: int,
**__pydantic_kwargs: Any,
) -> None:

View file

@ -7,6 +7,7 @@ class ReactionType(TelegramObject):
- :class:`aiogram.types.reaction_type_emoji.ReactionTypeEmoji`
- :class:`aiogram.types.reaction_type_custom_emoji.ReactionTypeCustomEmoji`
- :class:`aiogram.types.reaction_type_paid.ReactionTypePaid`
Source: https://core.telegram.org/bots/api#reactiontype
"""

View file

@ -0,0 +1,28 @@
from typing import TYPE_CHECKING, Any, Literal
from ..enums import ReactionTypeType
from .reaction_type import ReactionType
class ReactionTypePaid(ReactionType):
"""
The reaction is paid.
Source: https://core.telegram.org/bots/api#reactiontypepaid
"""
type: Literal["paid"] = "paid"
"""Type of the reaction, always 'paid'"""
if TYPE_CHECKING:
# DO NOT EDIT MANUALLY!!!
# This section was auto-generated via `butcher`
def __init__(
__pydantic__self__, *, type: Literal["paid"] = "paid", **__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__(type=type, **__pydantic_kwargs)

View file

@ -1,11 +1,14 @@
from __future__ import annotations
from typing import TYPE_CHECKING, Any, Literal, Optional
from typing import TYPE_CHECKING, Any, List, Literal, Optional, Union
from ..enums import TransactionPartnerType
from .transaction_partner import TransactionPartner
if TYPE_CHECKING:
from .paid_media_photo import PaidMediaPhoto
from .paid_media_preview import PaidMediaPreview
from .paid_media_video import PaidMediaVideo
from .user import User
@ -22,6 +25,8 @@ class TransactionPartnerUser(TransactionPartner):
"""Information about the user"""
invoice_payload: Optional[str] = None
"""*Optional*. Bot-specified invoice payload"""
paid_media: Optional[List[Union[PaidMediaPreview, PaidMediaPhoto, PaidMediaVideo]]] = None
"""*Optional*. Information about the paid media bought by the user"""
if TYPE_CHECKING:
# DO NOT EDIT MANUALLY!!!
@ -33,6 +38,9 @@ class TransactionPartnerUser(TransactionPartner):
type: Literal[TransactionPartnerType.USER] = TransactionPartnerType.USER,
user: User,
invoice_payload: Optional[str] = None,
paid_media: Optional[
List[Union[PaidMediaPreview, PaidMediaPhoto, PaidMediaVideo]]
] = None,
**__pydantic_kwargs: Any,
) -> None:
# DO NOT EDIT MANUALLY!!!
@ -40,5 +48,9 @@ class TransactionPartnerUser(TransactionPartner):
# Is needed only for type checking and IDE support without any additional plugins
super().__init__(
type=type, user=user, invoice_payload=invoice_payload, **__pydantic_kwargs
type=type,
user=user,
invoice_payload=invoice_payload,
paid_media=paid_media,
**__pydantic_kwargs,
)