From dfc88fc9076dfdbc722fadb17be877d268904583 Mon Sep 17 00:00:00 2001 From: Alex Root Junior Date: Sun, 17 Nov 2024 23:18:42 +0200 Subject: [PATCH] Added full support for Bot API 8.0 (#1606) * Added full support of Bot API 8.0 * Added tests * Reformat code * Added changelog * Bump API version --- .apiversion | 2 +- .../methods/createInvoiceLink/entity.json | 16 + .../editUserStarSubscription/entity.json | 41 +++ .../methods/getAvailableGifts/entity.json | 16 + .../savePreparedInlineMessage/entity.json | 65 ++++ .butcher/methods/sendGift/entity.json | 57 +++ .../methods/setUserEmojiStatus/entity.json | 41 +++ .../methods/setUserEmojiStatus/replace.yml | 11 + .butcher/schema/schema.json | 339 +++++++++++++++++- .butcher/types/Gift/entity.json | 57 +++ .butcher/types/Gifts/entity.json | 25 ++ .../types/PreparedInlineMessage/entity.json | 33 ++ .../types/PreparedInlineMessage/replace.yml | 11 + .butcher/types/SuccessfulPayment/entity.json | 24 ++ .../types/TransactionPartnerUser/entity.json | 16 + CHANGES/1606.feature.rst | 25 ++ README.rst | 2 +- aiogram/__meta__.py | 2 +- aiogram/client/bot.py | 171 +++++++++ aiogram/methods/__init__.py | 10 + aiogram/methods/create_invoice_link.py | 8 + aiogram/methods/edit_message_text.py | 10 +- .../methods/edit_user_star_subscription.py | 46 +++ aiogram/methods/get_available_gifts.py | 15 + .../methods/save_prepared_inline_message.py | 121 +++++++ aiogram/methods/send_gift.py | 55 +++ aiogram/methods/set_user_emoji_status.py | 51 +++ aiogram/types/__init__.py | 6 + aiogram/types/gift.py | 54 +++ aiogram/types/gifts.py | 30 ++ .../types/inline_query_result_cached_audio.py | 2 +- .../types/inline_query_result_cached_photo.py | 2 +- aiogram/types/input_poll_option.py | 2 +- aiogram/types/prepared_inline_message.py | 36 ++ aiogram/types/star_transactions.py | 2 +- aiogram/types/successful_payment.py | 12 + aiogram/types/transaction_partner_user.py | 8 + .../types/video_chat_participants_invited.py | 2 +- .../methods/edit_user_star_subscription.rst | 45 +++ docs/api/methods/get_available_gifts.rst | 38 ++ docs/api/methods/index.rst | 5 + .../methods/save_prepared_inline_message.rst | 45 +++ docs/api/methods/send_gift.rst | 45 +++ docs/api/methods/set_user_emoji_status.rst | 45 +++ docs/api/types/gift.rst | 10 + docs/api/types/gifts.rst | 10 + docs/api/types/index.rst | 3 + docs/api/types/prepared_inline_message.rst | 10 + .../test_session/test_aiohttp_session.py | 2 +- .../test_answer_callback_query.py | 2 +- .../test_methods/test_answer_inline_query.py | 10 +- .../test_answer_pre_checkout_query.py | 2 +- .../test_answer_shipping_query.py | 2 +- .../test_approve_chat_join_request.py | 2 +- .../test_methods/test_ban_chat_member.py | 2 +- .../test_methods/test_ban_chat_sender_chat.py | 2 +- tests/test_api/test_methods/test_close.py | 2 +- .../test_methods/test_close_forum_topic.py | 2 +- .../test_close_general_forum_topic.py | 2 +- .../test_methods/test_copy_message.py | 2 +- .../test_create_chat_invite_link.py | 2 +- ...st_create_chat_subscruption_invite_link.py | 6 +- .../test_methods/test_create_forum_topic.py | 2 +- .../test_methods/test_create_invoice_link.py | 2 +- .../test_create_new_sticker_set.py | 2 +- .../test_decline_chat_join_request.py | 2 +- .../test_methods/test_delete_chat_photo.py | 2 +- .../test_delete_chat_sticker_set.py | 2 +- .../test_methods/test_delete_forum_topic.py | 2 +- .../test_methods/test_delete_message.py | 2 +- .../test_methods/test_delete_my_commands.py | 2 +- .../test_delete_sticker_from_set.py | 2 +- .../test_methods/test_delete_sticker_set.py | 2 +- .../test_methods/test_delete_webhook.py | 2 +- .../test_edit_chat_invite_link.py | 2 +- ...test_edit_chat_subscruption_invite_link.py | 9 +- .../test_methods/test_edit_forum_topic.py | 2 +- .../test_edit_general_forum_topic.py | 2 +- .../test_methods/test_edit_message_caption.py | 2 +- .../test_edit_message_live_location.py | 2 +- .../test_methods/test_edit_message_media.py | 2 +- .../test_edit_message_reply_markup.py | 2 +- .../test_methods/test_edit_message_text.py | 2 +- .../test_edit_user_star_subscription.py | 15 + .../test_export_chat_invite_link.py | 2 +- .../test_methods/test_forward_message.py | 2 +- .../test_methods/test_get_available_gifts.py | 32 ++ .../test_get_chat_administrators.py | 2 +- .../test_methods/test_get_chat_member.py | 4 +- .../test_get_chat_member_count.py | 2 +- .../test_methods/test_get_chat_menu_button.py | 2 +- .../test_get_custom_emoji_stickers.py | 2 +- tests/test_api/test_methods/test_get_file.py | 2 +- .../test_get_forum_topic_icon_stickers.py | 2 +- .../test_methods/test_get_game_high_scores.py | 2 +- tests/test_api/test_methods/test_get_me.py | 2 +- .../test_methods/test_get_my_commands.py | 2 +- ...est_get_my_default_administrator_rights.py | 2 +- .../test_methods/test_get_my_description.py | 2 +- .../test_api/test_methods/test_get_my_name.py | 2 +- .../test_get_my_short_description.py | 2 +- .../test_methods/test_get_sticker_set.py | 2 +- .../test_api/test_methods/test_get_updates.py | 2 +- .../test_get_user_profile_photos.py | 2 +- .../test_methods/test_get_webhook_info.py | 2 +- .../test_hide_general_forum_topic.py | 2 +- .../test_api/test_methods/test_leave_chat.py | 2 +- tests/test_api/test_methods/test_log_out.py | 2 +- .../test_methods/test_pin_chat_message.py | 2 +- .../test_methods/test_promote_chat_member.py | 2 +- .../test_methods/test_refund_star_payment.py | 4 +- .../test_methods/test_reopen_forum_topic.py | 2 +- .../test_reopen_general_forum_topic.py | 2 +- .../test_methods/test_restrict_chat_member.py | 2 +- .../test_revoke_chat_invite_link.py | 2 +- .../test_save_prepared_inline_message.py | 34 ++ .../test_methods/test_send_animation.py | 2 +- .../test_api/test_methods/test_send_audio.py | 2 +- .../test_methods/test_send_chat_action.py | 2 +- .../test_methods/test_send_contact.py | 2 +- tests/test_api/test_methods/test_send_dice.py | 2 +- .../test_methods/test_send_document.py | 2 +- tests/test_api/test_methods/test_send_game.py | 2 +- tests/test_api/test_methods/test_send_gift.py | 11 + .../test_methods/test_send_invoice.py | 2 +- .../test_methods/test_send_location.py | 2 +- .../test_methods/test_send_media_group.py | 2 +- .../test_methods/test_send_message.py | 2 +- .../test_api/test_methods/test_send_photo.py | 2 +- tests/test_api/test_methods/test_send_poll.py | 2 +- .../test_methods/test_send_sticker.py | 2 +- .../test_api/test_methods/test_send_venue.py | 2 +- .../test_api/test_methods/test_send_video.py | 2 +- .../test_methods/test_send_video_note.py | 2 +- .../test_api/test_methods/test_send_voice.py | 2 +- ...est_set_chat_administrator_custom_title.py | 2 +- .../test_methods/test_set_chat_description.py | 2 +- .../test_methods/test_set_chat_menu_button.py | 2 +- .../test_methods/test_set_chat_permissions.py | 2 +- .../test_methods/test_set_chat_photo.py | 2 +- .../test_methods/test_set_chat_sticker_set.py | 2 +- .../test_methods/test_set_chat_title.py | 2 +- ..._set_custom_emoji_sticker_set_thumbnail.py | 2 +- .../test_methods/test_set_game_score.py | 2 +- .../test_methods/test_set_my_commands.py | 3 +- ...est_set_my_default_administrator_rights.py | 2 +- .../test_methods/test_set_my_description.py | 2 +- .../test_set_my_short_description.py | 2 +- .../test_set_passport_data_errors.py | 4 +- .../test_set_sticker_emoji_list.py | 2 +- .../test_methods/test_set_sticker_keywords.py | 2 +- .../test_set_sticker_mask_position.py | 2 +- .../test_set_sticker_position_in_set.py | 2 +- .../test_set_sticker_set_thumbnail.py | 2 +- .../test_set_sticker_set_title.py | 2 +- .../test_set_user_emoji_status.py | 17 + .../test_api/test_methods/test_set_webhook.py | 2 +- .../test_stop_message_live_location.py | 2 +- tests/test_api/test_methods/test_stop_poll.py | 2 +- .../test_methods/test_unban_chat_member.py | 2 +- .../test_unban_chat_sender_chat.py | 2 +- .../test_unhide_general_forum_topic.py | 2 +- .../test_unpin_all_chat_messages.py | 2 +- .../test_unpin_all_forum_topic_messages.py | 2 +- ..._unpin_all_general_forum_topic_messages.py | 6 +- .../test_methods/test_unpin_chat_message.py | 2 +- .../test_methods/test_upload_sticker_file.py | 2 +- tests/test_api/test_types/test_input_file.py | 2 - tests/test_fsm/storage/test_isolation.py | 1 - 169 files changed, 1890 insertions(+), 162 deletions(-) create mode 100644 .butcher/methods/editUserStarSubscription/entity.json create mode 100644 .butcher/methods/getAvailableGifts/entity.json create mode 100644 .butcher/methods/savePreparedInlineMessage/entity.json create mode 100644 .butcher/methods/sendGift/entity.json create mode 100644 .butcher/methods/setUserEmojiStatus/entity.json create mode 100644 .butcher/methods/setUserEmojiStatus/replace.yml create mode 100644 .butcher/types/Gift/entity.json create mode 100644 .butcher/types/Gifts/entity.json create mode 100644 .butcher/types/PreparedInlineMessage/entity.json create mode 100644 .butcher/types/PreparedInlineMessage/replace.yml create mode 100644 CHANGES/1606.feature.rst create mode 100644 aiogram/methods/edit_user_star_subscription.py create mode 100644 aiogram/methods/get_available_gifts.py create mode 100644 aiogram/methods/save_prepared_inline_message.py create mode 100644 aiogram/methods/send_gift.py create mode 100644 aiogram/methods/set_user_emoji_status.py create mode 100644 aiogram/types/gift.py create mode 100644 aiogram/types/gifts.py create mode 100644 aiogram/types/prepared_inline_message.py create mode 100644 docs/api/methods/edit_user_star_subscription.rst create mode 100644 docs/api/methods/get_available_gifts.rst create mode 100644 docs/api/methods/save_prepared_inline_message.rst create mode 100644 docs/api/methods/send_gift.rst create mode 100644 docs/api/methods/set_user_emoji_status.rst create mode 100644 docs/api/types/gift.rst create mode 100644 docs/api/types/gifts.rst create mode 100644 docs/api/types/prepared_inline_message.rst create mode 100644 tests/test_api/test_methods/test_edit_user_star_subscription.py create mode 100644 tests/test_api/test_methods/test_get_available_gifts.py create mode 100644 tests/test_api/test_methods/test_save_prepared_inline_message.py create mode 100644 tests/test_api/test_methods/test_send_gift.py create mode 100644 tests/test_api/test_methods/test_set_user_emoji_status.py diff --git a/.apiversion b/.apiversion index 67271a4c..cc40bca6 100644 --- a/.apiversion +++ b/.apiversion @@ -1 +1 @@ -7.11 +8.0 diff --git a/.butcher/methods/createInvoiceLink/entity.json b/.butcher/methods/createInvoiceLink/entity.json index b0f451b1..f1761868 100644 --- a/.butcher/methods/createInvoiceLink/entity.json +++ b/.butcher/methods/createInvoiceLink/entity.json @@ -11,6 +11,14 @@ "html_description": "

Use this method to create a link for an invoice. Returns the created invoice link as String on success.

", "rst_description": "Use this method to create a link for an invoice. Returns the created invoice link as *String* on success.", "annotations": [ + { + "type": "String", + "required": false, + "description": "Unique identifier of the business connection on behalf of which the link will be created", + "html_description": "Unique identifier of the business connection on behalf of which the link will be created", + "rst_description": "Unique identifier of the business connection on behalf of which the link will be created\n", + "name": "business_connection_id" + }, { "type": "String", "required": true, @@ -59,6 +67,14 @@ "rst_description": "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 `_.\n", "name": "prices" }, + { + "type": "Integer", + "required": false, + "description": "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.", + "html_description": "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.", + "rst_description": "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.\n", + "name": "subscription_period" + }, { "type": "Integer", "required": false, diff --git a/.butcher/methods/editUserStarSubscription/entity.json b/.butcher/methods/editUserStarSubscription/entity.json new file mode 100644 index 00000000..9cc74993 --- /dev/null +++ b/.butcher/methods/editUserStarSubscription/entity.json @@ -0,0 +1,41 @@ +{ + "meta": {}, + "group": { + "title": "Payments", + "anchor": "payments" + }, + "object": { + "anchor": "edituserstarsubscription", + "name": "editUserStarSubscription", + "description": "Allows the bot to cancel or re-enable extension of a subscription paid in Telegram Stars. Returns True on success.", + "html_description": "

Allows the bot to cancel or re-enable extension of a subscription paid in Telegram Stars. Returns True on success.

", + "rst_description": "Allows the bot to cancel or re-enable extension of a subscription paid in Telegram Stars. Returns :code:`True` on success.", + "annotations": [ + { + "type": "Integer", + "required": true, + "description": "Identifier of the user whose subscription will be edited", + "html_description": "Identifier of the user whose subscription will be edited", + "rst_description": "Identifier of the user whose subscription will be edited\n", + "name": "user_id" + }, + { + "type": "String", + "required": true, + "description": "Telegram payment identifier for the subscription", + "html_description": "Telegram payment identifier for the subscription", + "rst_description": "Telegram payment identifier for the subscription\n", + "name": "telegram_payment_charge_id" + }, + { + "type": "Boolean", + "required": true, + "description": "Pass True to cancel extension of the user subscription; the subscription must be active up to the end of the current subscription period. Pass False to allow the user to re-enable a subscription that was previously canceled by the bot.", + "html_description": "Pass True to cancel extension of the user subscription; the subscription must be active up to the end of the current subscription period. Pass False to allow the user to re-enable a subscription that was previously canceled by the bot.", + "rst_description": "Pass :code:`True` to cancel extension of the user subscription; the subscription must be active up to the end of the current subscription period. Pass :code:`False` to allow the user to re-enable a subscription that was previously canceled by the bot.\n", + "name": "is_canceled" + } + ], + "category": "methods" + } +} diff --git a/.butcher/methods/getAvailableGifts/entity.json b/.butcher/methods/getAvailableGifts/entity.json new file mode 100644 index 00000000..aa73b089 --- /dev/null +++ b/.butcher/methods/getAvailableGifts/entity.json @@ -0,0 +1,16 @@ +{ + "meta": {}, + "group": { + "title": "Stickers", + "anchor": "stickers" + }, + "object": { + "anchor": "getavailablegifts", + "name": "getAvailableGifts", + "description": "Returns the list of gifts that can be sent by the bot to users. Requires no parameters. Returns a Gifts object.", + "html_description": "

Returns the list of gifts that can be sent by the bot to users. Requires no parameters. Returns a Gifts object.

", + "rst_description": "Returns the list of gifts that can be sent by the bot to users. Requires no parameters. Returns a :class:`aiogram.types.gifts.Gifts` object.", + "annotations": [], + "category": "methods" + } +} diff --git a/.butcher/methods/savePreparedInlineMessage/entity.json b/.butcher/methods/savePreparedInlineMessage/entity.json new file mode 100644 index 00000000..dc1caa96 --- /dev/null +++ b/.butcher/methods/savePreparedInlineMessage/entity.json @@ -0,0 +1,65 @@ +{ + "meta": {}, + "group": { + "title": "Inline mode", + "anchor": "inline-mode" + }, + "object": { + "anchor": "savepreparedinlinemessage", + "name": "savePreparedInlineMessage", + "description": "Stores a message that can be sent by a user of a Mini App. Returns a PreparedInlineMessage object.", + "html_description": "

Stores a message that can be sent by a user of a Mini App. Returns a PreparedInlineMessage object.

", + "rst_description": "Stores a message that can be sent by a user of a Mini App. Returns a :class:`aiogram.types.prepared_inline_message.PreparedInlineMessage` object.", + "annotations": [ + { + "type": "Integer", + "required": true, + "description": "Unique identifier of the target user that can use the prepared message", + "html_description": "Unique identifier of the target user that can use the prepared message", + "rst_description": "Unique identifier of the target user that can use the prepared message\n", + "name": "user_id" + }, + { + "type": "InlineQueryResult", + "required": true, + "description": "A JSON-serialized object describing the message to be sent", + "html_description": "A JSON-serialized object describing the message to be sent", + "rst_description": "A JSON-serialized object describing the message to be sent\n", + "name": "result" + }, + { + "type": "Boolean", + "required": false, + "description": "Pass True if the message can be sent to private chats with users", + "html_description": "Pass True if the message can be sent to private chats with users", + "rst_description": "Pass :code:`True` if the message can be sent to private chats with users\n", + "name": "allow_user_chats" + }, + { + "type": "Boolean", + "required": false, + "description": "Pass True if the message can be sent to private chats with bots", + "html_description": "Pass True if the message can be sent to private chats with bots", + "rst_description": "Pass :code:`True` if the message can be sent to private chats with bots\n", + "name": "allow_bot_chats" + }, + { + "type": "Boolean", + "required": false, + "description": "Pass True if the message can be sent to group and supergroup chats", + "html_description": "Pass True if the message can be sent to group and supergroup chats", + "rst_description": "Pass :code:`True` if the message can be sent to group and supergroup chats\n", + "name": "allow_group_chats" + }, + { + "type": "Boolean", + "required": false, + "description": "Pass True if the message can be sent to channel chats", + "html_description": "Pass True if the message can be sent to channel chats", + "rst_description": "Pass :code:`True` if the message can be sent to channel chats\n", + "name": "allow_channel_chats" + } + ], + "category": "methods" + } +} diff --git a/.butcher/methods/sendGift/entity.json b/.butcher/methods/sendGift/entity.json new file mode 100644 index 00000000..f180440f --- /dev/null +++ b/.butcher/methods/sendGift/entity.json @@ -0,0 +1,57 @@ +{ + "meta": {}, + "group": { + "title": "Stickers", + "anchor": "stickers" + }, + "object": { + "anchor": "sendgift", + "name": "sendGift", + "description": "Sends a gift to the given user. The gift can't be converted to Telegram Stars by the user. Returns True on success.", + "html_description": "

Sends a gift to the given user. The gift can't be converted to Telegram Stars by the user. Returns True on success.

", + "rst_description": "Sends a gift to the given user. The gift can't be converted to Telegram Stars by the user. Returns :code:`True` on success.", + "annotations": [ + { + "type": "Integer", + "required": true, + "description": "Unique identifier of the target user that will receive the gift", + "html_description": "Unique identifier of the target user that will receive the gift", + "rst_description": "Unique identifier of the target user that will receive the gift\n", + "name": "user_id" + }, + { + "type": "String", + "required": true, + "description": "Identifier of the gift", + "html_description": "Identifier of the gift", + "rst_description": "Identifier of the gift\n", + "name": "gift_id" + }, + { + "type": "String", + "required": false, + "description": "Text that will be shown along with the gift; 0-255 characters", + "html_description": "Text that will be shown along with the gift; 0-255 characters", + "rst_description": "Text that will be shown along with the gift; 0-255 characters\n", + "name": "text" + }, + { + "type": "String", + "required": false, + "description": "Mode for parsing entities in the text. See formatting options for more details. Entities other than 'bold', 'italic', 'underline', 'strikethrough', 'spoiler', and 'custom_emoji' are ignored.", + "html_description": "Mode for parsing entities in the text. See formatting options for more details. Entities other than “bold”, “italic”, “underline”, “strikethrough”, “spoiler”, and “custom_emoji” are ignored.", + "rst_description": "Mode for parsing entities in the text. See `formatting options `_ for more details. Entities other than 'bold', 'italic', 'underline', 'strikethrough', 'spoiler', and 'custom_emoji' are ignored.\n", + "name": "text_parse_mode" + }, + { + "type": "Array of MessageEntity", + "required": false, + "description": "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.", + "html_description": "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.", + "rst_description": "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.\n", + "name": "text_entities" + } + ], + "category": "methods" + } +} diff --git a/.butcher/methods/setUserEmojiStatus/entity.json b/.butcher/methods/setUserEmojiStatus/entity.json new file mode 100644 index 00000000..b7dd1ab6 --- /dev/null +++ b/.butcher/methods/setUserEmojiStatus/entity.json @@ -0,0 +1,41 @@ +{ + "meta": {}, + "group": { + "title": "Available methods", + "anchor": "available-methods" + }, + "object": { + "anchor": "setuseremojistatus", + "name": "setUserEmojiStatus", + "description": "Changes the emoji status for a given user that previously allowed the bot to manage their emoji status via the Mini App method requestEmojiStatusAccess. Returns True on success.", + "html_description": "

Changes the emoji status for a given user that previously allowed the bot to manage their emoji status via the Mini App method requestEmojiStatusAccess. Returns True on success.

", + "rst_description": "Changes the emoji status for a given user that previously allowed the bot to manage their emoji status via the Mini App method `requestEmojiStatusAccess `_. Returns :code:`True` on success.", + "annotations": [ + { + "type": "Integer", + "required": true, + "description": "Unique identifier of the target user", + "html_description": "Unique identifier of the target user", + "rst_description": "Unique identifier of the target user\n", + "name": "user_id" + }, + { + "type": "String", + "required": false, + "description": "Custom emoji identifier of the emoji status to set. Pass an empty string to remove the status.", + "html_description": "Custom emoji identifier of the emoji status to set. Pass an empty string to remove the status.", + "rst_description": "Custom emoji identifier of the emoji status to set. Pass an empty string to remove the status.\n", + "name": "emoji_status_custom_emoji_id" + }, + { + "type": "Integer", + "required": false, + "description": "Expiration date of the emoji status, if any", + "html_description": "Expiration date of the emoji status, if any", + "rst_description": "Expiration date of the emoji status, if any\n", + "name": "emoji_status_expiration_date" + } + ], + "category": "methods" + } +} diff --git a/.butcher/methods/setUserEmojiStatus/replace.yml b/.butcher/methods/setUserEmojiStatus/replace.yml new file mode 100644 index 00000000..0507a6df --- /dev/null +++ b/.butcher/methods/setUserEmojiStatus/replace.yml @@ -0,0 +1,11 @@ +annotations: + emoji_status_expiration_date: + parsed_type: + type: union + items: + - type: std + name: datetime.datetime + - type: std + name: datetime.timedelta + - type: std + name: int diff --git a/.butcher/schema/schema.json b/.butcher/schema/schema.json index e336e035..941ca6a4 100644 --- a/.butcher/schema/schema.json +++ b/.butcher/schema/schema.json @@ -1,7 +1,7 @@ { "api": { - "version": "7.11", - "release_date": "2024-10-31" + "version": "8.0", + "release_date": "2024-11-17" }, "items": [ { @@ -10122,6 +10122,40 @@ ], "category": "methods" }, + { + "anchor": "setuseremojistatus", + "name": "setUserEmojiStatus", + "description": "Changes the emoji status for a given user that previously allowed the bot to manage their emoji status via the Mini App method requestEmojiStatusAccess. Returns True on success.", + "html_description": "

Changes the emoji status for a given user that previously allowed the bot to manage their emoji status via the Mini App method requestEmojiStatusAccess. Returns True on success.

", + "rst_description": "Changes the emoji status for a given user that previously allowed the bot to manage their emoji status via the Mini App method `requestEmojiStatusAccess `_. Returns :code:`True` on success.", + "annotations": [ + { + "type": "Integer", + "required": true, + "description": "Unique identifier of the target user", + "html_description": "Unique identifier of the target user", + "rst_description": "Unique identifier of the target user\n", + "name": "user_id" + }, + { + "type": "String", + "required": false, + "description": "Custom emoji identifier of the emoji status to set. Pass an empty string to remove the status.", + "html_description": "Custom emoji identifier of the emoji status to set. Pass an empty string to remove the status.", + "rst_description": "Custom emoji identifier of the emoji status to set. Pass an empty string to remove the status.\n", + "name": "emoji_status_custom_emoji_id" + }, + { + "type": "Integer", + "required": false, + "description": "Expiration date of the emoji status, if any", + "html_description": "Expiration date of the emoji status, if any", + "rst_description": "Expiration date of the emoji status, if any\n", + "name": "emoji_status_expiration_date" + } + ], + "category": "methods" + }, { "anchor": "getfile", "name": "getFile", @@ -13192,6 +13226,133 @@ } ], "category": "methods" + }, + { + "anchor": "gift", + "name": "Gift", + "description": "This object represents a gift that can be sent by the bot.", + "html_description": "

This object represents a gift that can be sent by the bot.

", + "rst_description": "This object represents a gift that can be sent by the bot.", + "annotations": [ + { + "type": "String", + "description": "Unique identifier of the gift", + "html_description": "Unique identifier of the gift", + "rst_description": "Unique identifier of the gift\n", + "name": "id", + "required": true + }, + { + "type": "Sticker", + "description": "The sticker that represents the gift", + "html_description": "The sticker that represents the gift", + "rst_description": "The sticker that represents the gift\n", + "name": "sticker", + "required": true + }, + { + "type": "Integer", + "description": "The number of Telegram Stars that must be paid to send the sticker", + "html_description": "The number of Telegram Stars that must be paid to send the sticker", + "rst_description": "The number of Telegram Stars that must be paid to send the sticker\n", + "name": "star_count", + "required": true + }, + { + "type": "Integer", + "description": "The total number of the gifts of this type that can be sent; for limited gifts only", + "html_description": "Optional. The total number of the gifts of this type that can be sent; for limited gifts only", + "rst_description": "*Optional*. The total number of the gifts of this type that can be sent; for limited gifts only\n", + "name": "total_count", + "required": false + }, + { + "type": "Integer", + "description": "The number of remaining gifts of this type that can be sent; for limited gifts only", + "html_description": "Optional. The number of remaining gifts of this type that can be sent; for limited gifts only", + "rst_description": "*Optional*. The number of remaining gifts of this type that can be sent; for limited gifts only\n", + "name": "remaining_count", + "required": false + } + ], + "category": "types" + }, + { + "anchor": "gifts", + "name": "Gifts", + "description": "This object represent a list of gifts.", + "html_description": "

This object represent a list of gifts.

", + "rst_description": "This object represent a list of gifts.", + "annotations": [ + { + "type": "Array of Gift", + "description": "The list of gifts", + "html_description": "The list of gifts", + "rst_description": "The list of gifts\n", + "name": "gifts", + "required": true + } + ], + "category": "types" + }, + { + "anchor": "getavailablegifts", + "name": "getAvailableGifts", + "description": "Returns the list of gifts that can be sent by the bot to users. Requires no parameters. Returns a Gifts object.", + "html_description": "

Returns the list of gifts that can be sent by the bot to users. Requires no parameters. Returns a Gifts object.

", + "rst_description": "Returns the list of gifts that can be sent by the bot to users. Requires no parameters. Returns a :class:`aiogram.types.gifts.Gifts` object.", + "annotations": [], + "category": "methods" + }, + { + "anchor": "sendgift", + "name": "sendGift", + "description": "Sends a gift to the given user. The gift can't be converted to Telegram Stars by the user. Returns True on success.", + "html_description": "

Sends a gift to the given user. The gift can't be converted to Telegram Stars by the user. Returns True on success.

", + "rst_description": "Sends a gift to the given user. The gift can't be converted to Telegram Stars by the user. Returns :code:`True` on success.", + "annotations": [ + { + "type": "Integer", + "required": true, + "description": "Unique identifier of the target user that will receive the gift", + "html_description": "Unique identifier of the target user that will receive the gift", + "rst_description": "Unique identifier of the target user that will receive the gift\n", + "name": "user_id" + }, + { + "type": "String", + "required": true, + "description": "Identifier of the gift", + "html_description": "Identifier of the gift", + "rst_description": "Identifier of the gift\n", + "name": "gift_id" + }, + { + "type": "String", + "required": false, + "description": "Text that will be shown along with the gift; 0-255 characters", + "html_description": "Text that will be shown along with the gift; 0-255 characters", + "rst_description": "Text that will be shown along with the gift; 0-255 characters\n", + "name": "text" + }, + { + "type": "String", + "required": false, + "description": "Mode for parsing entities in the text. See formatting options for more details. Entities other than 'bold', 'italic', 'underline', 'strikethrough', 'spoiler', and 'custom_emoji' are ignored.", + "html_description": "Mode for parsing entities in the text. See formatting options for more details. Entities other than “bold”, “italic”, “underline”, “strikethrough”, “spoiler”, and “custom_emoji” are ignored.", + "rst_description": "Mode for parsing entities in the text. See `formatting options `_ for more details. Entities other than 'bold', 'italic', 'underline', 'strikethrough', 'spoiler', and 'custom_emoji' are ignored.\n", + "name": "text_parse_mode" + }, + { + "type": "Array of MessageEntity", + "required": false, + "description": "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.", + "html_description": "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.", + "rst_description": "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.\n", + "name": "text_entities" + } + ], + "category": "methods" } ], "description": "The following methods and objects allow your bot to handle stickers and sticker sets." @@ -15839,6 +16000,90 @@ } ], "category": "types" + }, + { + "anchor": "savepreparedinlinemessage", + "name": "savePreparedInlineMessage", + "description": "Stores a message that can be sent by a user of a Mini App. Returns a PreparedInlineMessage object.", + "html_description": "

Stores a message that can be sent by a user of a Mini App. Returns a PreparedInlineMessage object.

", + "rst_description": "Stores a message that can be sent by a user of a Mini App. Returns a :class:`aiogram.types.prepared_inline_message.PreparedInlineMessage` object.", + "annotations": [ + { + "type": "Integer", + "required": true, + "description": "Unique identifier of the target user that can use the prepared message", + "html_description": "Unique identifier of the target user that can use the prepared message", + "rst_description": "Unique identifier of the target user that can use the prepared message\n", + "name": "user_id" + }, + { + "type": "InlineQueryResult", + "required": true, + "description": "A JSON-serialized object describing the message to be sent", + "html_description": "A JSON-serialized object describing the message to be sent", + "rst_description": "A JSON-serialized object describing the message to be sent\n", + "name": "result" + }, + { + "type": "Boolean", + "required": false, + "description": "Pass True if the message can be sent to private chats with users", + "html_description": "Pass True if the message can be sent to private chats with users", + "rst_description": "Pass :code:`True` if the message can be sent to private chats with users\n", + "name": "allow_user_chats" + }, + { + "type": "Boolean", + "required": false, + "description": "Pass True if the message can be sent to private chats with bots", + "html_description": "Pass True if the message can be sent to private chats with bots", + "rst_description": "Pass :code:`True` if the message can be sent to private chats with bots\n", + "name": "allow_bot_chats" + }, + { + "type": "Boolean", + "required": false, + "description": "Pass True if the message can be sent to group and supergroup chats", + "html_description": "Pass True if the message can be sent to group and supergroup chats", + "rst_description": "Pass :code:`True` if the message can be sent to group and supergroup chats\n", + "name": "allow_group_chats" + }, + { + "type": "Boolean", + "required": false, + "description": "Pass True if the message can be sent to channel chats", + "html_description": "Pass True if the message can be sent to channel chats", + "rst_description": "Pass :code:`True` if the message can be sent to channel chats\n", + "name": "allow_channel_chats" + } + ], + "category": "methods" + }, + { + "anchor": "preparedinlinemessage", + "name": "PreparedInlineMessage", + "description": "Describes an inline message to be sent by a user of a Mini App.", + "html_description": "

Describes an inline message to be sent by a user of a Mini App.

", + "rst_description": "Describes an inline message to be sent by a user of a Mini App.", + "annotations": [ + { + "type": "String", + "description": "Unique identifier of the prepared message", + "html_description": "Unique identifier of the prepared message", + "rst_description": "Unique identifier of the prepared message\n", + "name": "id", + "required": true + }, + { + "type": "Integer", + "description": "Expiration date of the prepared message, in Unix time. Expired prepared messages can no longer be used", + "html_description": "Expiration date of the prepared message, in Unix time. Expired prepared messages can no longer be used", + "rst_description": "Expiration date of the prepared message, in Unix time. Expired prepared messages can no longer be used\n", + "name": "expiration_date", + "required": true + } + ], + "category": "types" } ], "description": "The following methods and objects allow your bot to work in inline mode.\nPlease see our Introduction to Inline bots for more details.\nTo enable this option, send the /setinline command to @BotFather and provide the placeholder text that the user will see in the input field after typing your bot's name." @@ -16096,6 +16341,14 @@ "html_description": "

Use this method to create a link for an invoice. Returns the created invoice link as String on success.

", "rst_description": "Use this method to create a link for an invoice. Returns the created invoice link as *String* on success.", "annotations": [ + { + "type": "String", + "required": false, + "description": "Unique identifier of the business connection on behalf of which the link will be created", + "html_description": "Unique identifier of the business connection on behalf of which the link will be created", + "rst_description": "Unique identifier of the business connection on behalf of which the link will be created\n", + "name": "business_connection_id" + }, { "type": "String", "required": true, @@ -16144,6 +16397,14 @@ "rst_description": "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 `_.\n", "name": "prices" }, + { + "type": "Integer", + "required": false, + "description": "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.", + "html_description": "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.", + "rst_description": "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.\n", + "name": "subscription_period" + }, { "type": "Integer", "required": false, @@ -16387,6 +16648,40 @@ ], "category": "methods" }, + { + "anchor": "edituserstarsubscription", + "name": "editUserStarSubscription", + "description": "Allows the bot to cancel or re-enable extension of a subscription paid in Telegram Stars. Returns True on success.", + "html_description": "

Allows the bot to cancel or re-enable extension of a subscription paid in Telegram Stars. Returns True on success.

", + "rst_description": "Allows the bot to cancel or re-enable extension of a subscription paid in Telegram Stars. Returns :code:`True` on success.", + "annotations": [ + { + "type": "Integer", + "required": true, + "description": "Identifier of the user whose subscription will be edited", + "html_description": "Identifier of the user whose subscription will be edited", + "rst_description": "Identifier of the user whose subscription will be edited\n", + "name": "user_id" + }, + { + "type": "String", + "required": true, + "description": "Telegram payment identifier for the subscription", + "html_description": "Telegram payment identifier for the subscription", + "rst_description": "Telegram payment identifier for the subscription\n", + "name": "telegram_payment_charge_id" + }, + { + "type": "Boolean", + "required": true, + "description": "Pass True to cancel extension of the user subscription; the subscription must be active up to the end of the current subscription period. Pass False to allow the user to re-enable a subscription that was previously canceled by the bot.", + "html_description": "Pass True to cancel extension of the user subscription; the subscription must be active up to the end of the current subscription period. Pass False to allow the user to re-enable a subscription that was previously canceled by the bot.", + "rst_description": "Pass :code:`True` to cancel extension of the user subscription; the subscription must be active up to the end of the current subscription period. Pass :code:`False` to allow the user to re-enable a subscription that was previously canceled by the bot.\n", + "name": "is_canceled" + } + ], + "category": "methods" + }, { "anchor": "labeledprice", "name": "LabeledPrice", @@ -16628,6 +16923,30 @@ "name": "invoice_payload", "required": true }, + { + "type": "Integer", + "description": "Expiration date of the subscription, in Unix time; for recurring payments only", + "html_description": "Optional. Expiration date of the subscription, in Unix time; for recurring payments only", + "rst_description": "*Optional*. Expiration date of the subscription, in Unix time; for recurring payments only\n", + "name": "subscription_expiration_date", + "required": false + }, + { + "type": "True", + "description": "True, if the payment is a recurring payment for a subscription", + "html_description": "Optional. True, if the payment is a recurring payment for a subscription", + "rst_description": "*Optional*. True, if the payment is a recurring payment for a subscription\n", + "name": "is_recurring", + "required": false + }, + { + "type": "True", + "description": "True, if the payment is the first payment for a subscription", + "html_description": "Optional. True, if the payment is the first payment for a subscription", + "rst_description": "*Optional*. True, if the payment is the first payment for a subscription\n", + "name": "is_first_recurring", + "required": false + }, { "type": "String", "description": "Identifier of the shipping option chosen by the user", @@ -16966,6 +17285,14 @@ "name": "invoice_payload", "required": false }, + { + "type": "Integer", + "description": "The duration of the paid subscription", + "html_description": "Optional. The duration of the paid subscription", + "rst_description": "*Optional*. The duration of the paid subscription\n", + "name": "subscription_period", + "required": false + }, { "type": "Array of PaidMedia", "description": "Information about the paid media bought by the user", @@ -16981,6 +17308,14 @@ "rst_description": "*Optional*. Bot-specified paid media payload\n", "name": "paid_media_payload", "required": false + }, + { + "type": "String", + "description": "The gift sent to the user by the bot", + "html_description": "Optional. The gift sent to the user by the bot", + "rst_description": "*Optional*. The gift sent to the user by the bot\n", + "name": "gift", + "required": false } ], "category": "types" diff --git a/.butcher/types/Gift/entity.json b/.butcher/types/Gift/entity.json new file mode 100644 index 00000000..ce7728d6 --- /dev/null +++ b/.butcher/types/Gift/entity.json @@ -0,0 +1,57 @@ +{ + "meta": {}, + "group": { + "title": "Stickers", + "anchor": "stickers" + }, + "object": { + "anchor": "gift", + "name": "Gift", + "description": "This object represents a gift that can be sent by the bot.", + "html_description": "

This object represents a gift that can be sent by the bot.

", + "rst_description": "This object represents a gift that can be sent by the bot.", + "annotations": [ + { + "type": "String", + "description": "Unique identifier of the gift", + "html_description": "Unique identifier of the gift", + "rst_description": "Unique identifier of the gift\n", + "name": "id", + "required": true + }, + { + "type": "Sticker", + "description": "The sticker that represents the gift", + "html_description": "The sticker that represents the gift", + "rst_description": "The sticker that represents the gift\n", + "name": "sticker", + "required": true + }, + { + "type": "Integer", + "description": "The number of Telegram Stars that must be paid to send the sticker", + "html_description": "The number of Telegram Stars that must be paid to send the sticker", + "rst_description": "The number of Telegram Stars that must be paid to send the sticker\n", + "name": "star_count", + "required": true + }, + { + "type": "Integer", + "description": "The total number of the gifts of this type that can be sent; for limited gifts only", + "html_description": "Optional. The total number of the gifts of this type that can be sent; for limited gifts only", + "rst_description": "*Optional*. The total number of the gifts of this type that can be sent; for limited gifts only\n", + "name": "total_count", + "required": false + }, + { + "type": "Integer", + "description": "The number of remaining gifts of this type that can be sent; for limited gifts only", + "html_description": "Optional. The number of remaining gifts of this type that can be sent; for limited gifts only", + "rst_description": "*Optional*. The number of remaining gifts of this type that can be sent; for limited gifts only\n", + "name": "remaining_count", + "required": false + } + ], + "category": "types" + } +} diff --git a/.butcher/types/Gifts/entity.json b/.butcher/types/Gifts/entity.json new file mode 100644 index 00000000..d8546b7c --- /dev/null +++ b/.butcher/types/Gifts/entity.json @@ -0,0 +1,25 @@ +{ + "meta": {}, + "group": { + "title": "Stickers", + "anchor": "stickers" + }, + "object": { + "anchor": "gifts", + "name": "Gifts", + "description": "This object represent a list of gifts.", + "html_description": "

This object represent a list of gifts.

", + "rst_description": "This object represent a list of gifts.", + "annotations": [ + { + "type": "Array of Gift", + "description": "The list of gifts", + "html_description": "The list of gifts", + "rst_description": "The list of gifts\n", + "name": "gifts", + "required": true + } + ], + "category": "types" + } +} diff --git a/.butcher/types/PreparedInlineMessage/entity.json b/.butcher/types/PreparedInlineMessage/entity.json new file mode 100644 index 00000000..39c0c493 --- /dev/null +++ b/.butcher/types/PreparedInlineMessage/entity.json @@ -0,0 +1,33 @@ +{ + "meta": {}, + "group": { + "title": "Inline mode", + "anchor": "inline-mode" + }, + "object": { + "anchor": "preparedinlinemessage", + "name": "PreparedInlineMessage", + "description": "Describes an inline message to be sent by a user of a Mini App.", + "html_description": "

Describes an inline message to be sent by a user of a Mini App.

", + "rst_description": "Describes an inline message to be sent by a user of a Mini App.", + "annotations": [ + { + "type": "String", + "description": "Unique identifier of the prepared message", + "html_description": "Unique identifier of the prepared message", + "rst_description": "Unique identifier of the prepared message\n", + "name": "id", + "required": true + }, + { + "type": "Integer", + "description": "Expiration date of the prepared message, in Unix time. Expired prepared messages can no longer be used", + "html_description": "Expiration date of the prepared message, in Unix time. Expired prepared messages can no longer be used", + "rst_description": "Expiration date of the prepared message, in Unix time. Expired prepared messages can no longer be used\n", + "name": "expiration_date", + "required": true + } + ], + "category": "types" + } +} diff --git a/.butcher/types/PreparedInlineMessage/replace.yml b/.butcher/types/PreparedInlineMessage/replace.yml new file mode 100644 index 00000000..3b8e5159 --- /dev/null +++ b/.butcher/types/PreparedInlineMessage/replace.yml @@ -0,0 +1,11 @@ +annotations: + expiration_date: + parsed_type: + type: union + items: + - type: std + name: datetime.datetime + - type: std + name: datetime.timedelta + - type: std + name: int diff --git a/.butcher/types/SuccessfulPayment/entity.json b/.butcher/types/SuccessfulPayment/entity.json index 4ae3510e..bb1fe445 100644 --- a/.butcher/types/SuccessfulPayment/entity.json +++ b/.butcher/types/SuccessfulPayment/entity.json @@ -35,6 +35,30 @@ "name": "invoice_payload", "required": true }, + { + "type": "Integer", + "description": "Expiration date of the subscription, in Unix time; for recurring payments only", + "html_description": "Optional. Expiration date of the subscription, in Unix time; for recurring payments only", + "rst_description": "*Optional*. Expiration date of the subscription, in Unix time; for recurring payments only\n", + "name": "subscription_expiration_date", + "required": false + }, + { + "type": "True", + "description": "True, if the payment is a recurring payment for a subscription", + "html_description": "Optional. True, if the payment is a recurring payment for a subscription", + "rst_description": "*Optional*. True, if the payment is a recurring payment for a subscription\n", + "name": "is_recurring", + "required": false + }, + { + "type": "True", + "description": "True, if the payment is the first payment for a subscription", + "html_description": "Optional. True, if the payment is the first payment for a subscription", + "rst_description": "*Optional*. True, if the payment is the first payment for a subscription\n", + "name": "is_first_recurring", + "required": false + }, { "type": "String", "description": "Identifier of the shipping option chosen by the user", diff --git a/.butcher/types/TransactionPartnerUser/entity.json b/.butcher/types/TransactionPartnerUser/entity.json index ee2e06ce..f8064da9 100644 --- a/.butcher/types/TransactionPartnerUser/entity.json +++ b/.butcher/types/TransactionPartnerUser/entity.json @@ -35,6 +35,14 @@ "name": "invoice_payload", "required": false }, + { + "type": "Integer", + "description": "The duration of the paid subscription", + "html_description": "Optional. The duration of the paid subscription", + "rst_description": "*Optional*. The duration of the paid subscription\n", + "name": "subscription_period", + "required": false + }, { "type": "Array of PaidMedia", "description": "Information about the paid media bought by the user", @@ -50,6 +58,14 @@ "rst_description": "*Optional*. Bot-specified paid media payload\n", "name": "paid_media_payload", "required": false + }, + { + "type": "String", + "description": "The gift sent to the user by the bot", + "html_description": "Optional. The gift sent to the user by the bot", + "rst_description": "*Optional*. The gift sent to the user by the bot\n", + "name": "gift", + "required": false } ], "category": "types" diff --git a/CHANGES/1606.feature.rst b/CHANGES/1606.feature.rst new file mode 100644 index 00000000..4bc1223e --- /dev/null +++ b/CHANGES/1606.feature.rst @@ -0,0 +1,25 @@ +Added full support for `Bot API 8.0 `_ + +- Added the parameter :code:`subscription_period` to the method + :class:`aiogram.methods.create_invoice_link.CreateInvoiceLink` + to support the creation of links that are billed periodically. +- Added the parameter :code:`business_connection_id` to the method + :class:`aiogram.methods.create_invoice_link.CreateInvoiceLink` + to support the creation of invoice links on behalf of business accounts. +- Added the fields :code:`subscription_expiration_date`, + :code:`is_recurring` and :code:`is_first_recurring` to the class + :class:`aiogram.types.successful_payment.SuccessfulPayment`. +- Added the method :class:`aiogram.methods.edit_user_star_subscription.EditUserStarSubscription`. +- Added the field :code:`subscription_period` to the class + :class:`aiogram.types.transaction_partner_user.TransactionPartnerUser`. +- Added the method :class:`aiogram.methods.set_user_emoji_status.SetUserEmojiStatus`. + The user must allow the bot to manage their emoji status. +- Added the class :class:`aiogram.types.prepared_inline_message.PreparedInlineMessage` + and the method :class:`aiogram.methods.save_prepared_inline_message.SavePreparedInlineMessage`, + allowing bots to suggest users send a specific message from a Mini App via the method + :class:`aiogram.methods.share_message.ShareMessage`. +- Added the classes :class:`aiogram.types.gift.Gift` and :class:`aiogram.types.gifts.Gifts` + and the method :class:`aiogram.methods.get_available_gifts.GetAvailableGifts`, + allowing bots to get all gifts available for sending. +- Added the field :code:`gift` to the class + :class:`aiogram.types.transaction_partner_user.TransactionPartnerUser`. diff --git a/README.rst b/README.rst index 8f57418c..acc48f8b 100644 --- a/README.rst +++ b/README.rst @@ -52,7 +52,7 @@ Features - Asynchronous (`asyncio docs `_, :pep:`492`) - Has type hints (:pep:`484`) and can be used with `mypy `_ - Supports `PyPy `_ -- Supports `Telegram Bot API 7.11 `_ and gets fast updates to the latest versions of the Bot API +- Supports `Telegram Bot API 8.0 `_ and gets fast updates to the latest versions of the Bot API - Telegram Bot API integration code was `autogenerated `_ and can be easily re-generated when API gets updated - Updates router (Blueprints) - Has Finite State Machine diff --git a/aiogram/__meta__.py b/aiogram/__meta__.py index 84135881..801b95eb 100644 --- a/aiogram/__meta__.py +++ b/aiogram/__meta__.py @@ -1,2 +1,2 @@ __version__ = "3.14.0" -__api_version__ = "7.11" +__api_version__ = "8.0" diff --git a/aiogram/client/bot.py b/aiogram/client/bot.py index fb4b348c..b538485f 100644 --- a/aiogram/client/bot.py +++ b/aiogram/client/bot.py @@ -60,9 +60,11 @@ from ..methods import ( EditMessageMedia, EditMessageReplyMarkup, EditMessageText, + EditUserStarSubscription, ExportChatInviteLink, ForwardMessage, ForwardMessages, + GetAvailableGifts, GetBusinessConnection, GetChat, GetChatAdministrators, @@ -96,6 +98,7 @@ from ..methods import ( ReplaceStickerInSet, RestrictChatMember, RevokeChatInviteLink, + SavePreparedInlineMessage, SendAnimation, SendAudio, SendChatAction, @@ -103,6 +106,7 @@ from ..methods import ( SendDice, SendDocument, SendGame, + SendGift, SendInvoice, SendLocation, SendMediaGroup, @@ -137,6 +141,7 @@ from ..methods import ( SetStickerPositionInSet, SetStickerSetThumbnail, SetStickerSetTitle, + SetUserEmojiStatus, SetWebhook, StopMessageLiveLocation, StopPoll, @@ -178,6 +183,7 @@ from ..types import ( ForceReply, ForumTopic, GameHighScore, + Gifts, InlineKeyboardMarkup, InlineQueryResultArticle, InlineQueryResultAudio, @@ -229,6 +235,7 @@ from ..types import ( PassportElementErrorTranslationFiles, PassportElementErrorUnspecified, Poll, + PreparedInlineMessage, ReactionTypeCustomEmoji, ReactionTypeEmoji, ReactionTypePaid, @@ -978,7 +985,9 @@ class Bot: payload: str, currency: str, prices: list[LabeledPrice], + business_connection_id: Optional[str] = None, provider_token: Optional[str] = None, + subscription_period: Optional[int] = None, max_tip_amount: Optional[int] = None, suggested_tip_amounts: Optional[list[int]] = None, provider_data: Optional[str] = None, @@ -1005,7 +1014,9 @@ class Bot: :param payload: Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use it for your internal processes. :param currency: Three-letter ISO 4217 currency code, see `more on currencies `_. Pass 'XTR' for payments in `Telegram Stars `_. :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 `_. + :param business_connection_id: Unique identifier of the business connection on behalf of which the link will be created :param provider_token: Payment provider token, obtained via `@BotFather `_. Pass an empty string for payments in `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. :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 `_, 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 `_. :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. @@ -1030,7 +1041,9 @@ class Bot: payload=payload, currency=currency, prices=prices, + business_connection_id=business_connection_id, provider_token=provider_token, + subscription_period=subscription_period, max_tip_amount=max_tip_amount, suggested_tip_amounts=suggested_tip_amounts, provider_data=provider_data, @@ -4820,3 +4833,161 @@ class Bot: name=name, ) return await self(call, request_timeout=request_timeout) + + async def edit_user_star_subscription( + self, + user_id: int, + telegram_payment_charge_id: str, + is_canceled: bool, + request_timeout: Optional[int] = None, + ) -> bool: + """ + Allows the bot to cancel or re-enable extension of a subscription paid in Telegram Stars. Returns :code:`True` on success. + + Source: https://core.telegram.org/bots/api#edituserstarsubscription + + :param user_id: Identifier of the user whose subscription will be edited + :param telegram_payment_charge_id: Telegram payment identifier for the subscription + :param is_canceled: Pass :code:`True` to cancel extension of the user subscription; the subscription must be active up to the end of the current subscription period. Pass :code:`False` to allow the user to re-enable a subscription that was previously canceled by the bot. + :param request_timeout: Request timeout + :return: Returns :code:`True` on success. + """ + + call = EditUserStarSubscription( + user_id=user_id, + telegram_payment_charge_id=telegram_payment_charge_id, + is_canceled=is_canceled, + ) + return await self(call, request_timeout=request_timeout) + + async def get_available_gifts( + self, + request_timeout: Optional[int] = None, + ) -> Gifts: + """ + Returns the list of gifts that can be sent by the bot to users. Requires no parameters. Returns a :class:`aiogram.types.gifts.Gifts` object. + + Source: https://core.telegram.org/bots/api#getavailablegifts + + :param request_timeout: Request timeout + :return: Returns a :class:`aiogram.types.gifts.Gifts` object. + """ + + call = GetAvailableGifts() + return await self(call, request_timeout=request_timeout) + + async def save_prepared_inline_message( + self, + user_id: int, + result: Union[ + InlineQueryResultCachedAudio, + InlineQueryResultCachedDocument, + InlineQueryResultCachedGif, + InlineQueryResultCachedMpeg4Gif, + InlineQueryResultCachedPhoto, + InlineQueryResultCachedSticker, + InlineQueryResultCachedVideo, + InlineQueryResultCachedVoice, + InlineQueryResultArticle, + InlineQueryResultAudio, + InlineQueryResultContact, + InlineQueryResultGame, + InlineQueryResultDocument, + InlineQueryResultGif, + InlineQueryResultLocation, + InlineQueryResultMpeg4Gif, + InlineQueryResultPhoto, + InlineQueryResultVenue, + InlineQueryResultVideo, + InlineQueryResultVoice, + ], + allow_user_chats: Optional[bool] = None, + allow_bot_chats: Optional[bool] = None, + allow_group_chats: Optional[bool] = None, + allow_channel_chats: Optional[bool] = None, + request_timeout: Optional[int] = None, + ) -> PreparedInlineMessage: + """ + Stores a message that can be sent by a user of a Mini App. Returns a :class:`aiogram.types.prepared_inline_message.PreparedInlineMessage` object. + + Source: https://core.telegram.org/bots/api#savepreparedinlinemessage + + :param user_id: Unique identifier of the target user that can use the prepared message + :param result: A JSON-serialized object describing the message to be sent + :param allow_user_chats: Pass :code:`True` if the message can be sent to private chats with users + :param allow_bot_chats: Pass :code:`True` if the message can be sent to private chats with bots + :param allow_group_chats: Pass :code:`True` if the message can be sent to group and supergroup chats + :param allow_channel_chats: Pass :code:`True` if the message can be sent to channel chats + :param request_timeout: Request timeout + :return: Returns a :class:`aiogram.types.prepared_inline_message.PreparedInlineMessage` object. + """ + + call = SavePreparedInlineMessage( + user_id=user_id, + result=result, + allow_user_chats=allow_user_chats, + allow_bot_chats=allow_bot_chats, + allow_group_chats=allow_group_chats, + allow_channel_chats=allow_channel_chats, + ) + return await self(call, request_timeout=request_timeout) + + async def send_gift( + self, + user_id: int, + gift_id: str, + text: Optional[str] = None, + text_parse_mode: Optional[str] = None, + text_entities: Optional[list[MessageEntity]] = None, + request_timeout: Optional[int] = None, + ) -> bool: + """ + Sends a gift to the given user. The gift can't be converted to Telegram Stars by the user. Returns :code:`True` on success. + + Source: https://core.telegram.org/bots/api#sendgift + + :param user_id: Unique identifier of the target user that will receive the gift + :param gift_id: Identifier of the gift + :param text: Text that will be shown along with the gift; 0-255 characters + :param text_parse_mode: Mode for parsing entities in the text. See `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 = SendGift( + user_id=user_id, + gift_id=gift_id, + text=text, + text_parse_mode=text_parse_mode, + text_entities=text_entities, + ) + return await self(call, request_timeout=request_timeout) + + async def set_user_emoji_status( + self, + user_id: int, + emoji_status_custom_emoji_id: Optional[str] = None, + emoji_status_expiration_date: Optional[ + Union[datetime.datetime, datetime.timedelta, int] + ] = None, + request_timeout: Optional[int] = None, + ) -> bool: + """ + Changes the emoji status for a given user that previously allowed the bot to manage their emoji status via the Mini App method `requestEmojiStatusAccess `_. Returns :code:`True` on success. + + Source: https://core.telegram.org/bots/api#setuseremojistatus + + :param user_id: Unique identifier of the target user + :param emoji_status_custom_emoji_id: Custom emoji identifier of the emoji status to set. Pass an empty string to remove the status. + :param emoji_status_expiration_date: Expiration date of the emoji status, if any + :param request_timeout: Request timeout + :return: Returns :code:`True` on success. + """ + + call = SetUserEmojiStatus( + user_id=user_id, + emoji_status_custom_emoji_id=emoji_status_custom_emoji_id, + emoji_status_expiration_date=emoji_status_expiration_date, + ) + return await self(call, request_timeout=request_timeout) diff --git a/aiogram/methods/__init__.py b/aiogram/methods/__init__.py index 66214ac6..893f4f73 100644 --- a/aiogram/methods/__init__.py +++ b/aiogram/methods/__init__.py @@ -37,9 +37,11 @@ from .edit_message_live_location import EditMessageLiveLocation from .edit_message_media import EditMessageMedia from .edit_message_reply_markup import EditMessageReplyMarkup from .edit_message_text import EditMessageText +from .edit_user_star_subscription import EditUserStarSubscription from .export_chat_invite_link import ExportChatInviteLink from .forward_message import ForwardMessage from .forward_messages import ForwardMessages +from .get_available_gifts import GetAvailableGifts from .get_business_connection import GetBusinessConnection from .get_chat import GetChat from .get_chat_administrators import GetChatAdministrators @@ -73,6 +75,7 @@ from .reopen_general_forum_topic import ReopenGeneralForumTopic from .replace_sticker_in_set import ReplaceStickerInSet from .restrict_chat_member import RestrictChatMember from .revoke_chat_invite_link import RevokeChatInviteLink +from .save_prepared_inline_message import SavePreparedInlineMessage from .send_animation import SendAnimation from .send_audio import SendAudio from .send_chat_action import SendChatAction @@ -80,6 +83,7 @@ from .send_contact import SendContact from .send_dice import SendDice from .send_document import SendDocument from .send_game import SendGame +from .send_gift import SendGift from .send_invoice import SendInvoice from .send_location import SendLocation from .send_media_group import SendMediaGroup @@ -114,6 +118,7 @@ from .set_sticker_mask_position import SetStickerMaskPosition from .set_sticker_position_in_set import SetStickerPositionInSet from .set_sticker_set_thumbnail import SetStickerSetThumbnail from .set_sticker_set_title import SetStickerSetTitle +from .set_user_emoji_status import SetUserEmojiStatus from .set_webhook import SetWebhook from .stop_message_live_location import StopMessageLiveLocation from .stop_poll import StopPoll @@ -165,9 +170,11 @@ __all__ = ( "EditMessageMedia", "EditMessageReplyMarkup", "EditMessageText", + "EditUserStarSubscription", "ExportChatInviteLink", "ForwardMessage", "ForwardMessages", + "GetAvailableGifts", "GetBusinessConnection", "GetChat", "GetChatAdministrators", @@ -203,6 +210,7 @@ __all__ = ( "Response", "RestrictChatMember", "RevokeChatInviteLink", + "SavePreparedInlineMessage", "SendAnimation", "SendAudio", "SendChatAction", @@ -210,6 +218,7 @@ __all__ = ( "SendDice", "SendDocument", "SendGame", + "SendGift", "SendInvoice", "SendLocation", "SendMediaGroup", @@ -244,6 +253,7 @@ __all__ = ( "SetStickerPositionInSet", "SetStickerSetThumbnail", "SetStickerSetTitle", + "SetUserEmojiStatus", "SetWebhook", "StopMessageLiveLocation", "StopPoll", diff --git a/aiogram/methods/create_invoice_link.py b/aiogram/methods/create_invoice_link.py index 4e58df8d..0c17aac2 100644 --- a/aiogram/methods/create_invoice_link.py +++ b/aiogram/methods/create_invoice_link.py @@ -26,8 +26,12 @@ class CreateInvoiceLink(TelegramMethod[str]): """Three-letter ISO 4217 currency code, see `more on currencies `_. Pass 'XTR' for payments in `Telegram Stars `_.""" prices: list[LabeledPrice] """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 `_.""" + business_connection_id: Optional[str] = None + """Unique identifier of the business connection on behalf of which the link will be created""" provider_token: Optional[str] = None """Payment provider token, obtained via `@BotFather `_. Pass an empty string for payments in `Telegram Stars `_.""" + subscription_period: Optional[int] = None + """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.""" max_tip_amount: Optional[int] = None """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 `_, 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 `_.""" suggested_tip_amounts: Optional[list[int]] = None @@ -69,7 +73,9 @@ class CreateInvoiceLink(TelegramMethod[str]): payload: str, currency: str, prices: list[LabeledPrice], + business_connection_id: Optional[str] = None, provider_token: Optional[str] = None, + subscription_period: Optional[int] = None, max_tip_amount: Optional[int] = None, suggested_tip_amounts: Optional[list[int]] = None, provider_data: Optional[str] = None, @@ -96,7 +102,9 @@ class CreateInvoiceLink(TelegramMethod[str]): payload=payload, currency=currency, prices=prices, + business_connection_id=business_connection_id, provider_token=provider_token, + subscription_period=subscription_period, max_tip_amount=max_tip_amount, suggested_tip_amounts=suggested_tip_amounts, provider_data=provider_data, diff --git a/aiogram/methods/edit_message_text.py b/aiogram/methods/edit_message_text.py index 6feb9bc5..8b067ccb 100644 --- a/aiogram/methods/edit_message_text.py +++ b/aiogram/methods/edit_message_text.py @@ -1,17 +1,11 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Any, List, Optional, Union +from typing import TYPE_CHECKING, Any, Optional, Union from pydantic import Field from ..client.default import Default -from ..types import ( - UNSET_PARSE_MODE, - InlineKeyboardMarkup, - LinkPreviewOptions, - Message, - MessageEntity, -) +from ..types import InlineKeyboardMarkup, LinkPreviewOptions, Message, MessageEntity from .base import TelegramMethod diff --git a/aiogram/methods/edit_user_star_subscription.py b/aiogram/methods/edit_user_star_subscription.py new file mode 100644 index 00000000..fc97f730 --- /dev/null +++ b/aiogram/methods/edit_user_star_subscription.py @@ -0,0 +1,46 @@ +from __future__ import annotations + +from typing import TYPE_CHECKING, Any + +from .base import TelegramMethod + + +class EditUserStarSubscription(TelegramMethod[bool]): + """ + Allows the bot to cancel or re-enable extension of a subscription paid in Telegram Stars. Returns :code:`True` on success. + + Source: https://core.telegram.org/bots/api#edituserstarsubscription + """ + + __returning__ = bool + __api_method__ = "editUserStarSubscription" + + user_id: int + """Identifier of the user whose subscription will be edited""" + telegram_payment_charge_id: str + """Telegram payment identifier for the subscription""" + is_canceled: bool + """Pass :code:`True` to cancel extension of the user subscription; the subscription must be active up to the end of the current subscription period. Pass :code:`False` to allow the user to re-enable a subscription that was previously canceled by the bot.""" + + if TYPE_CHECKING: + # DO NOT EDIT MANUALLY!!! + # This section was auto-generated via `butcher` + + def __init__( + __pydantic__self__, + *, + user_id: int, + telegram_payment_charge_id: str, + is_canceled: bool, + **__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__( + user_id=user_id, + telegram_payment_charge_id=telegram_payment_charge_id, + is_canceled=is_canceled, + **__pydantic_kwargs, + ) diff --git a/aiogram/methods/get_available_gifts.py b/aiogram/methods/get_available_gifts.py new file mode 100644 index 00000000..91290140 --- /dev/null +++ b/aiogram/methods/get_available_gifts.py @@ -0,0 +1,15 @@ +from __future__ import annotations + +from ..types.gifts import Gifts +from .base import TelegramMethod + + +class GetAvailableGifts(TelegramMethod[Gifts]): + """ + Returns the list of gifts that can be sent by the bot to users. Requires no parameters. Returns a :class:`aiogram.types.gifts.Gifts` object. + + Source: https://core.telegram.org/bots/api#getavailablegifts + """ + + __returning__ = Gifts + __api_method__ = "getAvailableGifts" diff --git a/aiogram/methods/save_prepared_inline_message.py b/aiogram/methods/save_prepared_inline_message.py new file mode 100644 index 00000000..07b53e34 --- /dev/null +++ b/aiogram/methods/save_prepared_inline_message.py @@ -0,0 +1,121 @@ +from __future__ import annotations + +from typing import TYPE_CHECKING, Any, Optional, Union + +from ..types.inline_query_result_article import InlineQueryResultArticle +from ..types.inline_query_result_audio import InlineQueryResultAudio +from ..types.inline_query_result_cached_audio import InlineQueryResultCachedAudio +from ..types.inline_query_result_cached_document import InlineQueryResultCachedDocument +from ..types.inline_query_result_cached_gif import InlineQueryResultCachedGif +from ..types.inline_query_result_cached_mpeg4_gif import InlineQueryResultCachedMpeg4Gif +from ..types.inline_query_result_cached_photo import InlineQueryResultCachedPhoto +from ..types.inline_query_result_cached_sticker import InlineQueryResultCachedSticker +from ..types.inline_query_result_cached_video import InlineQueryResultCachedVideo +from ..types.inline_query_result_cached_voice import InlineQueryResultCachedVoice +from ..types.inline_query_result_contact import InlineQueryResultContact +from ..types.inline_query_result_document import InlineQueryResultDocument +from ..types.inline_query_result_game import InlineQueryResultGame +from ..types.inline_query_result_gif import InlineQueryResultGif +from ..types.inline_query_result_location import InlineQueryResultLocation +from ..types.inline_query_result_mpeg4_gif import InlineQueryResultMpeg4Gif +from ..types.inline_query_result_photo import InlineQueryResultPhoto +from ..types.inline_query_result_venue import InlineQueryResultVenue +from ..types.inline_query_result_video import InlineQueryResultVideo +from ..types.inline_query_result_voice import InlineQueryResultVoice +from ..types.prepared_inline_message import PreparedInlineMessage +from .base import TelegramMethod + + +class SavePreparedInlineMessage(TelegramMethod[PreparedInlineMessage]): + """ + Stores a message that can be sent by a user of a Mini App. Returns a :class:`aiogram.types.prepared_inline_message.PreparedInlineMessage` object. + + Source: https://core.telegram.org/bots/api#savepreparedinlinemessage + """ + + __returning__ = PreparedInlineMessage + __api_method__ = "savePreparedInlineMessage" + + user_id: int + """Unique identifier of the target user that can use the prepared message""" + result: Union[ + InlineQueryResultCachedAudio, + InlineQueryResultCachedDocument, + InlineQueryResultCachedGif, + InlineQueryResultCachedMpeg4Gif, + InlineQueryResultCachedPhoto, + InlineQueryResultCachedSticker, + InlineQueryResultCachedVideo, + InlineQueryResultCachedVoice, + InlineQueryResultArticle, + InlineQueryResultAudio, + InlineQueryResultContact, + InlineQueryResultGame, + InlineQueryResultDocument, + InlineQueryResultGif, + InlineQueryResultLocation, + InlineQueryResultMpeg4Gif, + InlineQueryResultPhoto, + InlineQueryResultVenue, + InlineQueryResultVideo, + InlineQueryResultVoice, + ] + """A JSON-serialized object describing the message to be sent""" + allow_user_chats: Optional[bool] = None + """Pass :code:`True` if the message can be sent to private chats with users""" + allow_bot_chats: Optional[bool] = None + """Pass :code:`True` if the message can be sent to private chats with bots""" + allow_group_chats: Optional[bool] = None + """Pass :code:`True` if the message can be sent to group and supergroup chats""" + allow_channel_chats: Optional[bool] = None + """Pass :code:`True` if the message can be sent to channel chats""" + + if TYPE_CHECKING: + # DO NOT EDIT MANUALLY!!! + # This section was auto-generated via `butcher` + + def __init__( + __pydantic__self__, + *, + user_id: int, + result: Union[ + InlineQueryResultCachedAudio, + InlineQueryResultCachedDocument, + InlineQueryResultCachedGif, + InlineQueryResultCachedMpeg4Gif, + InlineQueryResultCachedPhoto, + InlineQueryResultCachedSticker, + InlineQueryResultCachedVideo, + InlineQueryResultCachedVoice, + InlineQueryResultArticle, + InlineQueryResultAudio, + InlineQueryResultContact, + InlineQueryResultGame, + InlineQueryResultDocument, + InlineQueryResultGif, + InlineQueryResultLocation, + InlineQueryResultMpeg4Gif, + InlineQueryResultPhoto, + InlineQueryResultVenue, + InlineQueryResultVideo, + InlineQueryResultVoice, + ], + allow_user_chats: Optional[bool] = None, + allow_bot_chats: Optional[bool] = None, + allow_group_chats: Optional[bool] = None, + allow_channel_chats: 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__( + user_id=user_id, + result=result, + allow_user_chats=allow_user_chats, + allow_bot_chats=allow_bot_chats, + allow_group_chats=allow_group_chats, + allow_channel_chats=allow_channel_chats, + **__pydantic_kwargs, + ) diff --git a/aiogram/methods/send_gift.py b/aiogram/methods/send_gift.py new file mode 100644 index 00000000..a07e9f45 --- /dev/null +++ b/aiogram/methods/send_gift.py @@ -0,0 +1,55 @@ +from __future__ import annotations + +from typing import TYPE_CHECKING, Any, Optional + +from ..types.message_entity import MessageEntity +from .base import TelegramMethod + + +class SendGift(TelegramMethod[bool]): + """ + Sends a gift to the given user. The gift can't be converted to Telegram Stars by the user. Returns :code:`True` on success. + + Source: https://core.telegram.org/bots/api#sendgift + """ + + __returning__ = bool + __api_method__ = "sendGift" + + user_id: int + """Unique identifier of the target user that will receive the gift""" + gift_id: str + """Identifier of the gift""" + text: Optional[str] = None + """Text that will be shown along with the gift; 0-255 characters""" + text_parse_mode: Optional[str] = None + """Mode for parsing entities in the text. See `formatting options `_ for more details. Entities other than 'bold', 'italic', 'underline', 'strikethrough', 'spoiler', and 'custom_emoji' are ignored.""" + text_entities: Optional[list[MessageEntity]] = None + """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.""" + + if TYPE_CHECKING: + # DO NOT EDIT MANUALLY!!! + # This section was auto-generated via `butcher` + + def __init__( + __pydantic__self__, + *, + user_id: int, + gift_id: str, + text: Optional[str] = None, + text_parse_mode: Optional[str] = None, + text_entities: Optional[list[MessageEntity]] = 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__( + user_id=user_id, + gift_id=gift_id, + text=text, + text_parse_mode=text_parse_mode, + text_entities=text_entities, + **__pydantic_kwargs, + ) diff --git a/aiogram/methods/set_user_emoji_status.py b/aiogram/methods/set_user_emoji_status.py new file mode 100644 index 00000000..216ec787 --- /dev/null +++ b/aiogram/methods/set_user_emoji_status.py @@ -0,0 +1,51 @@ +from __future__ import annotations + +import datetime +from typing import TYPE_CHECKING, Any, Optional, Union + +from .base import TelegramMethod + + +class SetUserEmojiStatus(TelegramMethod[bool]): + """ + Changes the emoji status for a given user that previously allowed the bot to manage their emoji status via the Mini App method `requestEmojiStatusAccess `_. Returns :code:`True` on success. + + Source: https://core.telegram.org/bots/api#setuseremojistatus + """ + + __returning__ = bool + __api_method__ = "setUserEmojiStatus" + + user_id: int + """Unique identifier of the target user""" + emoji_status_custom_emoji_id: Optional[str] = None + """Custom emoji identifier of the emoji status to set. Pass an empty string to remove the status.""" + emoji_status_expiration_date: Optional[Union[datetime.datetime, datetime.timedelta, int]] = ( + None + ) + """Expiration date of the emoji status, if any""" + + if TYPE_CHECKING: + # DO NOT EDIT MANUALLY!!! + # This section was auto-generated via `butcher` + + def __init__( + __pydantic__self__, + *, + user_id: int, + emoji_status_custom_emoji_id: Optional[str] = None, + emoji_status_expiration_date: Optional[ + Union[datetime.datetime, datetime.timedelta, 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__( + user_id=user_id, + emoji_status_custom_emoji_id=emoji_status_custom_emoji_id, + emoji_status_expiration_date=emoji_status_expiration_date, + **__pydantic_kwargs, + ) diff --git a/aiogram/types/__init__.py b/aiogram/types/__init__.py index 414dc2a0..18632627 100644 --- a/aiogram/types/__init__.py +++ b/aiogram/types/__init__.py @@ -83,6 +83,8 @@ from .game import Game from .game_high_score import GameHighScore from .general_forum_topic_hidden import GeneralForumTopicHidden from .general_forum_topic_unhidden import GeneralForumTopicUnhidden +from .gift import Gift +from .gifts import Gifts from .giveaway import Giveaway from .giveaway_completed import GiveawayCompleted from .giveaway_created import GiveawayCreated @@ -184,6 +186,7 @@ from .poll import Poll from .poll_answer import PollAnswer from .poll_option import PollOption from .pre_checkout_query import PreCheckoutQuery +from .prepared_inline_message import PreparedInlineMessage from .proximity_alert_triggered import ProximityAlertTriggered from .reaction_count import ReactionCount from .reaction_type import ReactionType @@ -321,6 +324,8 @@ __all__ = ( "GameHighScore", "GeneralForumTopicHidden", "GeneralForumTopicUnhidden", + "Gift", + "Gifts", "Giveaway", "GiveawayCompleted", "GiveawayCreated", @@ -420,6 +425,7 @@ __all__ = ( "PollAnswer", "PollOption", "PreCheckoutQuery", + "PreparedInlineMessage", "ProximityAlertTriggered", "ReactionCount", "ReactionType", diff --git a/aiogram/types/gift.py b/aiogram/types/gift.py new file mode 100644 index 00000000..e25eb3ec --- /dev/null +++ b/aiogram/types/gift.py @@ -0,0 +1,54 @@ +from __future__ import annotations + +from typing import TYPE_CHECKING, Any, Optional + +from .base import TelegramObject + +if TYPE_CHECKING: + from .sticker import Sticker + + +class Gift(TelegramObject): + """ + This object represents a gift that can be sent by the bot. + + Source: https://core.telegram.org/bots/api#gift + """ + + id: str + """Unique identifier of the gift""" + sticker: Sticker + """The sticker that represents the gift""" + star_count: int + """The number of Telegram Stars that must be paid to send the sticker""" + total_count: Optional[int] = None + """*Optional*. The total number of the gifts of this type that can be sent; for limited gifts only""" + remaining_count: Optional[int] = None + """*Optional*. The number of remaining gifts of this type that can be sent; for limited gifts only""" + + if TYPE_CHECKING: + # DO NOT EDIT MANUALLY!!! + # This section was auto-generated via `butcher` + + def __init__( + __pydantic__self__, + *, + id: str, + sticker: Sticker, + star_count: int, + total_count: Optional[int] = None, + remaining_count: 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__( + id=id, + sticker=sticker, + star_count=star_count, + total_count=total_count, + remaining_count=remaining_count, + **__pydantic_kwargs, + ) diff --git a/aiogram/types/gifts.py b/aiogram/types/gifts.py new file mode 100644 index 00000000..990d27ab --- /dev/null +++ b/aiogram/types/gifts.py @@ -0,0 +1,30 @@ +from __future__ import annotations + +from typing import TYPE_CHECKING, Any + +from .base import TelegramObject + +if TYPE_CHECKING: + from .gift import Gift + + +class Gifts(TelegramObject): + """ + This object represent a list of gifts. + + Source: https://core.telegram.org/bots/api#gifts + """ + + gifts: list[Gift] + """The list of gifts""" + + if TYPE_CHECKING: + # DO NOT EDIT MANUALLY!!! + # This section was auto-generated via `butcher` + + def __init__(__pydantic__self__, *, gifts: list[Gift], **__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__(gifts=gifts, **__pydantic_kwargs) diff --git a/aiogram/types/inline_query_result_cached_audio.py b/aiogram/types/inline_query_result_cached_audio.py index e6137d69..40ee181d 100644 --- a/aiogram/types/inline_query_result_cached_audio.py +++ b/aiogram/types/inline_query_result_cached_audio.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Any, List, Literal, Optional, Union +from typing import TYPE_CHECKING, Any, Literal, Optional, Union from ..client.default import Default from ..enums import InlineQueryResultType diff --git a/aiogram/types/inline_query_result_cached_photo.py b/aiogram/types/inline_query_result_cached_photo.py index 6f40806e..c67a5c0e 100644 --- a/aiogram/types/inline_query_result_cached_photo.py +++ b/aiogram/types/inline_query_result_cached_photo.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Any, List, Literal, Optional, Union +from typing import TYPE_CHECKING, Any, Literal, Optional, Union from ..client.default import Default from ..enums import InlineQueryResultType diff --git a/aiogram/types/input_poll_option.py b/aiogram/types/input_poll_option.py index fc751ae9..e856ef52 100644 --- a/aiogram/types/input_poll_option.py +++ b/aiogram/types/input_poll_option.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Any, List, Optional, Union +from typing import TYPE_CHECKING, Any, Optional, Union from ..client.default import Default from .base import TelegramObject diff --git a/aiogram/types/prepared_inline_message.py b/aiogram/types/prepared_inline_message.py new file mode 100644 index 00000000..3d91f5fe --- /dev/null +++ b/aiogram/types/prepared_inline_message.py @@ -0,0 +1,36 @@ +from __future__ import annotations + +import datetime +from typing import TYPE_CHECKING, Any, Union + +from .base import TelegramObject + + +class PreparedInlineMessage(TelegramObject): + """ + Describes an inline message to be sent by a user of a Mini App. + + Source: https://core.telegram.org/bots/api#preparedinlinemessage + """ + + id: str + """Unique identifier of the prepared message""" + expiration_date: Union[datetime.datetime, datetime.timedelta, int] + """Expiration date of the prepared message, in Unix time. Expired prepared messages can no longer be used""" + + if TYPE_CHECKING: + # DO NOT EDIT MANUALLY!!! + # This section was auto-generated via `butcher` + + def __init__( + __pydantic__self__, + *, + id: str, + expiration_date: Union[datetime.datetime, datetime.timedelta, int], + **__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__(id=id, expiration_date=expiration_date, **__pydantic_kwargs) diff --git a/aiogram/types/star_transactions.py b/aiogram/types/star_transactions.py index 372730c7..b0039f4e 100644 --- a/aiogram/types/star_transactions.py +++ b/aiogram/types/star_transactions.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Any, List +from typing import TYPE_CHECKING, Any from .base import TelegramObject diff --git a/aiogram/types/successful_payment.py b/aiogram/types/successful_payment.py index 30d43561..c66f01df 100644 --- a/aiogram/types/successful_payment.py +++ b/aiogram/types/successful_payment.py @@ -25,6 +25,12 @@ class SuccessfulPayment(TelegramObject): """Telegram payment identifier""" provider_payment_charge_id: str """Provider payment identifier""" + subscription_expiration_date: Optional[int] = None + """*Optional*. Expiration date of the subscription, in Unix time; for recurring payments only""" + is_recurring: Optional[bool] = None + """*Optional*. True, if the payment is a recurring payment for a subscription""" + is_first_recurring: Optional[bool] = None + """*Optional*. True, if the payment is the first payment for a subscription""" shipping_option_id: Optional[str] = None """*Optional*. Identifier of the shipping option chosen by the user""" order_info: Optional[OrderInfo] = None @@ -42,6 +48,9 @@ class SuccessfulPayment(TelegramObject): invoice_payload: str, telegram_payment_charge_id: str, provider_payment_charge_id: str, + subscription_expiration_date: Optional[int] = None, + is_recurring: Optional[bool] = None, + is_first_recurring: Optional[bool] = None, shipping_option_id: Optional[str] = None, order_info: Optional[OrderInfo] = None, **__pydantic_kwargs: Any, @@ -56,6 +65,9 @@ class SuccessfulPayment(TelegramObject): invoice_payload=invoice_payload, telegram_payment_charge_id=telegram_payment_charge_id, provider_payment_charge_id=provider_payment_charge_id, + subscription_expiration_date=subscription_expiration_date, + is_recurring=is_recurring, + is_first_recurring=is_first_recurring, shipping_option_id=shipping_option_id, order_info=order_info, **__pydantic_kwargs, diff --git a/aiogram/types/transaction_partner_user.py b/aiogram/types/transaction_partner_user.py index d3ac5dc1..fbb47864 100644 --- a/aiogram/types/transaction_partner_user.py +++ b/aiogram/types/transaction_partner_user.py @@ -25,10 +25,14 @@ class TransactionPartnerUser(TransactionPartner): """Information about the user""" invoice_payload: Optional[str] = None """*Optional*. Bot-specified invoice payload""" + subscription_period: Optional[int] = None + """*Optional*. The duration of the paid subscription""" paid_media: Optional[list[Union[PaidMediaPreview, PaidMediaPhoto, PaidMediaVideo]]] = None """*Optional*. Information about the paid media bought by the user""" paid_media_payload: Optional[str] = None """*Optional*. Bot-specified paid media payload""" + gift: Optional[str] = None + """*Optional*. The gift sent to the user by the bot""" if TYPE_CHECKING: # DO NOT EDIT MANUALLY!!! @@ -40,10 +44,12 @@ class TransactionPartnerUser(TransactionPartner): type: Literal[TransactionPartnerType.USER] = TransactionPartnerType.USER, user: User, invoice_payload: Optional[str] = None, + subscription_period: Optional[int] = None, paid_media: Optional[ list[Union[PaidMediaPreview, PaidMediaPhoto, PaidMediaVideo]] ] = None, paid_media_payload: Optional[str] = None, + gift: Optional[str] = None, **__pydantic_kwargs: Any, ) -> None: # DO NOT EDIT MANUALLY!!! @@ -54,7 +60,9 @@ class TransactionPartnerUser(TransactionPartner): type=type, user=user, invoice_payload=invoice_payload, + subscription_period=subscription_period, paid_media=paid_media, paid_media_payload=paid_media_payload, + gift=gift, **__pydantic_kwargs, ) diff --git a/aiogram/types/video_chat_participants_invited.py b/aiogram/types/video_chat_participants_invited.py index 551b7e5b..31c0d77a 100644 --- a/aiogram/types/video_chat_participants_invited.py +++ b/aiogram/types/video_chat_participants_invited.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Any, List +from typing import TYPE_CHECKING, Any from .base import TelegramObject diff --git a/docs/api/methods/edit_user_star_subscription.rst b/docs/api/methods/edit_user_star_subscription.rst new file mode 100644 index 00000000..7c9b5400 --- /dev/null +++ b/docs/api/methods/edit_user_star_subscription.rst @@ -0,0 +1,45 @@ +######################## +editUserStarSubscription +######################## + +Returns: :obj:`bool` + +.. automodule:: aiogram.methods.edit_user_star_subscription + :members: + :member-order: bysource + :undoc-members: True + :exclude-members: model_config,model_fields + + +Usage +===== + +As bot method +------------- + +.. code-block:: + + result: bool = await bot.edit_user_star_subscription(...) + + +Method as object +---------------- + +Imports: + +- :code:`from aiogram.methods.edit_user_star_subscription import EditUserStarSubscription` +- alias: :code:`from aiogram.methods import EditUserStarSubscription` + +With specific bot +~~~~~~~~~~~~~~~~~ + +.. code-block:: python + + result: bool = await bot(EditUserStarSubscription(...)) + +As reply into Webhook in handler +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. code-block:: python + + return EditUserStarSubscription(...) diff --git a/docs/api/methods/get_available_gifts.rst b/docs/api/methods/get_available_gifts.rst new file mode 100644 index 00000000..a6fddae7 --- /dev/null +++ b/docs/api/methods/get_available_gifts.rst @@ -0,0 +1,38 @@ +################# +getAvailableGifts +################# + +Returns: :obj:`Gifts` + +.. automodule:: aiogram.methods.get_available_gifts + :members: + :member-order: bysource + :undoc-members: True + :exclude-members: model_config,model_fields + + +Usage +===== + +As bot method +------------- + +.. code-block:: + + result: Gifts = await bot.get_available_gifts(...) + + +Method as object +---------------- + +Imports: + +- :code:`from aiogram.methods.get_available_gifts import GetAvailableGifts` +- alias: :code:`from aiogram.methods import GetAvailableGifts` + +With specific bot +~~~~~~~~~~~~~~~~~ + +.. code-block:: python + + result: Gifts = await bot(GetAvailableGifts(...)) diff --git a/docs/api/methods/index.rst b/docs/api/methods/index.rst index 6278f342..8030927b 100644 --- a/docs/api/methods/index.rst +++ b/docs/api/methods/index.rst @@ -15,9 +15,11 @@ Stickers create_new_sticker_set delete_sticker_from_set delete_sticker_set + get_available_gifts get_custom_emoji_stickers get_sticker_set replace_sticker_in_set + send_gift send_sticker set_custom_emoji_sticker_set_thumbnail set_sticker_emoji_list @@ -112,6 +114,7 @@ Available methods set_my_description set_my_name set_my_short_description + set_user_emoji_status unban_chat_member unban_chat_sender_chat unhide_general_forum_topic @@ -144,6 +147,7 @@ Inline mode answer_inline_query answer_web_app_query + save_prepared_inline_message Games ===== @@ -164,6 +168,7 @@ Payments answer_pre_checkout_query answer_shipping_query create_invoice_link + edit_user_star_subscription get_star_transactions refund_star_payment send_invoice diff --git a/docs/api/methods/save_prepared_inline_message.rst b/docs/api/methods/save_prepared_inline_message.rst new file mode 100644 index 00000000..143fa6da --- /dev/null +++ b/docs/api/methods/save_prepared_inline_message.rst @@ -0,0 +1,45 @@ +######################### +savePreparedInlineMessage +######################### + +Returns: :obj:`PreparedInlineMessage` + +.. automodule:: aiogram.methods.save_prepared_inline_message + :members: + :member-order: bysource + :undoc-members: True + :exclude-members: model_config,model_fields + + +Usage +===== + +As bot method +------------- + +.. code-block:: + + result: PreparedInlineMessage = await bot.save_prepared_inline_message(...) + + +Method as object +---------------- + +Imports: + +- :code:`from aiogram.methods.save_prepared_inline_message import SavePreparedInlineMessage` +- alias: :code:`from aiogram.methods import SavePreparedInlineMessage` + +With specific bot +~~~~~~~~~~~~~~~~~ + +.. code-block:: python + + result: PreparedInlineMessage = await bot(SavePreparedInlineMessage(...)) + +As reply into Webhook in handler +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. code-block:: python + + return SavePreparedInlineMessage(...) diff --git a/docs/api/methods/send_gift.rst b/docs/api/methods/send_gift.rst new file mode 100644 index 00000000..fa53c274 --- /dev/null +++ b/docs/api/methods/send_gift.rst @@ -0,0 +1,45 @@ +######## +sendGift +######## + +Returns: :obj:`bool` + +.. automodule:: aiogram.methods.send_gift + :members: + :member-order: bysource + :undoc-members: True + :exclude-members: model_config,model_fields + + +Usage +===== + +As bot method +------------- + +.. code-block:: + + result: bool = await bot.send_gift(...) + + +Method as object +---------------- + +Imports: + +- :code:`from aiogram.methods.send_gift import SendGift` +- alias: :code:`from aiogram.methods import SendGift` + +With specific bot +~~~~~~~~~~~~~~~~~ + +.. code-block:: python + + result: bool = await bot(SendGift(...)) + +As reply into Webhook in handler +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. code-block:: python + + return SendGift(...) diff --git a/docs/api/methods/set_user_emoji_status.rst b/docs/api/methods/set_user_emoji_status.rst new file mode 100644 index 00000000..fb207aed --- /dev/null +++ b/docs/api/methods/set_user_emoji_status.rst @@ -0,0 +1,45 @@ +################## +setUserEmojiStatus +################## + +Returns: :obj:`bool` + +.. automodule:: aiogram.methods.set_user_emoji_status + :members: + :member-order: bysource + :undoc-members: True + :exclude-members: model_config,model_fields + + +Usage +===== + +As bot method +------------- + +.. code-block:: + + result: bool = await bot.set_user_emoji_status(...) + + +Method as object +---------------- + +Imports: + +- :code:`from aiogram.methods.set_user_emoji_status import SetUserEmojiStatus` +- alias: :code:`from aiogram.methods import SetUserEmojiStatus` + +With specific bot +~~~~~~~~~~~~~~~~~ + +.. code-block:: python + + result: bool = await bot(SetUserEmojiStatus(...)) + +As reply into Webhook in handler +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. code-block:: python + + return SetUserEmojiStatus(...) diff --git a/docs/api/types/gift.rst b/docs/api/types/gift.rst new file mode 100644 index 00000000..6b3daf5b --- /dev/null +++ b/docs/api/types/gift.rst @@ -0,0 +1,10 @@ +#### +Gift +#### + + +.. automodule:: aiogram.types.gift + :members: + :member-order: bysource + :undoc-members: True + :exclude-members: model_config,model_fields diff --git a/docs/api/types/gifts.rst b/docs/api/types/gifts.rst new file mode 100644 index 00000000..f2be33f7 --- /dev/null +++ b/docs/api/types/gifts.rst @@ -0,0 +1,10 @@ +##### +Gifts +##### + + +.. automodule:: aiogram.types.gifts + :members: + :member-order: bysource + :undoc-members: True + :exclude-members: model_config,model_fields diff --git a/docs/api/types/index.rst b/docs/api/types/index.rst index 5f9555a6..0f8b97ad 100644 --- a/docs/api/types/index.rst +++ b/docs/api/types/index.rst @@ -200,6 +200,7 @@ Inline mode input_message_content input_text_message_content input_venue_message_content + prepared_inline_message sent_web_app_message Stickers @@ -208,6 +209,8 @@ Stickers .. toctree:: :maxdepth: 1 + gift + gifts input_sticker mask_position sticker diff --git a/docs/api/types/prepared_inline_message.rst b/docs/api/types/prepared_inline_message.rst new file mode 100644 index 00000000..edfe4a63 --- /dev/null +++ b/docs/api/types/prepared_inline_message.rst @@ -0,0 +1,10 @@ +##################### +PreparedInlineMessage +##################### + + +.. automodule:: aiogram.types.prepared_inline_message + :members: + :member-order: bysource + :undoc-members: True + :exclude-members: model_config,model_fields diff --git a/tests/test_api/test_client/test_session/test_aiohttp_session.py b/tests/test_api/test_client/test_session/test_aiohttp_session.py index e23abc13..d382a7cf 100644 --- a/tests/test_api/test_client/test_session/test_aiohttp_session.py +++ b/tests/test_api/test_client/test_session/test_aiohttp_session.py @@ -21,7 +21,7 @@ from aiogram.client.session import aiohttp from aiogram.client.session.aiohttp import AiohttpSession from aiogram.exceptions import TelegramNetworkError from aiogram.methods import TelegramMethod -from aiogram.types import UNSET_PARSE_MODE, InputFile +from aiogram.types import InputFile from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_answer_callback_query.py b/tests/test_api/test_methods/test_answer_callback_query.py index 98e9df17..11e01b1e 100644 --- a/tests/test_api/test_methods/test_answer_callback_query.py +++ b/tests/test_api/test_methods/test_answer_callback_query.py @@ -1,4 +1,4 @@ -from aiogram.methods import AnswerCallbackQuery, Request +from aiogram.methods import AnswerCallbackQuery from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_answer_inline_query.py b/tests/test_api/test_methods/test_answer_inline_query.py index cd8ba266..f634ff1a 100644 --- a/tests/test_api/test_methods/test_answer_inline_query.py +++ b/tests/test_api/test_methods/test_answer_inline_query.py @@ -1,11 +1,5 @@ -from aiogram import Bot -from aiogram.methods import AnswerInlineQuery, Request -from aiogram.types import ( - InlineQueryResult, - InlineQueryResultArticle, - InlineQueryResultPhoto, - InputTextMessageContent, -) +from aiogram.methods import AnswerInlineQuery +from aiogram.types import InlineQueryResultArticle, InputTextMessageContent from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_answer_pre_checkout_query.py b/tests/test_api/test_methods/test_answer_pre_checkout_query.py index b2a1f6c9..09887aff 100644 --- a/tests/test_api/test_methods/test_answer_pre_checkout_query.py +++ b/tests/test_api/test_methods/test_answer_pre_checkout_query.py @@ -1,4 +1,4 @@ -from aiogram.methods import AnswerPreCheckoutQuery, Request +from aiogram.methods import AnswerPreCheckoutQuery from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_answer_shipping_query.py b/tests/test_api/test_methods/test_answer_shipping_query.py index d31f41f8..3d8b2a68 100644 --- a/tests/test_api/test_methods/test_answer_shipping_query.py +++ b/tests/test_api/test_methods/test_answer_shipping_query.py @@ -1,4 +1,4 @@ -from aiogram.methods import AnswerShippingQuery, Request +from aiogram.methods import AnswerShippingQuery from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_approve_chat_join_request.py b/tests/test_api/test_methods/test_approve_chat_join_request.py index 6b097702..f4e035b7 100755 --- a/tests/test_api/test_methods/test_approve_chat_join_request.py +++ b/tests/test_api/test_methods/test_approve_chat_join_request.py @@ -1,4 +1,4 @@ -from aiogram.methods import ApproveChatJoinRequest, Request +from aiogram.methods import ApproveChatJoinRequest from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_ban_chat_member.py b/tests/test_api/test_methods/test_ban_chat_member.py index 98ca951e..1e81a01b 100644 --- a/tests/test_api/test_methods/test_ban_chat_member.py +++ b/tests/test_api/test_methods/test_ban_chat_member.py @@ -1,4 +1,4 @@ -from aiogram.methods import BanChatMember, Request +from aiogram.methods import BanChatMember from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_ban_chat_sender_chat.py b/tests/test_api/test_methods/test_ban_chat_sender_chat.py index 6811c975..237516f5 100755 --- a/tests/test_api/test_methods/test_ban_chat_sender_chat.py +++ b/tests/test_api/test_methods/test_ban_chat_sender_chat.py @@ -1,4 +1,4 @@ -from aiogram.methods import BanChatSenderChat, Request +from aiogram.methods import BanChatSenderChat from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_close.py b/tests/test_api/test_methods/test_close.py index e13223fa..6944ca2a 100644 --- a/tests/test_api/test_methods/test_close.py +++ b/tests/test_api/test_methods/test_close.py @@ -1,4 +1,4 @@ -from aiogram.methods import Close, Request +from aiogram.methods import Close from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_close_forum_topic.py b/tests/test_api/test_methods/test_close_forum_topic.py index ff45c6ac..44644e31 100644 --- a/tests/test_api/test_methods/test_close_forum_topic.py +++ b/tests/test_api/test_methods/test_close_forum_topic.py @@ -1,4 +1,4 @@ -from aiogram.methods import CloseForumTopic, Request +from aiogram.methods import CloseForumTopic from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_close_general_forum_topic.py b/tests/test_api/test_methods/test_close_general_forum_topic.py index b0a022ec..f73e3b47 100644 --- a/tests/test_api/test_methods/test_close_general_forum_topic.py +++ b/tests/test_api/test_methods/test_close_general_forum_topic.py @@ -1,4 +1,4 @@ -from aiogram.methods import CloseGeneralForumTopic, Request +from aiogram.methods import CloseGeneralForumTopic from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_copy_message.py b/tests/test_api/test_methods/test_copy_message.py index bff6004b..0b9a762a 100644 --- a/tests/test_api/test_methods/test_copy_message.py +++ b/tests/test_api/test_methods/test_copy_message.py @@ -1,4 +1,4 @@ -from aiogram.methods import CopyMessage, Request +from aiogram.methods import CopyMessage from aiogram.types import MessageId from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_create_chat_invite_link.py b/tests/test_api/test_methods/test_create_chat_invite_link.py index 87a31be8..5e8216d3 100644 --- a/tests/test_api/test_methods/test_create_chat_invite_link.py +++ b/tests/test_api/test_methods/test_create_chat_invite_link.py @@ -1,4 +1,4 @@ -from aiogram.methods import CreateChatInviteLink, Request +from aiogram.methods import CreateChatInviteLink from aiogram.types import ChatInviteLink, User from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_create_chat_subscruption_invite_link.py b/tests/test_api/test_methods/test_create_chat_subscruption_invite_link.py index fa40f67b..66b002eb 100644 --- a/tests/test_api/test_methods/test_create_chat_subscruption_invite_link.py +++ b/tests/test_api/test_methods/test_create_chat_subscruption_invite_link.py @@ -1,10 +1,6 @@ from datetime import timedelta -from aiogram.methods import ( - CreateChatInviteLink, - CreateChatSubscriptionInviteLink, - Request, -) +from aiogram.methods import CreateChatSubscriptionInviteLink from aiogram.types import ChatInviteLink, User from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_create_forum_topic.py b/tests/test_api/test_methods/test_create_forum_topic.py index 071945ca..e39882c2 100644 --- a/tests/test_api/test_methods/test_create_forum_topic.py +++ b/tests/test_api/test_methods/test_create_forum_topic.py @@ -1,4 +1,4 @@ -from aiogram.methods import CreateForumTopic, Request +from aiogram.methods import CreateForumTopic from aiogram.types import ForumTopic from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_create_invoice_link.py b/tests/test_api/test_methods/test_create_invoice_link.py index 75a46326..97112036 100644 --- a/tests/test_api/test_methods/test_create_invoice_link.py +++ b/tests/test_api/test_methods/test_create_invoice_link.py @@ -1,4 +1,4 @@ -from aiogram.methods import CreateInvoiceLink, Request +from aiogram.methods import CreateInvoiceLink from aiogram.types import LabeledPrice from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_create_new_sticker_set.py b/tests/test_api/test_methods/test_create_new_sticker_set.py index 840f0c91..cdddc933 100644 --- a/tests/test_api/test_methods/test_create_new_sticker_set.py +++ b/tests/test_api/test_methods/test_create_new_sticker_set.py @@ -1,5 +1,5 @@ from aiogram.enums import StickerFormat -from aiogram.methods import CreateNewStickerSet, Request +from aiogram.methods import CreateNewStickerSet from aiogram.types import FSInputFile, InputSticker from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_decline_chat_join_request.py b/tests/test_api/test_methods/test_decline_chat_join_request.py index f85c4375..9da77257 100755 --- a/tests/test_api/test_methods/test_decline_chat_join_request.py +++ b/tests/test_api/test_methods/test_decline_chat_join_request.py @@ -1,4 +1,4 @@ -from aiogram.methods import DeclineChatJoinRequest, Request +from aiogram.methods import DeclineChatJoinRequest from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_delete_chat_photo.py b/tests/test_api/test_methods/test_delete_chat_photo.py index df8c5eef..dd9b0b9c 100644 --- a/tests/test_api/test_methods/test_delete_chat_photo.py +++ b/tests/test_api/test_methods/test_delete_chat_photo.py @@ -1,4 +1,4 @@ -from aiogram.methods import DeleteChatPhoto, Request +from aiogram.methods import DeleteChatPhoto from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_delete_chat_sticker_set.py b/tests/test_api/test_methods/test_delete_chat_sticker_set.py index c8452d75..5de60460 100644 --- a/tests/test_api/test_methods/test_delete_chat_sticker_set.py +++ b/tests/test_api/test_methods/test_delete_chat_sticker_set.py @@ -1,4 +1,4 @@ -from aiogram.methods import DeleteChatStickerSet, Request +from aiogram.methods import DeleteChatStickerSet from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_delete_forum_topic.py b/tests/test_api/test_methods/test_delete_forum_topic.py index 63cd629e..ad14ba61 100644 --- a/tests/test_api/test_methods/test_delete_forum_topic.py +++ b/tests/test_api/test_methods/test_delete_forum_topic.py @@ -1,4 +1,4 @@ -from aiogram.methods import DeleteForumTopic, Request +from aiogram.methods import DeleteForumTopic from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_delete_message.py b/tests/test_api/test_methods/test_delete_message.py index de8b44e4..67c9d767 100644 --- a/tests/test_api/test_methods/test_delete_message.py +++ b/tests/test_api/test_methods/test_delete_message.py @@ -1,4 +1,4 @@ -from aiogram.methods import DeleteMessage, Request +from aiogram.methods import DeleteMessage from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_delete_my_commands.py b/tests/test_api/test_methods/test_delete_my_commands.py index 86e4c47e..9aff0d71 100644 --- a/tests/test_api/test_methods/test_delete_my_commands.py +++ b/tests/test_api/test_methods/test_delete_my_commands.py @@ -1,4 +1,4 @@ -from aiogram.methods import DeleteMyCommands, Request +from aiogram.methods import DeleteMyCommands from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_delete_sticker_from_set.py b/tests/test_api/test_methods/test_delete_sticker_from_set.py index b8e25153..2bc0311f 100644 --- a/tests/test_api/test_methods/test_delete_sticker_from_set.py +++ b/tests/test_api/test_methods/test_delete_sticker_from_set.py @@ -1,4 +1,4 @@ -from aiogram.methods import DeleteStickerFromSet, Request +from aiogram.methods import DeleteStickerFromSet from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_delete_sticker_set.py b/tests/test_api/test_methods/test_delete_sticker_set.py index b0f6391c..1b864c75 100644 --- a/tests/test_api/test_methods/test_delete_sticker_set.py +++ b/tests/test_api/test_methods/test_delete_sticker_set.py @@ -1,4 +1,4 @@ -from aiogram.methods import DeleteStickerSet, Request +from aiogram.methods import DeleteStickerSet from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_delete_webhook.py b/tests/test_api/test_methods/test_delete_webhook.py index 3f755d73..85c93d57 100644 --- a/tests/test_api/test_methods/test_delete_webhook.py +++ b/tests/test_api/test_methods/test_delete_webhook.py @@ -1,4 +1,4 @@ -from aiogram.methods import DeleteWebhook, Request +from aiogram.methods import DeleteWebhook from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_edit_chat_invite_link.py b/tests/test_api/test_methods/test_edit_chat_invite_link.py index 7bceffcd..9f1c0822 100644 --- a/tests/test_api/test_methods/test_edit_chat_invite_link.py +++ b/tests/test_api/test_methods/test_edit_chat_invite_link.py @@ -1,4 +1,4 @@ -from aiogram.methods import EditChatInviteLink, Request +from aiogram.methods import EditChatInviteLink from aiogram.types import ChatInviteLink, User from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_edit_chat_subscruption_invite_link.py b/tests/test_api/test_methods/test_edit_chat_subscruption_invite_link.py index 90be9c23..7edbb032 100644 --- a/tests/test_api/test_methods/test_edit_chat_subscruption_invite_link.py +++ b/tests/test_api/test_methods/test_edit_chat_subscruption_invite_link.py @@ -1,11 +1,4 @@ -from datetime import timedelta - -from aiogram.methods import ( - CreateChatInviteLink, - CreateChatSubscriptionInviteLink, - EditChatSubscriptionInviteLink, - Request, -) +from aiogram.methods import EditChatSubscriptionInviteLink from aiogram.types import ChatInviteLink, User from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_edit_forum_topic.py b/tests/test_api/test_methods/test_edit_forum_topic.py index 2dbb06f9..e00cda20 100644 --- a/tests/test_api/test_methods/test_edit_forum_topic.py +++ b/tests/test_api/test_methods/test_edit_forum_topic.py @@ -1,4 +1,4 @@ -from aiogram.methods import EditForumTopic, Request +from aiogram.methods import EditForumTopic from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_edit_general_forum_topic.py b/tests/test_api/test_methods/test_edit_general_forum_topic.py index cc3fc14f..6d08f809 100644 --- a/tests/test_api/test_methods/test_edit_general_forum_topic.py +++ b/tests/test_api/test_methods/test_edit_general_forum_topic.py @@ -1,4 +1,4 @@ -from aiogram.methods import EditGeneralForumTopic, Request +from aiogram.methods import EditGeneralForumTopic from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_edit_message_caption.py b/tests/test_api/test_methods/test_edit_message_caption.py index 55ab5d6f..2aba0502 100644 --- a/tests/test_api/test_methods/test_edit_message_caption.py +++ b/tests/test_api/test_methods/test_edit_message_caption.py @@ -1,7 +1,7 @@ import datetime from typing import Union -from aiogram.methods import EditMessageCaption, Request +from aiogram.methods import EditMessageCaption from aiogram.types import Chat, Message from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_edit_message_live_location.py b/tests/test_api/test_methods/test_edit_message_live_location.py index b9aee11a..2ab8372e 100644 --- a/tests/test_api/test_methods/test_edit_message_live_location.py +++ b/tests/test_api/test_methods/test_edit_message_live_location.py @@ -1,6 +1,6 @@ from typing import Union -from aiogram.methods import EditMessageLiveLocation, Request +from aiogram.methods import EditMessageLiveLocation from aiogram.types import Message from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_edit_message_media.py b/tests/test_api/test_methods/test_edit_message_media.py index 57e74d45..c4c1cfd5 100644 --- a/tests/test_api/test_methods/test_edit_message_media.py +++ b/tests/test_api/test_methods/test_edit_message_media.py @@ -1,6 +1,6 @@ from typing import Union -from aiogram.methods import EditMessageMedia, Request +from aiogram.methods import EditMessageMedia from aiogram.types import BufferedInputFile, InputMediaPhoto, Message from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_edit_message_reply_markup.py b/tests/test_api/test_methods/test_edit_message_reply_markup.py index 1f5d94be..2e2e97e3 100644 --- a/tests/test_api/test_methods/test_edit_message_reply_markup.py +++ b/tests/test_api/test_methods/test_edit_message_reply_markup.py @@ -1,6 +1,6 @@ from typing import Union -from aiogram.methods import EditMessageReplyMarkup, Request +from aiogram.methods import EditMessageReplyMarkup from aiogram.types import InlineKeyboardButton, InlineKeyboardMarkup, Message from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_edit_message_text.py b/tests/test_api/test_methods/test_edit_message_text.py index c9e203a8..f4f33f4c 100644 --- a/tests/test_api/test_methods/test_edit_message_text.py +++ b/tests/test_api/test_methods/test_edit_message_text.py @@ -1,6 +1,6 @@ from typing import Union -from aiogram.methods import EditMessageText, Request +from aiogram.methods import EditMessageText from aiogram.types import Message from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_edit_user_star_subscription.py b/tests/test_api/test_methods/test_edit_user_star_subscription.py new file mode 100644 index 00000000..c534e781 --- /dev/null +++ b/tests/test_api/test_methods/test_edit_user_star_subscription.py @@ -0,0 +1,15 @@ +from aiogram.methods import EditUserStarSubscription +from tests.mocked_bot import MockedBot + + +class TestEditUserStarSubscription: + async def test_bot_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(EditUserStarSubscription, ok=True, result=True) + + response: bool = await bot.edit_user_star_subscription( + user_id=42, + telegram_payment_charge_id="telegram_payment_charge_id", + is_canceled=False, + ) + request = bot.get_request() + assert response == prepare_result.result diff --git a/tests/test_api/test_methods/test_export_chat_invite_link.py b/tests/test_api/test_methods/test_export_chat_invite_link.py index ba85def7..1d0de7ec 100644 --- a/tests/test_api/test_methods/test_export_chat_invite_link.py +++ b/tests/test_api/test_methods/test_export_chat_invite_link.py @@ -1,4 +1,4 @@ -from aiogram.methods import ExportChatInviteLink, Request +from aiogram.methods import ExportChatInviteLink from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_forward_message.py b/tests/test_api/test_methods/test_forward_message.py index daa434db..9b010a42 100644 --- a/tests/test_api/test_methods/test_forward_message.py +++ b/tests/test_api/test_methods/test_forward_message.py @@ -1,6 +1,6 @@ import datetime -from aiogram.methods import ForwardMessage, Request +from aiogram.methods import ForwardMessage from aiogram.types import Chat, Message from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_get_available_gifts.py b/tests/test_api/test_methods/test_get_available_gifts.py new file mode 100644 index 00000000..3576eee5 --- /dev/null +++ b/tests/test_api/test_methods/test_get_available_gifts.py @@ -0,0 +1,32 @@ +from aiogram.methods import GetAvailableGifts +from aiogram.types import Gift, Gifts, Sticker +from tests.mocked_bot import MockedBot + + +class TestGetAvailableGifts: + async def test_bot_method(self, bot: MockedBot): + prepare_result = bot.add_result_for( + GetAvailableGifts, + ok=True, + result=Gifts( + gifts=[ + Gift( + id="gift_id", + sticker=Sticker( + file_id="file_id", + file_unique_id="file_id", + type="regular", + width=512, + height=512, + is_animated=False, + is_video=False, + ), + star_count=1, + ) + ] + ), + ) + + response: Gifts = await bot.get_available_gifts() + request = bot.get_request() + assert response == prepare_result.result diff --git a/tests/test_api/test_methods/test_get_chat_administrators.py b/tests/test_api/test_methods/test_get_chat_administrators.py index d8d57fc5..f5992a87 100644 --- a/tests/test_api/test_methods/test_get_chat_administrators.py +++ b/tests/test_api/test_methods/test_get_chat_administrators.py @@ -1,6 +1,6 @@ from typing import List -from aiogram.methods import GetChatAdministrators, Request +from aiogram.methods import GetChatAdministrators from aiogram.types import ChatMember, ChatMemberOwner, User from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_get_chat_member.py b/tests/test_api/test_methods/test_get_chat_member.py index f59a491b..5d0490a5 100644 --- a/tests/test_api/test_methods/test_get_chat_member.py +++ b/tests/test_api/test_methods/test_get_chat_member.py @@ -1,5 +1,5 @@ -from aiogram.methods import GetChatMember, Request -from aiogram.types import ChatMember, ChatMemberOwner, User +from aiogram.methods import GetChatMember +from aiogram.types import ChatMemberOwner, User from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_get_chat_member_count.py b/tests/test_api/test_methods/test_get_chat_member_count.py index e1aea1ff..d2af7e2f 100644 --- a/tests/test_api/test_methods/test_get_chat_member_count.py +++ b/tests/test_api/test_methods/test_get_chat_member_count.py @@ -1,4 +1,4 @@ -from aiogram.methods import GetChatMemberCount, Request +from aiogram.methods import GetChatMemberCount from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_get_chat_menu_button.py b/tests/test_api/test_methods/test_get_chat_menu_button.py index 63a29eec..361ebc14 100644 --- a/tests/test_api/test_methods/test_get_chat_menu_button.py +++ b/tests/test_api/test_methods/test_get_chat_menu_button.py @@ -1,4 +1,4 @@ -from aiogram.methods import GetChatMenuButton, Request +from aiogram.methods import GetChatMenuButton from aiogram.types import MenuButton, MenuButtonDefault from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_get_custom_emoji_stickers.py b/tests/test_api/test_methods/test_get_custom_emoji_stickers.py index 6db0f8f4..20775c75 100644 --- a/tests/test_api/test_methods/test_get_custom_emoji_stickers.py +++ b/tests/test_api/test_methods/test_get_custom_emoji_stickers.py @@ -1,6 +1,6 @@ from typing import List -from aiogram.methods import GetCustomEmojiStickers, Request +from aiogram.methods import GetCustomEmojiStickers from aiogram.types import Sticker from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_get_file.py b/tests/test_api/test_methods/test_get_file.py index 9c54ac38..808681b4 100644 --- a/tests/test_api/test_methods/test_get_file.py +++ b/tests/test_api/test_methods/test_get_file.py @@ -1,4 +1,4 @@ -from aiogram.methods import GetFile, Request +from aiogram.methods import GetFile from aiogram.types import File from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_get_forum_topic_icon_stickers.py b/tests/test_api/test_methods/test_get_forum_topic_icon_stickers.py index ab280abc..df0ed2b2 100644 --- a/tests/test_api/test_methods/test_get_forum_topic_icon_stickers.py +++ b/tests/test_api/test_methods/test_get_forum_topic_icon_stickers.py @@ -1,6 +1,6 @@ from typing import List -from aiogram.methods import GetForumTopicIconStickers, Request +from aiogram.methods import GetForumTopicIconStickers from aiogram.types import Sticker from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_get_game_high_scores.py b/tests/test_api/test_methods/test_get_game_high_scores.py index 9dfaf5f4..189c05a8 100644 --- a/tests/test_api/test_methods/test_get_game_high_scores.py +++ b/tests/test_api/test_methods/test_get_game_high_scores.py @@ -1,6 +1,6 @@ from typing import List -from aiogram.methods import GetGameHighScores, Request +from aiogram.methods import GetGameHighScores from aiogram.types import GameHighScore, User from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_get_me.py b/tests/test_api/test_methods/test_get_me.py index e84ccd1e..eac5557d 100644 --- a/tests/test_api/test_methods/test_get_me.py +++ b/tests/test_api/test_methods/test_get_me.py @@ -1,4 +1,4 @@ -from aiogram.methods import GetMe, Request +from aiogram.methods import GetMe from aiogram.types import User from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_get_my_commands.py b/tests/test_api/test_methods/test_get_my_commands.py index 41a7a7d0..45a69a20 100644 --- a/tests/test_api/test_methods/test_get_my_commands.py +++ b/tests/test_api/test_methods/test_get_my_commands.py @@ -1,6 +1,6 @@ from typing import List -from aiogram.methods import GetMyCommands, Request +from aiogram.methods import GetMyCommands from aiogram.types import BotCommand from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_get_my_default_administrator_rights.py b/tests/test_api/test_methods/test_get_my_default_administrator_rights.py index 9fbc1f93..da76a4b2 100644 --- a/tests/test_api/test_methods/test_get_my_default_administrator_rights.py +++ b/tests/test_api/test_methods/test_get_my_default_administrator_rights.py @@ -1,4 +1,4 @@ -from aiogram.methods import GetMyDefaultAdministratorRights, Request +from aiogram.methods import GetMyDefaultAdministratorRights from aiogram.types import ChatAdministratorRights from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_get_my_description.py b/tests/test_api/test_methods/test_get_my_description.py index 32277b43..061d0837 100644 --- a/tests/test_api/test_methods/test_get_my_description.py +++ b/tests/test_api/test_methods/test_get_my_description.py @@ -1,4 +1,4 @@ -from aiogram.methods import GetMyDescription, Request +from aiogram.methods import GetMyDescription from aiogram.types import BotDescription from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_get_my_name.py b/tests/test_api/test_methods/test_get_my_name.py index 085ac0db..7ecb8f86 100644 --- a/tests/test_api/test_methods/test_get_my_name.py +++ b/tests/test_api/test_methods/test_get_my_name.py @@ -1,5 +1,5 @@ from aiogram.methods import GetMyName -from aiogram.types import BotDescription, BotName +from aiogram.types import BotName from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_get_my_short_description.py b/tests/test_api/test_methods/test_get_my_short_description.py index 3b78be89..f0d4a3ac 100644 --- a/tests/test_api/test_methods/test_get_my_short_description.py +++ b/tests/test_api/test_methods/test_get_my_short_description.py @@ -1,4 +1,4 @@ -from aiogram.methods import GetMyShortDescription, Request +from aiogram.methods import GetMyShortDescription from aiogram.types import BotShortDescription from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_get_sticker_set.py b/tests/test_api/test_methods/test_get_sticker_set.py index dd15e795..8b643b25 100644 --- a/tests/test_api/test_methods/test_get_sticker_set.py +++ b/tests/test_api/test_methods/test_get_sticker_set.py @@ -1,4 +1,4 @@ -from aiogram.methods import GetStickerSet, Request +from aiogram.methods import GetStickerSet from aiogram.types import Sticker, StickerSet from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_get_updates.py b/tests/test_api/test_methods/test_get_updates.py index ad86ceed..f9249e03 100644 --- a/tests/test_api/test_methods/test_get_updates.py +++ b/tests/test_api/test_methods/test_get_updates.py @@ -1,6 +1,6 @@ from typing import List -from aiogram.methods import GetUpdates, Request +from aiogram.methods import GetUpdates from aiogram.types import Update from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_get_user_profile_photos.py b/tests/test_api/test_methods/test_get_user_profile_photos.py index ed5329cc..1b9fad5d 100644 --- a/tests/test_api/test_methods/test_get_user_profile_photos.py +++ b/tests/test_api/test_methods/test_get_user_profile_photos.py @@ -1,4 +1,4 @@ -from aiogram.methods import GetUserProfilePhotos, Request +from aiogram.methods import GetUserProfilePhotos from aiogram.types import PhotoSize, UserProfilePhotos from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_get_webhook_info.py b/tests/test_api/test_methods/test_get_webhook_info.py index d6723411..20ef27e0 100644 --- a/tests/test_api/test_methods/test_get_webhook_info.py +++ b/tests/test_api/test_methods/test_get_webhook_info.py @@ -1,4 +1,4 @@ -from aiogram.methods import GetWebhookInfo, Request +from aiogram.methods import GetWebhookInfo from aiogram.types import WebhookInfo from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_hide_general_forum_topic.py b/tests/test_api/test_methods/test_hide_general_forum_topic.py index d142ae5e..8c6163aa 100644 --- a/tests/test_api/test_methods/test_hide_general_forum_topic.py +++ b/tests/test_api/test_methods/test_hide_general_forum_topic.py @@ -1,4 +1,4 @@ -from aiogram.methods import HideGeneralForumTopic, Request +from aiogram.methods import HideGeneralForumTopic from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_leave_chat.py b/tests/test_api/test_methods/test_leave_chat.py index e65902ca..56c87bac 100644 --- a/tests/test_api/test_methods/test_leave_chat.py +++ b/tests/test_api/test_methods/test_leave_chat.py @@ -1,4 +1,4 @@ -from aiogram.methods import LeaveChat, Request +from aiogram.methods import LeaveChat from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_log_out.py b/tests/test_api/test_methods/test_log_out.py index bb066579..2c23dede 100644 --- a/tests/test_api/test_methods/test_log_out.py +++ b/tests/test_api/test_methods/test_log_out.py @@ -1,4 +1,4 @@ -from aiogram.methods import LogOut, Request +from aiogram.methods import LogOut from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_pin_chat_message.py b/tests/test_api/test_methods/test_pin_chat_message.py index 5f8a0eba..7ce4e613 100644 --- a/tests/test_api/test_methods/test_pin_chat_message.py +++ b/tests/test_api/test_methods/test_pin_chat_message.py @@ -1,4 +1,4 @@ -from aiogram.methods import PinChatMessage, Request +from aiogram.methods import PinChatMessage from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_promote_chat_member.py b/tests/test_api/test_methods/test_promote_chat_member.py index 8fa4a08f..93a3a1d0 100644 --- a/tests/test_api/test_methods/test_promote_chat_member.py +++ b/tests/test_api/test_methods/test_promote_chat_member.py @@ -1,4 +1,4 @@ -from aiogram.methods import PromoteChatMember, Request +from aiogram.methods import PromoteChatMember from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_refund_star_payment.py b/tests/test_api/test_methods/test_refund_star_payment.py index 4e83f940..a39e55ca 100644 --- a/tests/test_api/test_methods/test_refund_star_payment.py +++ b/tests/test_api/test_methods/test_refund_star_payment.py @@ -1,6 +1,4 @@ -from aiogram.enums import StickerFormat -from aiogram.methods import AddStickerToSet, RefundStarPayment -from aiogram.types import InputSticker +from aiogram.methods import RefundStarPayment from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_reopen_forum_topic.py b/tests/test_api/test_methods/test_reopen_forum_topic.py index ff4c9b66..35cd6f4c 100644 --- a/tests/test_api/test_methods/test_reopen_forum_topic.py +++ b/tests/test_api/test_methods/test_reopen_forum_topic.py @@ -1,4 +1,4 @@ -from aiogram.methods import ReopenForumTopic, Request +from aiogram.methods import ReopenForumTopic from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_reopen_general_forum_topic.py b/tests/test_api/test_methods/test_reopen_general_forum_topic.py index 6eceb7d7..e7c08b89 100644 --- a/tests/test_api/test_methods/test_reopen_general_forum_topic.py +++ b/tests/test_api/test_methods/test_reopen_general_forum_topic.py @@ -1,4 +1,4 @@ -from aiogram.methods import ReopenGeneralForumTopic, Request +from aiogram.methods import ReopenGeneralForumTopic from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_restrict_chat_member.py b/tests/test_api/test_methods/test_restrict_chat_member.py index 716fa23d..e845b400 100644 --- a/tests/test_api/test_methods/test_restrict_chat_member.py +++ b/tests/test_api/test_methods/test_restrict_chat_member.py @@ -1,4 +1,4 @@ -from aiogram.methods import Request, RestrictChatMember +from aiogram.methods import RestrictChatMember from aiogram.types import ChatPermissions from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_revoke_chat_invite_link.py b/tests/test_api/test_methods/test_revoke_chat_invite_link.py index 9d8c26b3..cbaab593 100644 --- a/tests/test_api/test_methods/test_revoke_chat_invite_link.py +++ b/tests/test_api/test_methods/test_revoke_chat_invite_link.py @@ -1,4 +1,4 @@ -from aiogram.methods import Request, RevokeChatInviteLink +from aiogram.methods import RevokeChatInviteLink from aiogram.types import ChatInviteLink, User from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_save_prepared_inline_message.py b/tests/test_api/test_methods/test_save_prepared_inline_message.py new file mode 100644 index 00000000..2a1d1f4d --- /dev/null +++ b/tests/test_api/test_methods/test_save_prepared_inline_message.py @@ -0,0 +1,34 @@ +from datetime import datetime, timedelta + +from aiogram.methods import SavePreparedInlineMessage +from aiogram.types import ( + InlineQueryResultArticle, + InputTextMessageContent, + PreparedInlineMessage, +) +from tests.mocked_bot import MockedBot + + +class TestSavePreparedInlineMessage: + async def test_bot_method(self, bot: MockedBot): + prepare_result = bot.add_result_for( + SavePreparedInlineMessage, + ok=True, + result=PreparedInlineMessage( + id="id", + expiration_date=datetime.now() + timedelta(days=1), + ), + ) + + response: PreparedInlineMessage = await bot.save_prepared_inline_message( + user_id=42, + result=InlineQueryResultArticle( + id="id", + title="title", + input_message_content=InputTextMessageContent( + message_text="message_text", + ), + ), + ) + request = bot.get_request() + assert response == prepare_result.result diff --git a/tests/test_api/test_methods/test_send_animation.py b/tests/test_api/test_methods/test_send_animation.py index b9f5508f..569d663d 100644 --- a/tests/test_api/test_methods/test_send_animation.py +++ b/tests/test_api/test_methods/test_send_animation.py @@ -1,6 +1,6 @@ import datetime -from aiogram.methods import Request, SendAnimation +from aiogram.methods import SendAnimation from aiogram.types import Animation, Chat, Message from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_send_audio.py b/tests/test_api/test_methods/test_send_audio.py index b5b2a32b..63cdaf10 100644 --- a/tests/test_api/test_methods/test_send_audio.py +++ b/tests/test_api/test_methods/test_send_audio.py @@ -1,6 +1,6 @@ import datetime -from aiogram.methods import Request, SendAudio +from aiogram.methods import SendAudio from aiogram.types import Audio, Chat, Message from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_send_chat_action.py b/tests/test_api/test_methods/test_send_chat_action.py index 3c2d8ecb..22f2805d 100644 --- a/tests/test_api/test_methods/test_send_chat_action.py +++ b/tests/test_api/test_methods/test_send_chat_action.py @@ -1,5 +1,5 @@ from aiogram.enums import ChatAction -from aiogram.methods import Request, SendChatAction +from aiogram.methods import SendChatAction from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_send_contact.py b/tests/test_api/test_methods/test_send_contact.py index 83c6f3ae..e3f14496 100644 --- a/tests/test_api/test_methods/test_send_contact.py +++ b/tests/test_api/test_methods/test_send_contact.py @@ -1,6 +1,6 @@ import datetime -from aiogram.methods import Request, SendContact +from aiogram.methods import SendContact from aiogram.types import Chat, Contact, Message from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_send_dice.py b/tests/test_api/test_methods/test_send_dice.py index 35196ee6..66daf7d8 100644 --- a/tests/test_api/test_methods/test_send_dice.py +++ b/tests/test_api/test_methods/test_send_dice.py @@ -1,4 +1,4 @@ -from aiogram.methods import Request, SendDice +from aiogram.methods import SendDice from aiogram.types import Message from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_send_document.py b/tests/test_api/test_methods/test_send_document.py index 54c0d712..9a96a6ac 100644 --- a/tests/test_api/test_methods/test_send_document.py +++ b/tests/test_api/test_methods/test_send_document.py @@ -1,6 +1,6 @@ import datetime -from aiogram.methods import Request, SendDocument +from aiogram.methods import SendDocument from aiogram.types import Chat, Document, Message from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_send_game.py b/tests/test_api/test_methods/test_send_game.py index a0d1bb84..99621444 100644 --- a/tests/test_api/test_methods/test_send_game.py +++ b/tests/test_api/test_methods/test_send_game.py @@ -1,6 +1,6 @@ import datetime -from aiogram.methods import Request, SendGame +from aiogram.methods import SendGame from aiogram.types import Chat, Game, Message, PhotoSize from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_send_gift.py b/tests/test_api/test_methods/test_send_gift.py new file mode 100644 index 00000000..5654d49d --- /dev/null +++ b/tests/test_api/test_methods/test_send_gift.py @@ -0,0 +1,11 @@ +from aiogram.methods import SendGift +from tests.mocked_bot import MockedBot + + +class TestSendGift: + async def test_bot_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(SendGift, ok=True, result=True) + + response: bool = await bot.send_gift(user_id=42, gift_id="gift_id") + request = bot.get_request() + assert response == prepare_result.result diff --git a/tests/test_api/test_methods/test_send_invoice.py b/tests/test_api/test_methods/test_send_invoice.py index 650c4a19..b65ffd89 100644 --- a/tests/test_api/test_methods/test_send_invoice.py +++ b/tests/test_api/test_methods/test_send_invoice.py @@ -1,6 +1,6 @@ import datetime -from aiogram.methods import Request, SendInvoice +from aiogram.methods import SendInvoice from aiogram.types import Chat, Invoice, LabeledPrice, Message from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_send_location.py b/tests/test_api/test_methods/test_send_location.py index b662106d..be17dbec 100644 --- a/tests/test_api/test_methods/test_send_location.py +++ b/tests/test_api/test_methods/test_send_location.py @@ -1,6 +1,6 @@ import datetime -from aiogram.methods import Request, SendLocation +from aiogram.methods import SendLocation from aiogram.types import Chat, Location, Message from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_send_media_group.py b/tests/test_api/test_methods/test_send_media_group.py index 759184f7..1ac4cf42 100644 --- a/tests/test_api/test_methods/test_send_media_group.py +++ b/tests/test_api/test_methods/test_send_media_group.py @@ -1,7 +1,7 @@ import datetime from typing import List -from aiogram.methods import Request, SendMediaGroup +from aiogram.methods import SendMediaGroup from aiogram.types import ( BufferedInputFile, Chat, diff --git a/tests/test_api/test_methods/test_send_message.py b/tests/test_api/test_methods/test_send_message.py index 99242ca2..f16267c2 100644 --- a/tests/test_api/test_methods/test_send_message.py +++ b/tests/test_api/test_methods/test_send_message.py @@ -1,6 +1,6 @@ import datetime -from aiogram.methods import Request, SendMessage +from aiogram.methods import SendMessage from aiogram.types import Chat, ForceReply, Message, ReplyKeyboardRemove from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_send_photo.py b/tests/test_api/test_methods/test_send_photo.py index 528a04a1..f1ccc638 100644 --- a/tests/test_api/test_methods/test_send_photo.py +++ b/tests/test_api/test_methods/test_send_photo.py @@ -1,6 +1,6 @@ import datetime -from aiogram.methods import Request, SendPhoto +from aiogram.methods import SendPhoto from aiogram.types import Chat, Message, PhotoSize from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_send_poll.py b/tests/test_api/test_methods/test_send_poll.py index 4bc791fc..d070643d 100644 --- a/tests/test_api/test_methods/test_send_poll.py +++ b/tests/test_api/test_methods/test_send_poll.py @@ -1,6 +1,6 @@ import datetime -from aiogram.methods import Request, SendPoll +from aiogram.methods import SendPoll from aiogram.types import Chat, Message, Poll, PollOption from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_send_sticker.py b/tests/test_api/test_methods/test_send_sticker.py index af847e08..9e553e4c 100644 --- a/tests/test_api/test_methods/test_send_sticker.py +++ b/tests/test_api/test_methods/test_send_sticker.py @@ -1,6 +1,6 @@ import datetime -from aiogram.methods import Request, SendSticker +from aiogram.methods import SendSticker from aiogram.types import Chat, Message, Sticker from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_send_venue.py b/tests/test_api/test_methods/test_send_venue.py index 4234c7a5..3b910851 100644 --- a/tests/test_api/test_methods/test_send_venue.py +++ b/tests/test_api/test_methods/test_send_venue.py @@ -1,6 +1,6 @@ import datetime -from aiogram.methods import Request, SendVenue +from aiogram.methods import SendVenue from aiogram.types import Chat, Location, Message, Venue from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_send_video.py b/tests/test_api/test_methods/test_send_video.py index 16572b3e..31bec569 100644 --- a/tests/test_api/test_methods/test_send_video.py +++ b/tests/test_api/test_methods/test_send_video.py @@ -1,6 +1,6 @@ import datetime -from aiogram.methods import Request, SendVideo +from aiogram.methods import SendVideo from aiogram.types import Chat, Message, Video from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_send_video_note.py b/tests/test_api/test_methods/test_send_video_note.py index 3da752f5..f78fdce7 100644 --- a/tests/test_api/test_methods/test_send_video_note.py +++ b/tests/test_api/test_methods/test_send_video_note.py @@ -1,6 +1,6 @@ import datetime -from aiogram.methods import Request, SendVideoNote +from aiogram.methods import SendVideoNote from aiogram.types import BufferedInputFile, Chat, Message, VideoNote from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_send_voice.py b/tests/test_api/test_methods/test_send_voice.py index 2c55b07d..11ff9d85 100644 --- a/tests/test_api/test_methods/test_send_voice.py +++ b/tests/test_api/test_methods/test_send_voice.py @@ -1,6 +1,6 @@ import datetime -from aiogram.methods import Request, SendVoice +from aiogram.methods import SendVoice from aiogram.types import Chat, Message, Voice from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_set_chat_administrator_custom_title.py b/tests/test_api/test_methods/test_set_chat_administrator_custom_title.py index 7a759618..7ac13d36 100644 --- a/tests/test_api/test_methods/test_set_chat_administrator_custom_title.py +++ b/tests/test_api/test_methods/test_set_chat_administrator_custom_title.py @@ -1,4 +1,4 @@ -from aiogram.methods import Request, SetChatAdministratorCustomTitle +from aiogram.methods import SetChatAdministratorCustomTitle from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_set_chat_description.py b/tests/test_api/test_methods/test_set_chat_description.py index eb9885d2..7f4d8404 100644 --- a/tests/test_api/test_methods/test_set_chat_description.py +++ b/tests/test_api/test_methods/test_set_chat_description.py @@ -1,4 +1,4 @@ -from aiogram.methods import Request, SetChatDescription +from aiogram.methods import SetChatDescription from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_set_chat_menu_button.py b/tests/test_api/test_methods/test_set_chat_menu_button.py index 1cac7081..86d482cf 100644 --- a/tests/test_api/test_methods/test_set_chat_menu_button.py +++ b/tests/test_api/test_methods/test_set_chat_menu_button.py @@ -1,4 +1,4 @@ -from aiogram.methods import Request, SetChatMenuButton +from aiogram.methods import SetChatMenuButton from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_set_chat_permissions.py b/tests/test_api/test_methods/test_set_chat_permissions.py index 1dcd64b9..11cb8743 100644 --- a/tests/test_api/test_methods/test_set_chat_permissions.py +++ b/tests/test_api/test_methods/test_set_chat_permissions.py @@ -1,4 +1,4 @@ -from aiogram.methods import Request, SetChatPermissions +from aiogram.methods import SetChatPermissions from aiogram.types import ChatPermissions from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_set_chat_photo.py b/tests/test_api/test_methods/test_set_chat_photo.py index 68e0bbbc..d69aacea 100644 --- a/tests/test_api/test_methods/test_set_chat_photo.py +++ b/tests/test_api/test_methods/test_set_chat_photo.py @@ -1,4 +1,4 @@ -from aiogram.methods import Request, SetChatPhoto +from aiogram.methods import SetChatPhoto from aiogram.types import BufferedInputFile from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_set_chat_sticker_set.py b/tests/test_api/test_methods/test_set_chat_sticker_set.py index c87be0cd..78e692bc 100644 --- a/tests/test_api/test_methods/test_set_chat_sticker_set.py +++ b/tests/test_api/test_methods/test_set_chat_sticker_set.py @@ -1,4 +1,4 @@ -from aiogram.methods import Request, SetChatStickerSet +from aiogram.methods import SetChatStickerSet from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_set_chat_title.py b/tests/test_api/test_methods/test_set_chat_title.py index e45d24f2..c9a9c087 100644 --- a/tests/test_api/test_methods/test_set_chat_title.py +++ b/tests/test_api/test_methods/test_set_chat_title.py @@ -1,4 +1,4 @@ -from aiogram.methods import Request, SetChatTitle +from aiogram.methods import SetChatTitle from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_set_custom_emoji_sticker_set_thumbnail.py b/tests/test_api/test_methods/test_set_custom_emoji_sticker_set_thumbnail.py index 75d056df..b78e8c84 100644 --- a/tests/test_api/test_methods/test_set_custom_emoji_sticker_set_thumbnail.py +++ b/tests/test_api/test_methods/test_set_custom_emoji_sticker_set_thumbnail.py @@ -1,4 +1,4 @@ -from aiogram.methods import Request, SetCustomEmojiStickerSetThumbnail +from aiogram.methods import SetCustomEmojiStickerSetThumbnail from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_set_game_score.py b/tests/test_api/test_methods/test_set_game_score.py index 6da8e123..c2f1a2fa 100644 --- a/tests/test_api/test_methods/test_set_game_score.py +++ b/tests/test_api/test_methods/test_set_game_score.py @@ -1,6 +1,6 @@ from typing import Union -from aiogram.methods import Request, SetGameScore +from aiogram.methods import SetGameScore from aiogram.types import Message from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_set_my_commands.py b/tests/test_api/test_methods/test_set_my_commands.py index 16066b73..6a42aeed 100644 --- a/tests/test_api/test_methods/test_set_my_commands.py +++ b/tests/test_api/test_methods/test_set_my_commands.py @@ -1,5 +1,4 @@ -from aiogram.methods import Request, SetMyCommands -from aiogram.types import BotCommand +from aiogram.methods import SetMyCommands from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_set_my_default_administrator_rights.py b/tests/test_api/test_methods/test_set_my_default_administrator_rights.py index ac8e5d42..157bdd38 100644 --- a/tests/test_api/test_methods/test_set_my_default_administrator_rights.py +++ b/tests/test_api/test_methods/test_set_my_default_administrator_rights.py @@ -1,4 +1,4 @@ -from aiogram.methods import Request, SetMyDefaultAdministratorRights +from aiogram.methods import SetMyDefaultAdministratorRights from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_set_my_description.py b/tests/test_api/test_methods/test_set_my_description.py index 05e9bd7c..2c0dc6f3 100644 --- a/tests/test_api/test_methods/test_set_my_description.py +++ b/tests/test_api/test_methods/test_set_my_description.py @@ -1,4 +1,4 @@ -from aiogram.methods import Request, SetMyDescription +from aiogram.methods import SetMyDescription from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_set_my_short_description.py b/tests/test_api/test_methods/test_set_my_short_description.py index 9b40721d..6bebc09b 100644 --- a/tests/test_api/test_methods/test_set_my_short_description.py +++ b/tests/test_api/test_methods/test_set_my_short_description.py @@ -1,4 +1,4 @@ -from aiogram.methods import Request, SetMyDescription, SetMyShortDescription +from aiogram.methods import SetMyShortDescription from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_set_passport_data_errors.py b/tests/test_api/test_methods/test_set_passport_data_errors.py index 0e5647fb..c3afe7de 100644 --- a/tests/test_api/test_methods/test_set_passport_data_errors.py +++ b/tests/test_api/test_methods/test_set_passport_data_errors.py @@ -1,5 +1,5 @@ -from aiogram.methods import Request, SetPassportDataErrors -from aiogram.types import PassportElementError, PassportElementErrorFile +from aiogram.methods import SetPassportDataErrors +from aiogram.types import PassportElementErrorFile from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_set_sticker_emoji_list.py b/tests/test_api/test_methods/test_set_sticker_emoji_list.py index 76984264..82acb7db 100644 --- a/tests/test_api/test_methods/test_set_sticker_emoji_list.py +++ b/tests/test_api/test_methods/test_set_sticker_emoji_list.py @@ -1,4 +1,4 @@ -from aiogram.methods import Request, SetStickerEmojiList +from aiogram.methods import SetStickerEmojiList from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_set_sticker_keywords.py b/tests/test_api/test_methods/test_set_sticker_keywords.py index ff9b31e4..4c279aab 100644 --- a/tests/test_api/test_methods/test_set_sticker_keywords.py +++ b/tests/test_api/test_methods/test_set_sticker_keywords.py @@ -1,4 +1,4 @@ -from aiogram.methods import Request, SetStickerKeywords +from aiogram.methods import SetStickerKeywords from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_set_sticker_mask_position.py b/tests/test_api/test_methods/test_set_sticker_mask_position.py index fa041461..ac9f9e0a 100644 --- a/tests/test_api/test_methods/test_set_sticker_mask_position.py +++ b/tests/test_api/test_methods/test_set_sticker_mask_position.py @@ -1,4 +1,4 @@ -from aiogram.methods import Request, SetStickerEmojiList, SetStickerMaskPosition +from aiogram.methods import SetStickerMaskPosition from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_set_sticker_position_in_set.py b/tests/test_api/test_methods/test_set_sticker_position_in_set.py index ce06652c..2640de82 100644 --- a/tests/test_api/test_methods/test_set_sticker_position_in_set.py +++ b/tests/test_api/test_methods/test_set_sticker_position_in_set.py @@ -1,4 +1,4 @@ -from aiogram.methods import Request, SetStickerPositionInSet +from aiogram.methods import SetStickerPositionInSet from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_set_sticker_set_thumbnail.py b/tests/test_api/test_methods/test_set_sticker_set_thumbnail.py index bfdfd808..5d4b745b 100644 --- a/tests/test_api/test_methods/test_set_sticker_set_thumbnail.py +++ b/tests/test_api/test_methods/test_set_sticker_set_thumbnail.py @@ -1,5 +1,5 @@ from aiogram.enums import StickerFormat -from aiogram.methods import Request, SetStickerSetThumbnail +from aiogram.methods import SetStickerSetThumbnail from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_set_sticker_set_title.py b/tests/test_api/test_methods/test_set_sticker_set_title.py index 2a9645cb..a4eb9d09 100644 --- a/tests/test_api/test_methods/test_set_sticker_set_title.py +++ b/tests/test_api/test_methods/test_set_sticker_set_title.py @@ -1,4 +1,4 @@ -from aiogram.methods import Request, SetStickerEmojiList, SetStickerSetTitle +from aiogram.methods import SetStickerSetTitle from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_set_user_emoji_status.py b/tests/test_api/test_methods/test_set_user_emoji_status.py new file mode 100644 index 00000000..4e661eaf --- /dev/null +++ b/tests/test_api/test_methods/test_set_user_emoji_status.py @@ -0,0 +1,17 @@ +from datetime import datetime, timedelta + +from aiogram.methods import SetUserEmojiStatus +from tests.mocked_bot import MockedBot + + +class TestSetUserEmojiStatus: + async def test_bot_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(SetUserEmojiStatus, ok=True, result=True) + + response: bool = await bot.set_user_emoji_status( + user_id=42, + emoji_status_custom_emoji_id="emoji_status_custom_emoji_id", + emoji_status_expiration_date=datetime.now() + timedelta(days=1), + ) + request = bot.get_request() + assert response == prepare_result.result diff --git a/tests/test_api/test_methods/test_set_webhook.py b/tests/test_api/test_methods/test_set_webhook.py index c38a2bfa..37f75a9c 100644 --- a/tests/test_api/test_methods/test_set_webhook.py +++ b/tests/test_api/test_methods/test_set_webhook.py @@ -1,4 +1,4 @@ -from aiogram.methods import Request, SetWebhook +from aiogram.methods import SetWebhook from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_stop_message_live_location.py b/tests/test_api/test_methods/test_stop_message_live_location.py index 99c8b675..b0b7f397 100644 --- a/tests/test_api/test_methods/test_stop_message_live_location.py +++ b/tests/test_api/test_methods/test_stop_message_live_location.py @@ -1,6 +1,6 @@ from typing import Union -from aiogram.methods import Request, StopMessageLiveLocation +from aiogram.methods import StopMessageLiveLocation from aiogram.types import Message from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_stop_poll.py b/tests/test_api/test_methods/test_stop_poll.py index ef2d36d6..5a89e1ed 100644 --- a/tests/test_api/test_methods/test_stop_poll.py +++ b/tests/test_api/test_methods/test_stop_poll.py @@ -1,4 +1,4 @@ -from aiogram.methods import Request, StopPoll +from aiogram.methods import StopPoll from aiogram.types import Poll, PollOption from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_unban_chat_member.py b/tests/test_api/test_methods/test_unban_chat_member.py index 291512fa..23f922ad 100644 --- a/tests/test_api/test_methods/test_unban_chat_member.py +++ b/tests/test_api/test_methods/test_unban_chat_member.py @@ -1,4 +1,4 @@ -from aiogram.methods import Request, UnbanChatMember +from aiogram.methods import UnbanChatMember from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_unban_chat_sender_chat.py b/tests/test_api/test_methods/test_unban_chat_sender_chat.py index 54c334ab..e23c1b13 100755 --- a/tests/test_api/test_methods/test_unban_chat_sender_chat.py +++ b/tests/test_api/test_methods/test_unban_chat_sender_chat.py @@ -1,4 +1,4 @@ -from aiogram.methods import Request, UnbanChatSenderChat +from aiogram.methods import UnbanChatSenderChat from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_unhide_general_forum_topic.py b/tests/test_api/test_methods/test_unhide_general_forum_topic.py index eb69223b..da830cd6 100644 --- a/tests/test_api/test_methods/test_unhide_general_forum_topic.py +++ b/tests/test_api/test_methods/test_unhide_general_forum_topic.py @@ -1,4 +1,4 @@ -from aiogram.methods import Request, UnhideGeneralForumTopic +from aiogram.methods import UnhideGeneralForumTopic from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_unpin_all_chat_messages.py b/tests/test_api/test_methods/test_unpin_all_chat_messages.py index 173ce711..64ce1d4c 100644 --- a/tests/test_api/test_methods/test_unpin_all_chat_messages.py +++ b/tests/test_api/test_methods/test_unpin_all_chat_messages.py @@ -1,4 +1,4 @@ -from aiogram.methods import Request, UnpinAllChatMessages +from aiogram.methods import UnpinAllChatMessages from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_unpin_all_forum_topic_messages.py b/tests/test_api/test_methods/test_unpin_all_forum_topic_messages.py index ac7b409c..045fd926 100644 --- a/tests/test_api/test_methods/test_unpin_all_forum_topic_messages.py +++ b/tests/test_api/test_methods/test_unpin_all_forum_topic_messages.py @@ -1,4 +1,4 @@ -from aiogram.methods import Request, UnpinAllForumTopicMessages +from aiogram.methods import UnpinAllForumTopicMessages from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_unpin_all_general_forum_topic_messages.py b/tests/test_api/test_methods/test_unpin_all_general_forum_topic_messages.py index fc2df936..09a3658e 100644 --- a/tests/test_api/test_methods/test_unpin_all_general_forum_topic_messages.py +++ b/tests/test_api/test_methods/test_unpin_all_general_forum_topic_messages.py @@ -1,8 +1,4 @@ -from aiogram.methods import ( - Request, - UnpinAllForumTopicMessages, - UnpinAllGeneralForumTopicMessages, -) +from aiogram.methods import UnpinAllGeneralForumTopicMessages from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_unpin_chat_message.py b/tests/test_api/test_methods/test_unpin_chat_message.py index 804b3ae2..fdf1622d 100644 --- a/tests/test_api/test_methods/test_unpin_chat_message.py +++ b/tests/test_api/test_methods/test_unpin_chat_message.py @@ -1,4 +1,4 @@ -from aiogram.methods import Request, UnpinChatMessage +from aiogram.methods import UnpinChatMessage from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_methods/test_upload_sticker_file.py b/tests/test_api/test_methods/test_upload_sticker_file.py index fda4c4d0..0823772c 100644 --- a/tests/test_api/test_methods/test_upload_sticker_file.py +++ b/tests/test_api/test_methods/test_upload_sticker_file.py @@ -1,5 +1,5 @@ from aiogram.enums import StickerFormat -from aiogram.methods import Request, UploadStickerFile +from aiogram.methods import UploadStickerFile from aiogram.types import BufferedInputFile, File from tests.mocked_bot import MockedBot diff --git a/tests/test_api/test_types/test_input_file.py b/tests/test_api/test_types/test_input_file.py index e8716f84..cd0b94db 100644 --- a/tests/test_api/test_types/test_input_file.py +++ b/tests/test_api/test_types/test_input_file.py @@ -1,5 +1,3 @@ -from typing import AsyncIterable - from aresponses import ResponsesMockServer from aiogram import Bot diff --git a/tests/test_fsm/storage/test_isolation.py b/tests/test_fsm/storage/test_isolation.py index 867362c1..7257123d 100644 --- a/tests/test_fsm/storage/test_isolation.py +++ b/tests/test_fsm/storage/test_isolation.py @@ -1,4 +1,3 @@ -from unittest import mock from unittest.mock import AsyncMock, patch import pytest