Added full support of Bot API 7.6

This commit is contained in:
JRoot Junior 2024-07-01 21:12:29 +03:00
parent 3baa7383c1
commit ad771ce495
No known key found for this signature in database
GPG key ID: 738964250D5FF6E2
90 changed files with 1840 additions and 270 deletions

View file

@ -123,6 +123,9 @@ from .input_media_document import InputMediaDocument
from .input_media_photo import InputMediaPhoto
from .input_media_video import InputMediaVideo
from .input_message_content import InputMessageContent
from .input_paid_media import InputPaidMedia
from .input_paid_media_photo import InputPaidMediaPhoto
from .input_paid_media_video import InputPaidMediaVideo
from .input_poll_option import InputPollOption
from .input_sticker import InputSticker
from .input_text_message_content import InputTextMessageContent
@ -155,6 +158,11 @@ from .message_origin_user import MessageOriginUser
from .message_reaction_count_updated import MessageReactionCountUpdated
from .message_reaction_updated import MessageReactionUpdated
from .order_info import OrderInfo
from .paid_media import PaidMedia
from .paid_media_info import PaidMediaInfo
from .paid_media_photo import PaidMediaPhoto
from .paid_media_preview import PaidMediaPreview
from .paid_media_video import PaidMediaVideo
from .passport_data import PassportData
from .passport_element_error import PassportElementError
from .passport_element_error_data_field import PassportElementErrorDataField
@ -203,6 +211,7 @@ from .text_quote import TextQuote
from .transaction_partner import TransactionPartner
from .transaction_partner_fragment import TransactionPartnerFragment
from .transaction_partner_other import TransactionPartnerOther
from .transaction_partner_telegram_ads import TransactionPartnerTelegramAds
from .transaction_partner_user import TransactionPartnerUser
from .update import Update
from .user import User
@ -347,6 +356,9 @@ __all__ = (
"InputMediaPhoto",
"InputMediaVideo",
"InputMessageContent",
"InputPaidMedia",
"InputPaidMediaPhoto",
"InputPaidMediaVideo",
"InputPollOption",
"InputSticker",
"InputTextMessageContent",
@ -379,6 +391,11 @@ __all__ = (
"MessageReactionCountUpdated",
"MessageReactionUpdated",
"OrderInfo",
"PaidMedia",
"PaidMediaInfo",
"PaidMediaPhoto",
"PaidMediaPreview",
"PaidMediaVideo",
"PassportData",
"PassportElementError",
"PassportElementErrorDataField",
@ -426,6 +443,7 @@ __all__ = (
"TransactionPartner",
"TransactionPartnerFragment",
"TransactionPartnerOther",
"TransactionPartnerTelegramAds",
"TransactionPartnerUser",
"UNSET_PARSE_MODE",
"URLInputFile",

View file

@ -20,17 +20,17 @@ class Animation(TelegramObject):
file_unique_id: str
"""Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file."""
width: int
"""Video width as defined by sender"""
"""Video width as defined by the sender"""
height: int
"""Video height as defined by sender"""
"""Video height as defined by the sender"""
duration: int
"""Duration of the video in seconds as defined by sender"""
"""Duration of the video in seconds as defined by the sender"""
thumbnail: Optional[PhotoSize] = None
"""*Optional*. Animation thumbnail as defined by sender"""
"""*Optional*. Animation thumbnail as defined by the sender"""
file_name: Optional[str] = None
"""*Optional*. Original animation filename as defined by sender"""
"""*Optional*. Original animation filename as defined by the sender"""
mime_type: Optional[str] = None
"""*Optional*. MIME type of the file as defined by sender"""
"""*Optional*. MIME type of the file as defined by the sender"""
file_size: Optional[int] = None
"""*Optional*. File size in bytes. It can be bigger than 2^31 and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this value."""

View file

@ -20,15 +20,15 @@ class Audio(TelegramObject):
file_unique_id: str
"""Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file."""
duration: int
"""Duration of the audio in seconds as defined by sender"""
"""Duration of the audio in seconds as defined by the sender"""
performer: Optional[str] = None
"""*Optional*. Performer of the audio as defined by sender or by audio tags"""
"""*Optional*. Performer of the audio as defined by the sender or by audio tags"""
title: Optional[str] = None
"""*Optional*. Title of the audio as defined by sender or by audio tags"""
"""*Optional*. Title of the audio as defined by the sender or by audio tags"""
file_name: Optional[str] = None
"""*Optional*. Original filename as defined by sender"""
"""*Optional*. Original filename as defined by the sender"""
mime_type: Optional[str] = None
"""*Optional*. MIME type of the file as defined by sender"""
"""*Optional*. MIME type of the file as defined by the sender"""
file_size: Optional[int] = None
"""*Optional*. File size in bytes. It can be bigger than 2^31 and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this value."""
thumbnail: Optional[PhotoSize] = None

View file

@ -87,6 +87,8 @@ class ChatFullInfo(Chat):
"""*Optional*. The most recent pinned message (by sending date)"""
permissions: Optional[ChatPermissions] = None
"""*Optional*. Default chat member permissions, for groups and supergroups"""
can_send_paid_media: Optional[bool] = None
"""*Optional*. :code:`True`, if paid media messages can be sent or forwarded to the channel chat. The field is available only for channel chats."""
slow_mode_delay: Optional[int] = None
"""*Optional*. For supergroups, the minimum allowed delay between consecutive messages sent by each unprivileged user; in seconds"""
unrestrict_boost_count: Optional[int] = None
@ -152,6 +154,7 @@ class ChatFullInfo(Chat):
invite_link: Optional[str] = None,
pinned_message: Optional[Message] = None,
permissions: Optional[ChatPermissions] = None,
can_send_paid_media: Optional[bool] = None,
slow_mode_delay: Optional[int] = None,
unrestrict_boost_count: Optional[int] = None,
message_auto_delete_time: Optional[int] = None,
@ -202,6 +205,7 @@ class ChatFullInfo(Chat):
invite_link=invite_link,
pinned_message=pinned_message,
permissions=permissions,
can_send_paid_media=can_send_paid_media,
slow_mode_delay=slow_mode_delay,
unrestrict_boost_count=unrestrict_boost_count,
message_auto_delete_time=message_auto_delete_time,

View file

@ -1,7 +1,6 @@
import sys
from datetime import datetime
from datetime import datetime, timezone
from datetime import timezone
from pydantic import PlainSerializer
from typing_extensions import Annotated

View file

@ -20,11 +20,11 @@ class Document(TelegramObject):
file_unique_id: str
"""Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file."""
thumbnail: Optional[PhotoSize] = None
"""*Optional*. Document thumbnail as defined by sender"""
"""*Optional*. Document thumbnail as defined by the sender"""
file_name: Optional[str] = None
"""*Optional*. Original filename as defined by sender"""
"""*Optional*. Original filename as defined by the sender"""
mime_type: Optional[str] = None
"""*Optional*. MIME type of the file as defined by sender"""
"""*Optional*. MIME type of the file as defined by the sender"""
file_size: Optional[int] = None
"""*Optional*. File size in bytes. It can be bigger than 2^31 and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this value."""

View file

@ -5,6 +5,7 @@ from typing import TYPE_CHECKING, Any, List, Optional, Union
from .base import TelegramObject
if TYPE_CHECKING:
from .paid_media_info import PaidMediaInfo
from .animation import Animation
from .audio import Audio
from .chat import Chat
@ -54,6 +55,8 @@ class ExternalReplyInfo(TelegramObject):
"""*Optional*. Message is an audio file, information about the file"""
document: Optional[Document] = None
"""*Optional*. Message is a general file, information about the file"""
paid_media: Optional[PaidMediaInfo] = None
"""*Optional*. Message contains paid media; information about the paid media"""
photo: Optional[List[PhotoSize]] = None
"""*Optional*. Message is a photo, available sizes of the photo"""
sticker: Optional[Sticker] = None
@ -103,6 +106,7 @@ class ExternalReplyInfo(TelegramObject):
animation: Optional[Animation] = None,
audio: Optional[Audio] = None,
document: Optional[Document] = None,
paid_media: Optional[PaidMediaInfo] = None,
photo: Optional[List[PhotoSize]] = None,
sticker: Optional[Sticker] = None,
story: Optional[Story] = None,
@ -133,6 +137,7 @@ class ExternalReplyInfo(TelegramObject):
animation=animation,
audio=audio,
document=document,
paid_media=paid_media,
photo=photo,
sticker=sticker,
story=story,

View file

@ -0,0 +1,12 @@
from .base import TelegramObject
class InputPaidMedia(TelegramObject):
"""
This object describes the paid media to be sent. Currently, it can be one of
- :class:`aiogram.types.input_paid_media_photo.InputPaidMediaPhoto`
- :class:`aiogram.types.input_paid_media_video.InputPaidMediaVideo`
Source: https://core.telegram.org/bots/api#inputpaidmedia
"""

View file

@ -0,0 +1,36 @@
from __future__ import annotations
from typing import TYPE_CHECKING, Any, Literal
from ..enums import InputPaidMediaType
from .input_paid_media import InputPaidMedia
class InputPaidMediaPhoto(InputPaidMedia):
"""
The paid media to send is a photo.
Source: https://core.telegram.org/bots/api#inputpaidmediaphoto
"""
type: Literal[InputPaidMediaType.PHOTO] = InputPaidMediaType.PHOTO
"""Type of the media, must be *photo*"""
media: str
"""File to send. 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>`"""
if TYPE_CHECKING:
# DO NOT EDIT MANUALLY!!!
# This section was auto-generated via `butcher`
def __init__(
__pydantic__self__,
*,
type: Literal[InputPaidMediaType.PHOTO] = InputPaidMediaType.PHOTO,
media: 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__(type=type, media=media, **__pydantic_kwargs)

View file

@ -0,0 +1,61 @@
from __future__ import annotations
from typing import TYPE_CHECKING, Any, Literal, Optional, Union
from ..enums import InputPaidMediaType
from .input_file import InputFile
from .input_paid_media import InputPaidMedia
class InputPaidMediaVideo(InputPaidMedia):
"""
The paid media to send is a video.
Source: https://core.telegram.org/bots/api#inputpaidmediavideo
"""
type: Literal[InputPaidMediaType.VIDEO] = InputPaidMediaType.VIDEO
"""Type of the media, must be *video*"""
media: str
"""File to send. 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>`"""
thumbnail: Optional[Union[InputFile, str]] = None
"""*Optional*. 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>`"""
width: Optional[int] = None
"""*Optional*. Video width"""
height: Optional[int] = None
"""*Optional*. Video height"""
duration: Optional[int] = None
"""*Optional*. Video duration in seconds"""
supports_streaming: Optional[bool] = None
"""*Optional*. Pass :code:`True` if the uploaded video is suitable for streaming"""
if TYPE_CHECKING:
# DO NOT EDIT MANUALLY!!!
# This section was auto-generated via `butcher`
def __init__(
__pydantic__self__,
*,
type: Literal[InputPaidMediaType.VIDEO] = InputPaidMediaType.VIDEO,
media: str,
thumbnail: Optional[Union[InputFile, str]] = None,
width: Optional[int] = None,
height: Optional[int] = None,
duration: Optional[int] = None,
supports_streaming: Optional[bool] = 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__(
type=type,
media=media,
thumbnail=thumbnail,
width=width,
height=height,
duration=duration,
supports_streaming=supports_streaming,
**__pydantic_kwargs,
)

View file

@ -11,7 +11,7 @@ if TYPE_CHECKING:
class InputPollOption(TelegramObject):
"""
This object contains information about one answer option in a poll to send.
This object contains information about one answer option in a poll to be sent.
Source: https://core.telegram.org/bots/api#inputpolloption
"""

View file

@ -13,9 +13,9 @@ class Location(TelegramObject):
"""
latitude: float
"""Latitude as defined by sender"""
"""Latitude as defined by the sender"""
longitude: float
"""Longitude as defined by sender"""
"""Longitude as defined by the sender"""
horizontal_accuracy: Optional[float] = None
"""*Optional*. The radius of uncertainty for the location, measured in meters; 0-1500"""
live_period: Optional[int] = None

View file

@ -26,7 +26,7 @@ class MenuButton(MutableTelegramObject):
text: Optional[str] = None
"""*Optional*. Text on the button"""
web_app: Optional[WebAppInfo] = None
"""*Optional*. Description of the Web App that will be launched when the user presses the button. The Web App will be able to send an arbitrary message on behalf of the user using the method :class:`aiogram.methods.answer_web_app_query.AnswerWebAppQuery`."""
"""*Optional*. Description of the Web App that will be launched when the user presses the button. The Web App will be able to send an arbitrary message on behalf of the user using the method :class:`aiogram.methods.answer_web_app_query.AnswerWebAppQuery`. Alternatively, a :code:`t.me` link to a Web App of the bot can be specified in the object instead of the Web App's URL, in which case the Web App will be opened as if the user pressed the link."""
if TYPE_CHECKING:
# DO NOT EDIT MANUALLY!!!

View file

@ -21,7 +21,7 @@ class MenuButtonWebApp(MenuButton):
text: str
"""Text on the button"""
web_app: WebAppInfo
"""Description of the Web App that will be launched when the user presses the button. The Web App will be able to send an arbitrary message on behalf of the user using the method :class:`aiogram.methods.answer_web_app_query.AnswerWebAppQuery`."""
"""Description of the Web App that will be launched when the user presses the button. The Web App will be able to send an arbitrary message on behalf of the user using the method :class:`aiogram.methods.answer_web_app_query.AnswerWebAppQuery`. Alternatively, a :code:`t.me` link to a Web App of the bot can be specified in the object instead of the Web App's URL, in which case the Web App will be opened as if the user pressed the link."""
if TYPE_CHECKING:
# DO NOT EDIT MANUALLY!!!

View file

@ -14,8 +14,6 @@ from aiogram.utils.text_decorations import (
from ..client.default import Default
from ..enums import ContentType
from .custom import DateTime
from .input_poll_option import InputPollOption
from .maybe_inaccessible_message import MaybeInaccessibleMessage
if TYPE_CHECKING:
from ..methods import (
@ -79,16 +77,19 @@ if TYPE_CHECKING:
from .input_media_document import InputMediaDocument
from .input_media_photo import InputMediaPhoto
from .input_media_video import InputMediaVideo
from .input_poll_option import InputPollOption
from .invoice import Invoice
from .labeled_price import LabeledPrice
from .link_preview_options import LinkPreviewOptions
from .location import Location
from .maybe_inaccessible_message import MaybeInaccessibleMessage
from .message_auto_delete_timer_changed import MessageAutoDeleteTimerChanged
from .message_entity import MessageEntity
from .message_origin_channel import MessageOriginChannel
from .message_origin_chat import MessageOriginChat
from .message_origin_hidden_user import MessageOriginHiddenUser
from .message_origin_user import MessageOriginUser
from .paid_media_info import PaidMediaInfo
from .passport_data import PassportData
from .photo_size import PhotoSize
from .poll import Poll
@ -184,6 +185,8 @@ class Message(MaybeInaccessibleMessage):
"""*Optional*. Message is an audio file, information about the file"""
document: Optional[Document] = None
"""*Optional*. Message is a general file, information about the file"""
paid_media: Optional[PaidMediaInfo] = None
"""*Optional*. Message contains paid media; information about the paid media"""
photo: Optional[List[PhotoSize]] = None
"""*Optional*. Message is a photo, available sizes of the photo"""
sticker: Optional[Sticker] = None
@ -197,7 +200,7 @@ class Message(MaybeInaccessibleMessage):
voice: Optional[Voice] = None
"""*Optional*. Message is a voice message, information about the file"""
caption: Optional[str] = None
"""*Optional*. Caption for the animation, audio, document, photo, video or voice"""
"""*Optional*. Caption for the animation, audio, document, paid media, photo, video or voice"""
caption_entities: Optional[List[MessageEntity]] = None
"""*Optional*. For messages with a caption, special entities like usernames, URLs, bot commands, etc. that appear in the caption"""
show_caption_above_media: Optional[bool] = None
@ -371,6 +374,7 @@ class Message(MaybeInaccessibleMessage):
animation: Optional[Animation] = None,
audio: Optional[Audio] = None,
document: Optional[Document] = None,
paid_media: Optional[PaidMediaInfo] = None,
photo: Optional[List[PhotoSize]] = None,
sticker: Optional[Sticker] = None,
story: Optional[Story] = None,
@ -468,6 +472,7 @@ class Message(MaybeInaccessibleMessage):
animation=animation,
audio=audio,
document=document,
paid_media=paid_media,
photo=photo,
sticker=sticker,
story=story,
@ -3483,7 +3488,7 @@ class Message(MaybeInaccessibleMessage):
- :code:`from_chat_id`
- :code:`message_id`
Use this method to copy messages of any kind. Service messages, giveaway messages, giveaway winners messages, and invoice messages can't be copied. A quiz :class:`aiogram.methods.poll.Poll` can be copied only if the value of the field *correct_option_id* is known to the bot. The method is analogous to the method :class:`aiogram.methods.forward_message.ForwardMessage`, but the copied message doesn't have a link to the original message. Returns the :class:`aiogram.types.message_id.MessageId` of the sent message on success.
Use this method to copy messages of any kind. Service messages, paid media messages, giveaway messages, giveaway winners messages, and invoice messages can't be copied. A quiz :class:`aiogram.methods.poll.Poll` can be copied only if the value of the field *correct_option_id* is known to the bot. The method is analogous to the method :class:`aiogram.methods.forward_message.ForwardMessage`, but the copied message doesn't have a link to the original message. Returns the :class:`aiogram.types.message_id.MessageId` of the sent message on success.
Source: https://core.telegram.org/bots/api#copymessage

View file

@ -0,0 +1,13 @@
from .base import TelegramObject
class PaidMedia(TelegramObject):
"""
This object describes paid media. Currently, it can be one of
- :class:`aiogram.types.paid_media_preview.PaidMediaPreview`
- :class:`aiogram.types.paid_media_photo.PaidMediaPhoto`
- :class:`aiogram.types.paid_media_video.PaidMediaVideo`
Source: https://core.telegram.org/bots/api#paidmedia
"""

View file

@ -0,0 +1,40 @@
from __future__ import annotations
from typing import TYPE_CHECKING, Any, List, Union
from .base import TelegramObject
if TYPE_CHECKING:
from .paid_media_photo import PaidMediaPhoto
from .paid_media_preview import PaidMediaPreview
from .paid_media_video import PaidMediaVideo
class PaidMediaInfo(TelegramObject):
"""
Describes the paid media added to a message.
Source: https://core.telegram.org/bots/api#paidmediainfo
"""
star_count: int
"""The number of Telegram Stars that must be paid to buy access to the media"""
paid_media: List[Union[PaidMediaPreview, PaidMediaPhoto, PaidMediaVideo]]
"""Information about the paid media"""
if TYPE_CHECKING:
# DO NOT EDIT MANUALLY!!!
# This section was auto-generated via `butcher`
def __init__(
__pydantic__self__,
*,
star_count: int,
paid_media: List[Union[PaidMediaPreview, PaidMediaPhoto, PaidMediaVideo]],
**__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__(star_count=star_count, paid_media=paid_media, **__pydantic_kwargs)

View file

@ -0,0 +1,38 @@
from __future__ import annotations
from typing import TYPE_CHECKING, Any, List, Literal
from .paid_media import PaidMedia
if TYPE_CHECKING:
from .photo_size import PhotoSize
class PaidMediaPhoto(PaidMedia):
"""
The paid media is a photo.
Source: https://core.telegram.org/bots/api#paidmediaphoto
"""
type: Literal["photo"] = "photo"
"""Type of the paid media, always 'photo'"""
photo: List[PhotoSize]
"""The photo"""
if TYPE_CHECKING:
# DO NOT EDIT MANUALLY!!!
# This section was auto-generated via `butcher`
def __init__(
__pydantic__self__,
*,
type: Literal["photo"] = "photo",
photo: List[PhotoSize],
**__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, photo=photo, **__pydantic_kwargs)

View file

@ -0,0 +1,43 @@
from __future__ import annotations
from typing import TYPE_CHECKING, Any, Literal, Optional
from .paid_media import PaidMedia
class PaidMediaPreview(PaidMedia):
"""
The paid media isn't available before the payment.
Source: https://core.telegram.org/bots/api#paidmediapreview
"""
type: Literal["preview"] = "preview"
"""Type of the paid media, always 'preview'"""
width: Optional[int] = None
"""*Optional*. Media width as defined by the sender"""
height: Optional[int] = None
"""*Optional*. Media height as defined by the sender"""
duration: Optional[int] = None
"""*Optional*. Duration of the media in seconds as defined by the sender"""
if TYPE_CHECKING:
# DO NOT EDIT MANUALLY!!!
# This section was auto-generated via `butcher`
def __init__(
__pydantic__self__,
*,
type: Literal["preview"] = "preview",
width: Optional[int] = None,
height: Optional[int] = None,
duration: Optional[int] = 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__(
type=type, width=width, height=height, duration=duration, **__pydantic_kwargs
)

View file

@ -0,0 +1,38 @@
from __future__ import annotations
from typing import TYPE_CHECKING, Any, Literal
from .paid_media import PaidMedia
if TYPE_CHECKING:
from .video import Video
class PaidMediaVideo(PaidMedia):
"""
The paid media is a video.
Source: https://core.telegram.org/bots/api#paidmediavideo
"""
type: Literal["video"] = "video"
"""Type of the paid media, always 'video'"""
video: Video
"""The video"""
if TYPE_CHECKING:
# DO NOT EDIT MANUALLY!!!
# This section was auto-generated via `butcher`
def __init__(
__pydantic__self__,
*,
type: Literal["video"] = "video",
video: Video,
**__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, video=video, **__pydantic_kwargs)

View file

@ -28,7 +28,7 @@ class PreCheckoutQuery(TelegramObject):
total_amount: int
"""Total price in the *smallest units* of the currency (integer, **not** float/double). For example, for a price of :code:`US$ 1.45` pass :code:`amount = 145`. See the *exp* parameter in `currencies.json <https://core.telegram.org/bots/payments/currencies.json>`_, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies)."""
invoice_payload: str
"""Bot specified invoice payload"""
"""Bot-specified invoice payload"""
shipping_option_id: Optional[str] = None
"""*Optional*. Identifier of the shipping option chosen by the user"""
order_info: Optional[OrderInfo] = None

View file

@ -25,7 +25,7 @@ class ShippingQuery(TelegramObject):
from_user: User = Field(..., alias="from")
"""User who sent the query"""
invoice_payload: str
"""Bot specified invoice payload"""
"""Bot-specified invoice payload"""
shipping_address: ShippingAddress
"""User specified shipping address"""

View file

@ -2,6 +2,7 @@ from __future__ import annotations
from typing import TYPE_CHECKING, Any, Optional, Union
from . import TransactionPartnerTelegramAds
from .base import TelegramObject
from .custom import DateTime
@ -25,11 +26,21 @@ class StarTransaction(TelegramObject):
date: DateTime
"""Date the transaction was created in Unix time"""
source: Optional[
Union[TransactionPartnerFragment, TransactionPartnerUser, TransactionPartnerOther]
Union[
TransactionPartnerUser,
TransactionPartnerFragment,
TransactionPartnerTelegramAds,
TransactionPartnerOther,
]
] = None
"""*Optional*. Source of an incoming transaction (e.g., a user purchasing goods or services, Fragment refunding a failed withdrawal). Only for incoming transactions"""
receiver: Optional[
Union[TransactionPartnerFragment, TransactionPartnerUser, TransactionPartnerOther]
Union[
TransactionPartnerUser,
TransactionPartnerFragment,
TransactionPartnerTelegramAds,
TransactionPartnerOther,
]
] = None
"""*Optional*. Receiver of an outgoing transaction (e.g., a user for a purchase refund, Fragment for a withdrawal). Only for outgoing transactions"""
@ -44,10 +55,20 @@ class StarTransaction(TelegramObject):
amount: int,
date: DateTime,
source: Optional[
Union[TransactionPartnerFragment, TransactionPartnerUser, TransactionPartnerOther]
Union[
TransactionPartnerUser,
TransactionPartnerFragment,
TransactionPartnerTelegramAds,
TransactionPartnerOther,
]
] = None,
receiver: Optional[
Union[TransactionPartnerFragment, TransactionPartnerUser, TransactionPartnerOther]
Union[
TransactionPartnerUser,
TransactionPartnerFragment,
TransactionPartnerTelegramAds,
TransactionPartnerOther,
]
] = None,
**__pydantic_kwargs: Any,
) -> None:

View file

@ -20,7 +20,7 @@ class SuccessfulPayment(TelegramObject):
total_amount: int
"""Total price in the *smallest units* of the currency (integer, **not** float/double). For example, for a price of :code:`US$ 1.45` pass :code:`amount = 145`. See the *exp* parameter in `currencies.json <https://core.telegram.org/bots/payments/currencies.json>`_, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies)."""
invoice_payload: str
"""Bot specified invoice payload"""
"""Bot-specified invoice payload"""
telegram_payment_charge_id: str
"""Telegram payment identifier"""
provider_payment_charge_id: str

View file

@ -5,8 +5,9 @@ class TransactionPartner(TelegramObject):
"""
This object describes the source of a transaction, or its recipient for outgoing transactions. Currently, it can be one of
- :class:`aiogram.types.transaction_partner_fragment.TransactionPartnerFragment`
- :class:`aiogram.types.transaction_partner_user.TransactionPartnerUser`
- :class:`aiogram.types.transaction_partner_fragment.TransactionPartnerFragment`
- :class:`aiogram.types.transaction_partner_telegram_ads.TransactionPartnerTelegramAds`
- :class:`aiogram.types.transaction_partner_other.TransactionPartnerOther`
Source: https://core.telegram.org/bots/api#transactionpartner

View file

@ -0,0 +1,35 @@
from __future__ import annotations
from typing import TYPE_CHECKING, Any, Literal
from ..enums import TransactionPartnerType
from .transaction_partner import TransactionPartner
class TransactionPartnerTelegramAds(TransactionPartner):
"""
Describes a withdrawal transaction to the Telegram Ads platform.
Source: https://core.telegram.org/bots/api#transactionpartnertelegramads
"""
type: Literal[TransactionPartnerType.TELEGRAM_ADS] = TransactionPartnerType.TELEGRAM_ADS
"""Type of the transaction partner, always 'telegram_ads'"""
if TYPE_CHECKING:
# DO NOT EDIT MANUALLY!!!
# This section was auto-generated via `butcher`
def __init__(
__pydantic__self__,
*,
type: Literal[
TransactionPartnerType.TELEGRAM_ADS
] = TransactionPartnerType.TELEGRAM_ADS,
**__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,6 +1,6 @@
from __future__ import annotations
from typing import TYPE_CHECKING, Any, Literal
from typing import TYPE_CHECKING, Any, Literal, Optional
from ..enums import TransactionPartnerType
from .transaction_partner import TransactionPartner
@ -20,6 +20,8 @@ class TransactionPartnerUser(TransactionPartner):
"""Type of the transaction partner, always 'user'"""
user: User
"""Information about the user"""
invoice_payload: Optional[str] = None
"""*Optional*. Bot-specified invoice payload"""
if TYPE_CHECKING:
# DO NOT EDIT MANUALLY!!!
@ -30,10 +32,13 @@ class TransactionPartnerUser(TransactionPartner):
*,
type: Literal[TransactionPartnerType.USER] = TransactionPartnerType.USER,
user: User,
invoice_payload: 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__(type=type, user=user, **__pydantic_kwargs)
super().__init__(
type=type, user=user, invoice_payload=invoice_payload, **__pydantic_kwargs
)

View file

@ -20,17 +20,17 @@ class Video(TelegramObject):
file_unique_id: str
"""Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file."""
width: int
"""Video width as defined by sender"""
"""Video width as defined by the sender"""
height: int
"""Video height as defined by sender"""
"""Video height as defined by the sender"""
duration: int
"""Duration of the video in seconds as defined by sender"""
"""Duration of the video in seconds as defined by the sender"""
thumbnail: Optional[PhotoSize] = None
"""*Optional*. Video thumbnail"""
file_name: Optional[str] = None
"""*Optional*. Original filename as defined by sender"""
"""*Optional*. Original filename as defined by the sender"""
mime_type: Optional[str] = None
"""*Optional*. MIME type of the file as defined by sender"""
"""*Optional*. MIME type of the file as defined by the sender"""
file_size: Optional[int] = None
"""*Optional*. File size in bytes. It can be bigger than 2^31 and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this value."""

View file

@ -20,9 +20,9 @@ class VideoNote(TelegramObject):
file_unique_id: str
"""Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file."""
length: int
"""Video width and height (diameter of the video message) as defined by sender"""
"""Video width and height (diameter of the video message) as defined by the sender"""
duration: int
"""Duration of the video in seconds as defined by sender"""
"""Duration of the video in seconds as defined by the sender"""
thumbnail: Optional[PhotoSize] = None
"""*Optional*. Video thumbnail"""
file_size: Optional[int] = None

View file

@ -17,9 +17,9 @@ class Voice(TelegramObject):
file_unique_id: str
"""Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file."""
duration: int
"""Duration of the audio in seconds as defined by sender"""
"""Duration of the audio in seconds as defined by the sender"""
mime_type: Optional[str] = None
"""*Optional*. MIME type of the file as defined by sender"""
"""*Optional*. MIME type of the file as defined by the sender"""
file_size: Optional[int] = None
"""*Optional*. File size in bytes. It can be bigger than 2^31 and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this value."""