From 27f0631bcf73b60d528025f06de73c8e6d7ffaa5 Mon Sep 17 00:00:00 2001 From: JRoot Junior Date: Sun, 31 Mar 2024 21:09:26 +0300 Subject: [PATCH] Added base support of Bot API 7.2 --- .../methods/getBusinessConnection/entity.json | 25 +++++++ .../methods/replaceStickerInSet/entity.json | 49 ++++++++++++++ .butcher/types/Birthdate/entity.json | 41 ++++++++++++ .butcher/types/BusinessConnection/entity.json | 65 +++++++++++++++++++ .butcher/types/BusinessIntro/entity.json | 41 ++++++++++++ .butcher/types/BusinessLocation/entity.json | 33 ++++++++++ .../types/BusinessMessagesDeleted/entity.json | 41 ++++++++++++ .../types/BusinessOpeningHours/entity.json | 33 ++++++++++ .../BusinessOpeningHoursInterval/entity.json | 33 ++++++++++ .butcher/types/SharedUser/entity.json | 57 ++++++++++++++++ .../test_session/test_base_session.py | 2 +- 11 files changed, 419 insertions(+), 1 deletion(-) create mode 100644 .butcher/methods/getBusinessConnection/entity.json create mode 100644 .butcher/methods/replaceStickerInSet/entity.json create mode 100644 .butcher/types/Birthdate/entity.json create mode 100644 .butcher/types/BusinessConnection/entity.json create mode 100644 .butcher/types/BusinessIntro/entity.json create mode 100644 .butcher/types/BusinessLocation/entity.json create mode 100644 .butcher/types/BusinessMessagesDeleted/entity.json create mode 100644 .butcher/types/BusinessOpeningHours/entity.json create mode 100644 .butcher/types/BusinessOpeningHoursInterval/entity.json create mode 100644 .butcher/types/SharedUser/entity.json diff --git a/.butcher/methods/getBusinessConnection/entity.json b/.butcher/methods/getBusinessConnection/entity.json new file mode 100644 index 00000000..8005a363 --- /dev/null +++ b/.butcher/methods/getBusinessConnection/entity.json @@ -0,0 +1,25 @@ +{ + "meta": {}, + "group": { + "title": "Available methods", + "anchor": "available-methods" + }, + "object": { + "anchor": "getbusinessconnection", + "name": "getBusinessConnection", + "description": "Use this method to get information about the connection of the bot with a business account. Returns a BusinessConnection object on success.", + "html_description": "

Use this method to get information about the connection of the bot with a business account. Returns a BusinessConnection object on success.

", + "rst_description": "Use this method to get information about the connection of the bot with a business account. Returns a :class:`aiogram.types.business_connection.BusinessConnection` object on success.", + "annotations": [ + { + "type": "String", + "required": true, + "description": "Unique identifier of the business connection", + "html_description": "Unique identifier of the business connection", + "rst_description": "Unique identifier of the business connection\n", + "name": "business_connection_id" + } + ], + "category": "methods" + } +} diff --git a/.butcher/methods/replaceStickerInSet/entity.json b/.butcher/methods/replaceStickerInSet/entity.json new file mode 100644 index 00000000..8ef0e9a3 --- /dev/null +++ b/.butcher/methods/replaceStickerInSet/entity.json @@ -0,0 +1,49 @@ +{ + "meta": {}, + "group": { + "title": "Stickers", + "anchor": "stickers" + }, + "object": { + "anchor": "replacestickerinset", + "name": "replaceStickerInSet", + "description": "Use this method to replace an existing sticker in a sticker set with a new one. The method is equivalent to calling deleteStickerFromSet, then addStickerToSet, then setStickerPositionInSet. Returns True on success.", + "html_description": "

Use this method to replace an existing sticker in a sticker set with a new one. The method is equivalent to calling deleteStickerFromSet, then addStickerToSet, then setStickerPositionInSet. Returns True on success.

", + "rst_description": "Use this method to replace an existing sticker in a sticker set with a new one. The method is equivalent to calling :class:`aiogram.methods.delete_sticker_from_set.DeleteStickerFromSet`, then :class:`aiogram.methods.add_sticker_to_set.AddStickerToSet`, then :class:`aiogram.methods.set_sticker_position_in_set.SetStickerPositionInSet`. Returns :code:`True` on success.", + "annotations": [ + { + "type": "Integer", + "required": true, + "description": "User identifier of the sticker set owner", + "html_description": "User identifier of the sticker set owner", + "rst_description": "User identifier of the sticker set owner\n", + "name": "user_id" + }, + { + "type": "String", + "required": true, + "description": "Sticker set name", + "html_description": "Sticker set name", + "rst_description": "Sticker set name\n", + "name": "name" + }, + { + "type": "String", + "required": true, + "description": "File identifier of the replaced sticker", + "html_description": "File identifier of the replaced sticker", + "rst_description": "File identifier of the replaced sticker\n", + "name": "old_sticker" + }, + { + "type": "InputSticker", + "required": true, + "description": "A JSON-serialized object with information about the added sticker. If exactly the same sticker had already been added to the set, then the set remains unchanged.", + "html_description": "A JSON-serialized object with information about the added sticker. If exactly the same sticker had already been added to the set, then the set remains unchanged.", + "rst_description": "A JSON-serialized object with information about the added sticker. If exactly the same sticker had already been added to the set, then the set remains unchanged.\n", + "name": "sticker" + } + ], + "category": "methods" + } +} diff --git a/.butcher/types/Birthdate/entity.json b/.butcher/types/Birthdate/entity.json new file mode 100644 index 00000000..b70055c6 --- /dev/null +++ b/.butcher/types/Birthdate/entity.json @@ -0,0 +1,41 @@ +{ + "meta": {}, + "group": { + "title": "Available types", + "anchor": "available-types" + }, + "object": { + "anchor": "birthdate", + "name": "Birthdate", + "description": "", + "html_description": "", + "rst_description": "", + "annotations": [ + { + "type": "Integer", + "description": "Day of the user's birth; 1-31", + "html_description": "Day of the user's birth; 1-31", + "rst_description": "Day of the user's birth; 1-31\n", + "name": "day", + "required": true + }, + { + "type": "Integer", + "description": "Month of the user's birth; 1-12", + "html_description": "Month of the user's birth; 1-12", + "rst_description": "Month of the user's birth; 1-12\n", + "name": "month", + "required": true + }, + { + "type": "Integer", + "description": "Year of the user's birth", + "html_description": "Optional. Year of the user's birth", + "rst_description": "*Optional*. Year of the user's birth\n", + "name": "year", + "required": false + } + ], + "category": "types" + } +} diff --git a/.butcher/types/BusinessConnection/entity.json b/.butcher/types/BusinessConnection/entity.json new file mode 100644 index 00000000..09b9a0ef --- /dev/null +++ b/.butcher/types/BusinessConnection/entity.json @@ -0,0 +1,65 @@ +{ + "meta": {}, + "group": { + "title": "Available types", + "anchor": "available-types" + }, + "object": { + "anchor": "businessconnection", + "name": "BusinessConnection", + "description": "Describes the connection of the bot with a business account.", + "html_description": "

Describes the connection of the bot with a business account.

", + "rst_description": "Describes the connection of the bot with a business account.", + "annotations": [ + { + "type": "String", + "description": "Unique identifier of the business connection", + "html_description": "Unique identifier of the business connection", + "rst_description": "Unique identifier of the business connection\n", + "name": "id", + "required": true + }, + { + "type": "User", + "description": "Business account user that created the business connection", + "html_description": "Business account user that created the business connection", + "rst_description": "Business account user that created the business connection\n", + "name": "user", + "required": true + }, + { + "type": "Integer", + "description": "Identifier of a private chat with the user who created the business connection. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a 64-bit integer or double-precision float type are safe for storing this identifier.", + "html_description": "Identifier of a private chat with the user who created the business connection. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a 64-bit integer or double-precision float type are safe for storing this identifier.", + "rst_description": "Identifier of a private chat with the user who created the business connection. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a 64-bit integer or double-precision float type are safe for storing this identifier.\n", + "name": "user_chat_id", + "required": true + }, + { + "type": "Integer", + "description": "Date the connection was established in Unix time", + "html_description": "Date the connection was established in Unix time", + "rst_description": "Date the connection was established in Unix time\n", + "name": "date", + "required": true + }, + { + "type": "Boolean", + "description": "True, if the bot can act on behalf of the business account in chats that were active in the last 24 hours", + "html_description": "True, if the bot can act on behalf of the business account in chats that were active in the last 24 hours", + "rst_description": "True, if the bot can act on behalf of the business account in chats that were active in the last 24 hours\n", + "name": "can_reply", + "required": true + }, + { + "type": "Boolean", + "description": "True, if the connection is active", + "html_description": "True, if the connection is active", + "rst_description": "True, if the connection is active\n", + "name": "is_enabled", + "required": true + } + ], + "category": "types" + } +} diff --git a/.butcher/types/BusinessIntro/entity.json b/.butcher/types/BusinessIntro/entity.json new file mode 100644 index 00000000..4208d21f --- /dev/null +++ b/.butcher/types/BusinessIntro/entity.json @@ -0,0 +1,41 @@ +{ + "meta": {}, + "group": { + "title": "Available types", + "anchor": "available-types" + }, + "object": { + "anchor": "businessintro", + "name": "BusinessIntro", + "description": "", + "html_description": "", + "rst_description": "", + "annotations": [ + { + "type": "String", + "description": "Title text of the business intro", + "html_description": "Optional. Title text of the business intro", + "rst_description": "*Optional*. Title text of the business intro\n", + "name": "title", + "required": false + }, + { + "type": "String", + "description": "Message text of the business intro", + "html_description": "Optional. Message text of the business intro", + "rst_description": "*Optional*. Message text of the business intro\n", + "name": "message", + "required": false + }, + { + "type": "Sticker", + "description": "Sticker of the business intro", + "html_description": "Optional. Sticker of the business intro", + "rst_description": "*Optional*. Sticker of the business intro\n", + "name": "sticker", + "required": false + } + ], + "category": "types" + } +} diff --git a/.butcher/types/BusinessLocation/entity.json b/.butcher/types/BusinessLocation/entity.json new file mode 100644 index 00000000..0d3ddac3 --- /dev/null +++ b/.butcher/types/BusinessLocation/entity.json @@ -0,0 +1,33 @@ +{ + "meta": {}, + "group": { + "title": "Available types", + "anchor": "available-types" + }, + "object": { + "anchor": "businesslocation", + "name": "BusinessLocation", + "description": "", + "html_description": "", + "rst_description": "", + "annotations": [ + { + "type": "String", + "description": "Address of the business", + "html_description": "Address of the business", + "rst_description": "Address of the business\n", + "name": "address", + "required": true + }, + { + "type": "Location", + "description": "Location of the business", + "html_description": "Optional. Location of the business", + "rst_description": "*Optional*. Location of the business\n", + "name": "location", + "required": false + } + ], + "category": "types" + } +} diff --git a/.butcher/types/BusinessMessagesDeleted/entity.json b/.butcher/types/BusinessMessagesDeleted/entity.json new file mode 100644 index 00000000..3eb82a8d --- /dev/null +++ b/.butcher/types/BusinessMessagesDeleted/entity.json @@ -0,0 +1,41 @@ +{ + "meta": {}, + "group": { + "title": "Available types", + "anchor": "available-types" + }, + "object": { + "anchor": "businessmessagesdeleted", + "name": "BusinessMessagesDeleted", + "description": "This object is received when messages are deleted from a connected business account.", + "html_description": "

This object is received when messages are deleted from a connected business account.

", + "rst_description": "This object is received when messages are deleted from a connected business account.", + "annotations": [ + { + "type": "String", + "description": "Unique identifier of the business connection", + "html_description": "Unique identifier of the business connection", + "rst_description": "Unique identifier of the business connection\n", + "name": "business_connection_id", + "required": true + }, + { + "type": "Chat", + "description": "Information about a chat in the business account. The bot may not have access to the chat or the corresponding user.", + "html_description": "Information about a chat in the business account. The bot may not have access to the chat or the corresponding user.", + "rst_description": "Information about a chat in the business account. The bot may not have access to the chat or the corresponding user.\n", + "name": "chat", + "required": true + }, + { + "type": "Array of Integer", + "description": "A JSON-serialized list of identifiers of deleted messages in the chat of the business account", + "html_description": "A JSON-serialized list of identifiers of deleted messages in the chat of the business account", + "rst_description": "A JSON-serialized list of identifiers of deleted messages in the chat of the business account\n", + "name": "message_ids", + "required": true + } + ], + "category": "types" + } +} diff --git a/.butcher/types/BusinessOpeningHours/entity.json b/.butcher/types/BusinessOpeningHours/entity.json new file mode 100644 index 00000000..7632bbe0 --- /dev/null +++ b/.butcher/types/BusinessOpeningHours/entity.json @@ -0,0 +1,33 @@ +{ + "meta": {}, + "group": { + "title": "Available types", + "anchor": "available-types" + }, + "object": { + "anchor": "businessopeninghours", + "name": "BusinessOpeningHours", + "description": "", + "html_description": "", + "rst_description": "", + "annotations": [ + { + "type": "String", + "description": "Unique name of the time zone for which the opening hours are defined", + "html_description": "Unique name of the time zone for which the opening hours are defined", + "rst_description": "Unique name of the time zone for which the opening hours are defined\n", + "name": "time_zone_name", + "required": true + }, + { + "type": "Array of BusinessOpeningHoursInterval", + "description": "List of time intervals describing business opening hours", + "html_description": "List of time intervals describing business opening hours", + "rst_description": "List of time intervals describing business opening hours\n", + "name": "opening_hours", + "required": true + } + ], + "category": "types" + } +} diff --git a/.butcher/types/BusinessOpeningHoursInterval/entity.json b/.butcher/types/BusinessOpeningHoursInterval/entity.json new file mode 100644 index 00000000..ad07ba67 --- /dev/null +++ b/.butcher/types/BusinessOpeningHoursInterval/entity.json @@ -0,0 +1,33 @@ +{ + "meta": {}, + "group": { + "title": "Available types", + "anchor": "available-types" + }, + "object": { + "anchor": "businessopeninghoursinterval", + "name": "BusinessOpeningHoursInterval", + "description": "", + "html_description": "", + "rst_description": "", + "annotations": [ + { + "type": "Integer", + "description": "The minute's sequence number in a week, starting on Monday, marking the start of the time interval during which the business is open; 0 - 7 24 60", + "html_description": "The minute's sequence number in a week, starting on Monday, marking the start of the time interval during which the business is open; 0 - 7 24 60", + "rst_description": "The minute's sequence number in a week, starting on Monday, marking the start of the time interval during which the business is open; 0 - 7 * 24 * 60\n", + "name": "opening_minute", + "required": true + }, + { + "type": "Integer", + "description": "The minute's sequence number in a week, starting on Monday, marking the end of the time interval during which the business is open; 0 - 8 24 60", + "html_description": "The minute's sequence number in a week, starting on Monday, marking the end of the time interval during which the business is open; 0 - 8 24 60", + "rst_description": "The minute's sequence number in a week, starting on Monday, marking the end of the time interval during which the business is open; 0 - 8 * 24 * 60\n", + "name": "closing_minute", + "required": true + } + ], + "category": "types" + } +} diff --git a/.butcher/types/SharedUser/entity.json b/.butcher/types/SharedUser/entity.json new file mode 100644 index 00000000..6e33fe97 --- /dev/null +++ b/.butcher/types/SharedUser/entity.json @@ -0,0 +1,57 @@ +{ + "meta": {}, + "group": { + "title": "Available types", + "anchor": "available-types" + }, + "object": { + "anchor": "shareduser", + "name": "SharedUser", + "description": "This object contains information about a user that was shared with the bot using a KeyboardButtonRequestUser button.", + "html_description": "

This object contains information about a user that was shared with the bot using a KeyboardButtonRequestUser button.

", + "rst_description": "This object contains information about a user that was shared with the bot using a :class:`aiogram.types.keyboard_button_request_user.KeyboardButtonRequestUser` button.", + "annotations": [ + { + "type": "Integer", + "description": "Identifier of the shared user. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so 64-bit integers or double-precision float types are safe for storing these identifiers. The bot may not have access to the user and could be unable to use this identifier, unless the user is already known to the bot by some other means.", + "html_description": "Identifier of the shared user. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so 64-bit integers or double-precision float types are safe for storing these identifiers. The bot may not have access to the user and could be unable to use this identifier, unless the user is already known to the bot by some other means.", + "rst_description": "Identifier of the shared user. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so 64-bit integers or double-precision float types are safe for storing these identifiers. The bot may not have access to the user and could be unable to use this identifier, unless the user is already known to the bot by some other means.\n", + "name": "user_id", + "required": true + }, + { + "type": "String", + "description": "First name of the user, if the name was requested by the bot", + "html_description": "Optional. First name of the user, if the name was requested by the bot", + "rst_description": "*Optional*. First name of the user, if the name was requested by the bot\n", + "name": "first_name", + "required": false + }, + { + "type": "String", + "description": "Last name of the user, if the name was requested by the bot", + "html_description": "Optional. Last name of the user, if the name was requested by the bot", + "rst_description": "*Optional*. Last name of the user, if the name was requested by the bot\n", + "name": "last_name", + "required": false + }, + { + "type": "String", + "description": "Username of the user, if the username was requested by the bot", + "html_description": "Optional. Username of the user, if the username was requested by the bot", + "rst_description": "*Optional*. Username of the user, if the username was requested by the bot\n", + "name": "username", + "required": false + }, + { + "type": "Array of PhotoSize", + "description": "Available sizes of the chat photo, if the photo was requested by the bot", + "html_description": "Optional. Available sizes of the chat photo, if the photo was requested by the bot", + "rst_description": "*Optional*. Available sizes of the chat photo, if the photo was requested by the bot\n", + "name": "photo", + "required": false + } + ], + "category": "types" + } +} diff --git a/tests/test_api/test_client/test_session/test_base_session.py b/tests/test_api/test_client/test_session/test_base_session.py index 1a1b3c14..6bca619c 100644 --- a/tests/test_api/test_client/test_session/test_base_session.py +++ b/tests/test_api/test_client/test_session/test_base_session.py @@ -26,7 +26,7 @@ from aiogram.exceptions import ( TelegramUnauthorizedError, ) from aiogram.methods import DeleteMessage, GetMe, TelegramMethod -from aiogram.types import UNSET_PARSE_MODE, User, LinkPreviewOptions +from aiogram.types import UNSET_PARSE_MODE, LinkPreviewOptions, User from aiogram.types.base import UNSET_DISABLE_WEB_PAGE_PREVIEW, UNSET_PROTECT_CONTENT from tests.mocked_bot import MockedBot