Added full support for the Bot API 9.0 (#1671)

* Added full support for the Bot API 9.0

* Bump version
This commit is contained in:
Alex Root Junior 2025-04-12 23:29:48 +03:00 committed by GitHub
parent 25e9127db9
commit 2c2bd61551
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
231 changed files with 9565 additions and 389 deletions

View file

@ -33,6 +33,7 @@ from ..methods import (
Close,
CloseForumTopic,
CloseGeneralForumTopic,
ConvertGiftToStars,
CopyMessage,
CopyMessages,
CreateChatInviteLink,
@ -41,6 +42,7 @@ from ..methods import (
CreateInvoiceLink,
CreateNewStickerSet,
DeclineChatJoinRequest,
DeleteBusinessMessages,
DeleteChatPhoto,
DeleteChatStickerSet,
DeleteForumTopic,
@ -49,6 +51,7 @@ from ..methods import (
DeleteMyCommands,
DeleteStickerFromSet,
DeleteStickerSet,
DeleteStory,
DeleteWebhook,
EditChatInviteLink,
EditChatSubscriptionInviteLink,
@ -59,11 +62,14 @@ from ..methods import (
EditMessageMedia,
EditMessageReplyMarkup,
EditMessageText,
EditStory,
EditUserStarSubscription,
ExportChatInviteLink,
ForwardMessage,
ForwardMessages,
GetAvailableGifts,
GetBusinessAccountGifts,
GetBusinessAccountStarBalance,
GetBusinessConnection,
GetChat,
GetChatAdministrators,
@ -86,12 +92,16 @@ from ..methods import (
GetUserChatBoosts,
GetUserProfilePhotos,
GetWebhookInfo,
GiftPremiumSubscription,
HideGeneralForumTopic,
LeaveChat,
LogOut,
PinChatMessage,
PostStory,
PromoteChatMember,
ReadBusinessMessage,
RefundStarPayment,
RemoveBusinessAccountProfilePhoto,
RemoveChatVerification,
RemoveUserVerification,
ReopenForumTopic,
@ -120,6 +130,11 @@ from ..methods import (
SendVideo,
SendVideoNote,
SendVoice,
SetBusinessAccountBio,
SetBusinessAccountGiftSettings,
SetBusinessAccountName,
SetBusinessAccountProfilePhoto,
SetBusinessAccountUsername,
SetChatAdministratorCustomTitle,
SetChatDescription,
SetChatMenuButton,
@ -147,6 +162,8 @@ from ..methods import (
StopMessageLiveLocation,
StopPoll,
TelegramMethod,
TransferBusinessAccountStars,
TransferGift,
UnbanChatMember,
UnbanChatSenderChat,
UnhideGeneralForumTopic,
@ -154,11 +171,13 @@ from ..methods import (
UnpinAllForumTopicMessages,
UnpinAllGeneralForumTopicMessages,
UnpinChatMessage,
UpgradeGift,
UploadStickerFile,
VerifyChat,
VerifyUser,
)
from ..types import (
AcceptedGiftTypes,
BotCommand,
BotCommandScopeUnion,
BotDescription,
@ -184,7 +203,9 @@ from ..types import (
InputMediaUnion,
InputPaidMediaUnion,
InputPollOptionUnion,
InputProfilePhotoUnion,
InputSticker,
InputStoryContentUnion,
LabeledPrice,
LinkPreviewOptions,
MaskPosition,
@ -193,6 +214,7 @@ from ..types import (
Message,
MessageEntity,
MessageId,
OwnedGifts,
PassportElementErrorUnion,
Poll,
PreparedInlineMessage,
@ -203,9 +225,12 @@ from ..types import (
ResultMenuButtonUnion,
SentWebAppMessage,
ShippingOption,
StarAmount,
StarTransactions,
Sticker,
StickerSet,
Story,
StoryArea,
Update,
User,
UserChatBoosts,
@ -932,7 +957,7 @@ class Bot:
:param prices: Price breakdown, a JSON-serialized list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.). Must contain exactly one item for payments in `Telegram Stars <https://t.me/BotNews/90>`_.
:param business_connection_id: Unique identifier of the business connection on behalf of which the link will be created. For payments in `Telegram Stars <https://t.me/BotNews/90>`_ only.
:param provider_token: Payment provider token, obtained via `@BotFather <https://t.me/botfather>`_. Pass an empty string for payments in `Telegram Stars <https://t.me/BotNews/90>`_.
:param subscription_period: The number of seconds the subscription will be active for before the next payment. The currency must be set to 'XTR' (Telegram Stars) if the parameter is used. Currently, it must always be 2592000 (30 days) if specified. Any number of subscriptions can be active for a given bot at the same time, including multiple concurrent subscriptions from the same user. Subscription price must no exceed 2500 Telegram Stars.
:param subscription_period: The number of seconds the subscription will be active for before the next payment. The currency must be set to 'XTR' (Telegram Stars) if the parameter is used. Currently, it must always be 2592000 (30 days) if specified. Any number of subscriptions can be active for a given bot at the same time, including multiple concurrent subscriptions from the same user. Subscription price must no exceed 10000 Telegram Stars.
:param max_tip_amount: The maximum accepted amount for tips in the *smallest units* of the currency (integer, **not** float/double). For example, for a maximum tip of :code:`US$ 1.45` pass :code:`max_tip_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). Defaults to 0. Not supported for payments in `Telegram Stars <https://t.me/BotNews/90>`_.
:param suggested_tip_amounts: A JSON-serialized array of suggested amounts of tips in the *smallest units* of the currency (integer, **not** float/double). At most 4 suggested tip amounts can be specified. The suggested tip amounts must be positive, passed in a strictly increased order and must not exceed *max_tip_amount*.
:param provider_data: JSON-serialized data about the invoice, which will be shared with the payment provider. A detailed description of required fields should be provided by the payment provider.
@ -4571,7 +4596,7 @@ class Bot:
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`). 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; 1-2500
:param star_count: The number of Telegram Stars that must be paid to buy access to the media; 1-10000
: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 payload: Bot-defined paid media payload, 0-128 bytes. This will not be displayed to the user, use it for your internal processes.
@ -4621,7 +4646,7 @@ class Bot:
: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 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-10000
: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.
@ -4758,7 +4783,7 @@ class Bot:
:param user_id: Required if *chat_id* is not specified. Unique identifier of the target user who will receive the gift.
:param chat_id: 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.
:param pay_for_upgrade: Pass :code:`True` to pay for the gift upgrade from the bot's balance, thereby making the upgrade free for the receiver
:param text: Text that will be shown along with the gift; 0-255 characters
:param text: Text that will be shown along with the gift; 0-128 characters
:param text_parse_mode: Mode for parsing entities in the text. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details. Entities other than 'bold', 'italic', 'underline', 'strikethrough', 'spoiler', and 'custom_emoji' are ignored.
:param text_entities: A JSON-serialized list of special entities that appear in the gift text. It can be specified instead of *text_parse_mode*. Entities other than 'bold', 'italic', 'underline', 'strikethrough', 'spoiler', and 'custom_emoji' are ignored.
:param request_timeout: Request timeout
@ -4887,3 +4912,507 @@ class Bot:
custom_description=custom_description,
)
return await self(call, request_timeout=request_timeout)
async def convert_gift_to_stars(
self,
business_connection_id: str,
owned_gift_id: str,
request_timeout: Optional[int] = None,
) -> bool:
"""
Converts a given regular gift to Telegram Stars. Requires the *can_convert_gifts_to_stars* business bot right. Returns :code:`True` on success.
Source: https://core.telegram.org/bots/api#convertgifttostars
:param business_connection_id: Unique identifier of the business connection
:param owned_gift_id: Unique identifier of the regular gift that should be converted to Telegram Stars
:param request_timeout: Request timeout
:return: Returns :code:`True` on success.
"""
call = ConvertGiftToStars(
business_connection_id=business_connection_id,
owned_gift_id=owned_gift_id,
)
return await self(call, request_timeout=request_timeout)
async def delete_business_messages(
self,
business_connection_id: str,
message_ids: list[int],
request_timeout: Optional[int] = None,
) -> 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.
Source: https://core.telegram.org/bots/api#deletebusinessmessages
:param business_connection_id: Unique identifier of the business connection on behalf of which to delete the messages
:param message_ids: A JSON-serialized list of 1-100 identifiers of messages to delete. All messages must be from the same chat. See :class:`aiogram.methods.delete_message.DeleteMessage` for limitations on which messages can be deleted
:param request_timeout: Request timeout
:return: Returns :code:`True` on success.
"""
call = DeleteBusinessMessages(
business_connection_id=business_connection_id,
message_ids=message_ids,
)
return await self(call, request_timeout=request_timeout)
async def delete_story(
self,
business_connection_id: str,
story_id: int,
request_timeout: Optional[int] = None,
) -> bool:
"""
Deletes a story previously posted by the bot on behalf of a managed business account. Requires the *can_manage_stories* business bot right. Returns :code:`True` on success.
Source: https://core.telegram.org/bots/api#deletestory
:param business_connection_id: Unique identifier of the business connection
:param story_id: Unique identifier of the story to delete
:param request_timeout: Request timeout
:return: Returns :code:`True` on success.
"""
call = DeleteStory(
business_connection_id=business_connection_id,
story_id=story_id,
)
return await self(call, request_timeout=request_timeout)
async def edit_story(
self,
business_connection_id: str,
story_id: int,
content: InputStoryContentUnion,
caption: Optional[str] = None,
parse_mode: Optional[str] = None,
caption_entities: Optional[list[MessageEntity]] = None,
areas: Optional[list[StoryArea]] = None,
request_timeout: Optional[int] = None,
) -> Story:
"""
Edits a story previously posted by the bot on behalf of a managed business account. Requires the *can_manage_stories* business bot right. Returns :class:`aiogram.types.story.Story` on success.
Source: https://core.telegram.org/bots/api#editstory
:param business_connection_id: Unique identifier of the business connection
:param story_id: Unique identifier of the story to edit
:param content: Content of the story
:param caption: Caption of the story, 0-2048 characters after entities parsing
:param parse_mode: Mode for parsing entities in the story 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*
:param areas: A JSON-serialized list of clickable areas to be shown on the story
:param request_timeout: Request timeout
:return: Returns :class:`aiogram.types.story.Story` on success.
"""
call = EditStory(
business_connection_id=business_connection_id,
story_id=story_id,
content=content,
caption=caption,
parse_mode=parse_mode,
caption_entities=caption_entities,
areas=areas,
)
return await self(call, request_timeout=request_timeout)
async def get_business_account_gifts(
self,
business_connection_id: str,
exclude_unsaved: Optional[bool] = None,
exclude_saved: Optional[bool] = None,
exclude_unlimited: Optional[bool] = None,
exclude_limited: Optional[bool] = None,
exclude_unique: Optional[bool] = None,
sort_by_price: Optional[bool] = None,
offset: Optional[str] = None,
limit: Optional[int] = None,
request_timeout: Optional[int] = None,
) -> OwnedGifts:
"""
Returns the gifts received and owned by a managed business account. Requires the *can_view_gifts_and_stars* business bot right. Returns :class:`aiogram.types.owned_gifts.OwnedGifts` on success.
Source: https://core.telegram.org/bots/api#getbusinessaccountgifts
:param business_connection_id: Unique identifier of the business connection
:param exclude_unsaved: Pass True to exclude gifts that aren't saved to the account's profile page
:param exclude_saved: Pass True to exclude gifts that are saved to the account's profile page
:param exclude_unlimited: Pass True to exclude gifts that can be purchased an unlimited number of times
:param exclude_limited: Pass True to exclude gifts that can be purchased a limited number of times
:param exclude_unique: Pass True to exclude unique gifts
:param sort_by_price: Pass True to sort results by gift price instead of send date. Sorting is applied before pagination.
:param offset: Offset of the first entry to return as received from the previous request; use empty string to get the first chunk of results
:param limit: The maximum number of gifts to be returned; 1-100. Defaults to 100
:param request_timeout: Request timeout
:return: Returns :class:`aiogram.types.owned_gifts.OwnedGifts` on success.
"""
call = GetBusinessAccountGifts(
business_connection_id=business_connection_id,
exclude_unsaved=exclude_unsaved,
exclude_saved=exclude_saved,
exclude_unlimited=exclude_unlimited,
exclude_limited=exclude_limited,
exclude_unique=exclude_unique,
sort_by_price=sort_by_price,
offset=offset,
limit=limit,
)
return await self(call, request_timeout=request_timeout)
async def get_business_account_star_balance(
self,
business_connection_id: str,
request_timeout: Optional[int] = None,
) -> StarAmount:
"""
Returns the amount of Telegram Stars owned by a managed business account. Requires the *can_view_gifts_and_stars* business bot right. Returns :class:`aiogram.types.star_amount.StarAmount` on success.
Source: https://core.telegram.org/bots/api#getbusinessaccountstarbalance
:param business_connection_id: Unique identifier of the business connection
:param request_timeout: Request timeout
:return: Returns :class:`aiogram.types.star_amount.StarAmount` on success.
"""
call = GetBusinessAccountStarBalance(
business_connection_id=business_connection_id,
)
return await self(call, request_timeout=request_timeout)
async def gift_premium_subscription(
self,
user_id: int,
month_count: int,
star_count: int,
text: Optional[str] = None,
text_parse_mode: Optional[str] = None,
text_entities: Optional[list[MessageEntity]] = None,
request_timeout: Optional[int] = None,
) -> bool:
"""
Gifts a Telegram Premium subscription to the given user. Returns :code:`True` on success.
Source: https://core.telegram.org/bots/api#giftpremiumsubscription
:param user_id: Unique identifier of the target user who will receive a Telegram Premium subscription
:param month_count: Number of months the Telegram Premium subscription will be active for the user; must be one of 3, 6, or 12
:param star_count: Number of Telegram Stars to pay for the Telegram Premium subscription; must be 1000 for 3 months, 1500 for 6 months, and 2500 for 12 months
:param text: Text that will be shown along with the service message about the subscription; 0-128 characters
:param text_parse_mode: Mode for parsing entities in the text. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details. Entities other than 'bold', 'italic', 'underline', 'strikethrough', 'spoiler', and 'custom_emoji' are ignored.
:param text_entities: A JSON-serialized list of special entities that appear in the gift text. It can be specified instead of *text_parse_mode*. Entities other than 'bold', 'italic', 'underline', 'strikethrough', 'spoiler', and 'custom_emoji' are ignored.
:param request_timeout: Request timeout
:return: Returns :code:`True` on success.
"""
call = GiftPremiumSubscription(
user_id=user_id,
month_count=month_count,
star_count=star_count,
text=text,
text_parse_mode=text_parse_mode,
text_entities=text_entities,
)
return await self(call, request_timeout=request_timeout)
async def post_story(
self,
business_connection_id: str,
content: InputStoryContentUnion,
active_period: int,
caption: Optional[str] = None,
parse_mode: Optional[str] = None,
caption_entities: Optional[list[MessageEntity]] = None,
areas: Optional[list[StoryArea]] = None,
post_to_chat_page: Optional[bool] = None,
protect_content: Optional[bool] = None,
request_timeout: Optional[int] = None,
) -> Story:
"""
Posts a story on behalf of a managed business account. Requires the *can_manage_stories* business bot right. Returns :class:`aiogram.types.story.Story` on success.
Source: https://core.telegram.org/bots/api#poststory
:param business_connection_id: Unique identifier of the business connection
:param content: Content of the story
:param active_period: Period after which the story is moved to the archive, in seconds; must be one of :code:`6 * 3600`, :code:`12 * 3600`, :code:`86400`, or :code:`2 * 86400`
:param caption: Caption of the story, 0-2048 characters after entities parsing
:param parse_mode: Mode for parsing entities in the story 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*
:param areas: A JSON-serialized list of clickable areas to be shown on the story
:param post_to_chat_page: Pass :code:`True` to keep the story accessible after it expires
:param protect_content: Pass :code:`True` if the content of the story must be protected from forwarding and screenshotting
:param request_timeout: Request timeout
:return: Returns :class:`aiogram.types.story.Story` on success.
"""
call = PostStory(
business_connection_id=business_connection_id,
content=content,
active_period=active_period,
caption=caption,
parse_mode=parse_mode,
caption_entities=caption_entities,
areas=areas,
post_to_chat_page=post_to_chat_page,
protect_content=protect_content,
)
return await self(call, request_timeout=request_timeout)
async def read_business_message(
self,
business_connection_id: str,
chat_id: int,
message_id: int,
request_timeout: Optional[int] = None,
) -> bool:
"""
Marks incoming message as read on behalf of a business account. Requires the *can_read_messages* business bot right. Returns :code:`True` on success.
Source: https://core.telegram.org/bots/api#readbusinessmessage
:param business_connection_id: Unique identifier of the business connection on behalf of which to read the message
:param chat_id: Unique identifier of the chat in which the message was received. The chat must have been active in the last 24 hours.
:param message_id: Unique identifier of the message to mark as read
:param request_timeout: Request timeout
:return: Returns :code:`True` on success.
"""
call = ReadBusinessMessage(
business_connection_id=business_connection_id,
chat_id=chat_id,
message_id=message_id,
)
return await self(call, request_timeout=request_timeout)
async def remove_business_account_profile_photo(
self,
business_connection_id: str,
is_public: Optional[bool] = None,
request_timeout: Optional[int] = None,
) -> bool:
"""
Removes the current profile photo of a managed business account. Requires the *can_edit_profile_photo* business bot right. Returns :code:`True` on success.
Source: https://core.telegram.org/bots/api#removebusinessaccountprofilephoto
:param business_connection_id: Unique identifier of the business connection
:param is_public: 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.
:param request_timeout: Request timeout
:return: Returns :code:`True` on success.
"""
call = RemoveBusinessAccountProfilePhoto(
business_connection_id=business_connection_id,
is_public=is_public,
)
return await self(call, request_timeout=request_timeout)
async def set_business_account_bio(
self,
business_connection_id: str,
bio: Optional[str] = None,
request_timeout: Optional[int] = None,
) -> bool:
"""
Changes the bio of a managed business account. Requires the *can_change_bio* business bot right. Returns :code:`True` on success.
Source: https://core.telegram.org/bots/api#setbusinessaccountbio
:param business_connection_id: Unique identifier of the business connection
:param bio: The new value of the bio for the business account; 0-140 characters
:param request_timeout: Request timeout
:return: Returns :code:`True` on success.
"""
call = SetBusinessAccountBio(
business_connection_id=business_connection_id,
bio=bio,
)
return await self(call, request_timeout=request_timeout)
async def set_business_account_gift_settings(
self,
business_connection_id: str,
show_gift_button: bool,
accepted_gift_types: AcceptedGiftTypes,
request_timeout: Optional[int] = None,
) -> bool:
"""
Changes the privacy settings pertaining to incoming gifts in a managed business account. Requires the *can_change_gift_settings* business bot right. Returns :code:`True` on success.
Source: https://core.telegram.org/bots/api#setbusinessaccountgiftsettings
:param business_connection_id: Unique identifier of the business connection
:param show_gift_button: 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
:param accepted_gift_types: Types of gifts accepted by the business account
:param request_timeout: Request timeout
:return: Returns :code:`True` on success.
"""
call = SetBusinessAccountGiftSettings(
business_connection_id=business_connection_id,
show_gift_button=show_gift_button,
accepted_gift_types=accepted_gift_types,
)
return await self(call, request_timeout=request_timeout)
async def set_business_account_name(
self,
business_connection_id: str,
first_name: str,
last_name: Optional[str] = None,
request_timeout: Optional[int] = None,
) -> bool:
"""
Changes the first and last name of a managed business account. Requires the *can_change_name* business bot right. Returns :code:`True` on success.
Source: https://core.telegram.org/bots/api#setbusinessaccountname
:param business_connection_id: Unique identifier of the business connection
:param first_name: The new value of the first name for the business account; 1-64 characters
:param last_name: The new value of the last name for the business account; 0-64 characters
:param request_timeout: Request timeout
:return: Returns :code:`True` on success.
"""
call = SetBusinessAccountName(
business_connection_id=business_connection_id,
first_name=first_name,
last_name=last_name,
)
return await self(call, request_timeout=request_timeout)
async def set_business_account_profile_photo(
self,
business_connection_id: str,
photo: InputProfilePhotoUnion,
is_public: Optional[bool] = None,
request_timeout: Optional[int] = None,
) -> bool:
"""
Changes the profile photo of a managed business account. Requires the *can_edit_profile_photo* business bot right. Returns :code:`True` on success.
Source: https://core.telegram.org/bots/api#setbusinessaccountprofilephoto
:param business_connection_id: Unique identifier of the business connection
:param photo: The new profile photo to set
:param is_public: 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.
:param request_timeout: Request timeout
:return: Returns :code:`True` on success.
"""
call = SetBusinessAccountProfilePhoto(
business_connection_id=business_connection_id,
photo=photo,
is_public=is_public,
)
return await self(call, request_timeout=request_timeout)
async def set_business_account_username(
self,
business_connection_id: str,
username: Optional[str] = None,
request_timeout: Optional[int] = None,
) -> bool:
"""
Changes the username of a managed business account. Requires the *can_change_username* business bot right. Returns :code:`True` on success.
Source: https://core.telegram.org/bots/api#setbusinessaccountusername
:param business_connection_id: Unique identifier of the business connection
:param username: The new value of the username for the business account; 0-32 characters
:param request_timeout: Request timeout
:return: Returns :code:`True` on success.
"""
call = SetBusinessAccountUsername(
business_connection_id=business_connection_id,
username=username,
)
return await self(call, request_timeout=request_timeout)
async def transfer_business_account_stars(
self,
business_connection_id: str,
star_count: int,
request_timeout: Optional[int] = None,
) -> bool:
"""
Transfers Telegram Stars from the business account balance to the bot's balance. Requires the *can_transfer_stars* business bot right. Returns :code:`True` on success.
Source: https://core.telegram.org/bots/api#transferbusinessaccountstars
:param business_connection_id: Unique identifier of the business connection
:param star_count: Number of Telegram Stars to transfer; 1-10000
:param request_timeout: Request timeout
:return: Returns :code:`True` on success.
"""
call = TransferBusinessAccountStars(
business_connection_id=business_connection_id,
star_count=star_count,
)
return await self(call, request_timeout=request_timeout)
async def transfer_gift(
self,
business_connection_id: str,
owned_gift_id: str,
new_owner_chat_id: int,
star_count: Optional[int] = None,
request_timeout: Optional[int] = None,
) -> bool:
"""
Transfers an owned unique gift to another user. Requires the *can_transfer_and_upgrade_gifts* business bot right. Requires *can_transfer_stars* business bot right if the transfer is paid. Returns :code:`True` on success.
Source: https://core.telegram.org/bots/api#transfergift
:param business_connection_id: Unique identifier of the business connection
:param owned_gift_id: Unique identifier of the regular gift that should be transferred
:param new_owner_chat_id: Unique identifier of the chat which will own the gift. The chat must be active in the last 24 hours.
:param star_count: The amount of Telegram Stars that will be paid for the transfer from the business account balance. If positive, then the *can_transfer_stars* business bot right is required.
:param request_timeout: Request timeout
:return: Returns :code:`True` on success.
"""
call = TransferGift(
business_connection_id=business_connection_id,
owned_gift_id=owned_gift_id,
new_owner_chat_id=new_owner_chat_id,
star_count=star_count,
)
return await self(call, request_timeout=request_timeout)
async def upgrade_gift(
self,
business_connection_id: str,
owned_gift_id: str,
keep_original_details: Optional[bool] = None,
star_count: Optional[int] = None,
request_timeout: Optional[int] = None,
) -> bool:
"""
Upgrades a given regular gift to a unique gift. Requires the *can_transfer_and_upgrade_gifts* business bot right. Additionally requires the *can_transfer_stars* business bot right if the upgrade is paid. Returns :code:`True` on success.
Source: https://core.telegram.org/bots/api#upgradegift
:param business_connection_id: Unique identifier of the business connection
:param owned_gift_id: Unique identifier of the regular gift that should be upgraded to a unique one
:param keep_original_details: Pass True to keep the original gift text, sender and receiver in the upgraded gift
:param star_count: 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.
:param request_timeout: Request timeout
:return: Returns :code:`True` on success.
"""
call = UpgradeGift(
business_connection_id=business_connection_id,
owned_gift_id=owned_gift_id,
keep_original_details=keep_original_details,
star_count=star_count,
)
return await self(call, request_timeout=request_timeout)