From 33003f20266dd16339dd912c8484f460009ae849 Mon Sep 17 00:00:00 2001 From: Alex Root Junior Date: Sat, 11 Apr 2020 20:15:03 +0300 Subject: [PATCH] Add support of Bot API 4.7. Bump version --- aiogram/__init__.py | 4 +- aiogram/api/client/bot.py | 209 +++++++++++++----- aiogram/api/client/session/base.py | 10 +- aiogram/api/methods/__init__.py | 8 + aiogram/api/methods/add_sticker_to_set.py | 14 +- aiogram/api/methods/base.py | 11 +- aiogram/api/methods/create_new_sticker_set.py | 20 +- aiogram/api/methods/delete_message.py | 1 + aiogram/api/methods/edit_message_caption.py | 2 +- aiogram/api/methods/edit_message_text.py | 2 +- aiogram/api/methods/get_my_commands.py | 20 ++ aiogram/api/methods/send_animation.py | 3 +- aiogram/api/methods/send_audio.py | 2 +- aiogram/api/methods/send_dice.py | 40 ++++ aiogram/api/methods/send_document.py | 3 +- aiogram/api/methods/send_message.py | 2 +- aiogram/api/methods/send_photo.py | 3 +- aiogram/api/methods/send_poll.py | 2 +- aiogram/api/methods/send_sticker.py | 2 +- aiogram/api/methods/send_video.py | 3 +- aiogram/api/methods/send_voice.py | 4 +- aiogram/api/methods/set_my_commands.py | 23 ++ .../methods/set_sticker_position_in_set.py | 2 +- aiogram/api/methods/set_sticker_set_thumb.py | 36 +++ aiogram/api/methods/upload_sticker_file.py | 2 +- aiogram/api/types/__init__.py | 4 + aiogram/api/types/bot_command.py | 17 ++ aiogram/api/types/dice.py | 15 ++ .../api/types/inline_query_result_audio.py | 2 +- .../types/inline_query_result_cached_audio.py | 2 +- .../inline_query_result_cached_document.py | 2 +- .../types/inline_query_result_cached_gif.py | 2 +- .../inline_query_result_cached_mpeg4_gif.py | 2 +- .../types/inline_query_result_cached_photo.py | 2 +- .../types/inline_query_result_cached_video.py | 2 +- .../types/inline_query_result_cached_voice.py | 2 +- .../api/types/inline_query_result_document.py | 2 +- aiogram/api/types/inline_query_result_gif.py | 2 +- .../types/inline_query_result_mpeg4_gif.py | 2 +- .../api/types/inline_query_result_photo.py | 2 +- .../api/types/inline_query_result_video.py | 2 +- .../api/types/inline_query_result_voice.py | 4 +- aiogram/api/types/input_file.py | 8 +- aiogram/api/types/input_media_animation.py | 2 +- aiogram/api/types/input_media_audio.py | 2 +- aiogram/api/types/input_media_document.py | 2 +- aiogram/api/types/input_media_photo.py | 2 +- aiogram/api/types/input_media_video.py | 2 +- aiogram/api/types/message.py | 8 +- aiogram/api/types/sticker.py | 2 +- aiogram/api/types/sticker_set.py | 5 +- aiogram/dispatcher/event/handler.py | 12 +- aiogram/dispatcher/filters/__init__.py | 6 +- aiogram/dispatcher/filters/base.py | 9 +- aiogram/dispatcher/handler/base.py | 9 +- aiogram/dispatcher/handler/message.py | 5 +- aiogram/dispatcher/router.py | 7 +- aiogram/utils/helper.py | 10 +- aiogram/utils/mixins.py | 34 ++- docs/_api_version.md | 2 +- docs/api/methods/add_sticker_to_set.md | 9 +- docs/api/methods/answer_callback_query.md | 4 +- docs/api/methods/answer_inline_query.md | 4 +- docs/api/methods/answer_pre_checkout_query.md | 4 +- docs/api/methods/answer_shipping_query.md | 4 +- docs/api/methods/create_new_sticker_set.md | 9 +- docs/api/methods/delete_chat_photo.md | 4 +- docs/api/methods/delete_chat_sticker_set.md | 4 +- docs/api/methods/delete_message.md | 6 +- docs/api/methods/delete_sticker_from_set.md | 4 +- docs/api/methods/delete_webhook.md | 4 +- docs/api/methods/edit_message_caption.md | 6 +- .../api/methods/edit_message_live_location.md | 4 +- docs/api/methods/edit_message_media.md | 4 +- docs/api/methods/edit_message_reply_markup.md | 4 +- docs/api/methods/edit_message_text.md | 6 +- docs/api/methods/export_chat_invite_link.md | 4 +- docs/api/methods/forward_message.md | 4 +- docs/api/methods/get_chat.md | 3 +- docs/api/methods/get_chat_administrators.md | 3 +- docs/api/methods/get_chat_member.md | 3 +- docs/api/methods/get_chat_members_count.md | 3 +- docs/api/methods/get_file.md | 3 +- docs/api/methods/get_game_high_scores.md | 3 +- docs/api/methods/get_me.md | 3 +- docs/api/methods/get_my_commands.md | 48 ++++ docs/api/methods/get_sticker_set.md | 3 +- docs/api/methods/get_updates.md | 3 +- docs/api/methods/get_user_profile_photos.md | 3 +- docs/api/methods/get_webhook_info.md | 3 +- docs/api/methods/index.md | 5 +- docs/api/methods/kick_chat_member.md | 4 +- docs/api/methods/leave_chat.md | 4 +- docs/api/methods/pin_chat_message.md | 4 +- docs/api/methods/promote_chat_member.md | 4 +- docs/api/methods/restrict_chat_member.md | 4 +- docs/api/methods/send_animation.md | 6 +- docs/api/methods/send_audio.md | 6 +- docs/api/methods/send_chat_action.md | 4 +- docs/api/methods/send_contact.md | 4 +- docs/api/methods/send_dice.md | 64 ++++++ docs/api/methods/send_document.md | 6 +- docs/api/methods/send_game.md | 4 +- docs/api/methods/send_invoice.md | 4 +- docs/api/methods/send_location.md | 4 +- docs/api/methods/send_media_group.md | 4 +- docs/api/methods/send_message.md | 6 +- docs/api/methods/send_photo.md | 6 +- docs/api/methods/send_poll.md | 4 +- docs/api/methods/send_sticker.md | 6 +- docs/api/methods/send_venue.md | 4 +- docs/api/methods/send_video.md | 6 +- docs/api/methods/send_video_note.md | 4 +- docs/api/methods/send_voice.md | 8 +- .../set_chat_administrator_custom_title.md | 4 +- docs/api/methods/set_chat_description.md | 4 +- docs/api/methods/set_chat_permissions.md | 4 +- docs/api/methods/set_chat_photo.md | 3 +- docs/api/methods/set_chat_sticker_set.md | 4 +- docs/api/methods/set_chat_title.md | 4 +- docs/api/methods/set_game_score.md | 4 +- docs/api/methods/set_my_commands.md | 57 +++++ docs/api/methods/set_passport_data_errors.md | 4 +- .../methods/set_sticker_position_in_set.md | 6 +- docs/api/methods/set_sticker_set_thumb.md | 60 +++++ docs/api/methods/set_webhook.md | 4 +- .../api/methods/stop_message_live_location.md | 4 +- docs/api/methods/stop_poll.md | 4 +- docs/api/methods/unban_chat_member.md | 4 +- docs/api/methods/unpin_chat_message.md | 4 +- docs/api/methods/upload_sticker_file.md | 5 +- docs/api/types/bot_command.md | 25 +++ docs/api/types/dice.md | 24 ++ docs/api/types/index.md | 3 +- docs/api/types/inline_query.md | 2 +- docs/api/types/inline_query_result_audio.md | 2 +- .../types/inline_query_result_cached_audio.md | 2 +- .../inline_query_result_cached_document.md | 2 +- .../types/inline_query_result_cached_gif.md | 2 +- .../inline_query_result_cached_mpeg4_gif.md | 2 +- .../types/inline_query_result_cached_photo.md | 2 +- .../types/inline_query_result_cached_video.md | 2 +- .../types/inline_query_result_cached_voice.md | 2 +- .../api/types/inline_query_result_document.md | 2 +- docs/api/types/inline_query_result_gif.md | 2 +- .../types/inline_query_result_mpeg4_gif.md | 2 +- docs/api/types/inline_query_result_photo.md | 2 +- docs/api/types/inline_query_result_video.md | 2 +- docs/api/types/inline_query_result_voice.md | 4 +- docs/api/types/input_media_animation.md | 2 +- docs/api/types/input_media_audio.md | 2 +- docs/api/types/input_media_document.md | 2 +- docs/api/types/input_media_photo.md | 2 +- docs/api/types/input_media_video.md | 2 +- docs/api/types/keyboard_button.md | 4 +- docs/api/types/message.md | 8 +- docs/api/types/sticker.md | 2 +- docs/api/types/sticker_set.md | 2 + mkdocs.yml | 14 +- poetry.lock | 117 +++++----- pyproject.toml | 3 +- .../test_methods/test_get_my_commands.py | 27 +++ tests/test_api/test_methods/test_send_dice.py | 25 +++ .../test_methods/test_set_my_commands.py | 28 +++ .../test_set_sticker_set_thumb.py | 26 +++ tests/test_utils/test_helper.py | 1 + tests/test_utils/test_mixins.py | 5 +- 167 files changed, 996 insertions(+), 504 deletions(-) create mode 100644 aiogram/api/methods/get_my_commands.py create mode 100644 aiogram/api/methods/send_dice.py create mode 100644 aiogram/api/methods/set_my_commands.py create mode 100644 aiogram/api/methods/set_sticker_set_thumb.py create mode 100644 aiogram/api/types/bot_command.py create mode 100644 aiogram/api/types/dice.py create mode 100644 docs/api/methods/get_my_commands.md create mode 100644 docs/api/methods/send_dice.md create mode 100644 docs/api/methods/set_my_commands.md create mode 100644 docs/api/methods/set_sticker_set_thumb.md create mode 100644 docs/api/types/bot_command.md create mode 100644 docs/api/types/dice.md create mode 100644 tests/test_api/test_methods/test_get_my_commands.py create mode 100644 tests/test_api/test_methods/test_send_dice.py create mode 100644 tests/test_api/test_methods/test_set_my_commands.py create mode 100644 tests/test_api/test_methods/test_set_sticker_set_thumb.py diff --git a/aiogram/__init__.py b/aiogram/__init__.py index 0bc46460..8975399c 100644 --- a/aiogram/__init__.py +++ b/aiogram/__init__.py @@ -26,5 +26,5 @@ __all__ = ( "handler", ) -__version__ = "3.0.0a2" -__api_version__ = "4.6" +__version__ = "3.0.0a3" +__api_version__ = "4.7" diff --git a/aiogram/api/client/bot.py b/aiogram/api/client/bot.py index 00ec955d..27293d83 100644 --- a/aiogram/api/client/bot.py +++ b/aiogram/api/client/bot.py @@ -2,19 +2,12 @@ from __future__ import annotations import datetime from contextlib import asynccontextmanager -from typing import ( - List, - Optional, - Union, - TypeVar, - AsyncIterator, - Any, -) +from typing import Any, AsyncIterator, List, Optional, TypeVar, Union from async_lru import alru_cache -from .session.aiohttp import AiohttpSession -from .session.base import BaseSession +from ...utils.mixins import ContextInstanceMixin +from ...utils.token import extract_bot_id, validate_token from ..methods import ( AddStickerToSet, AnswerCallbackQuery, @@ -41,6 +34,7 @@ from ..methods import ( GetFile, GetGameHighScores, GetMe, + GetMyCommands, GetStickerSet, GetUpdates, GetUserProfilePhotos, @@ -54,6 +48,7 @@ from ..methods import ( SendAudio, SendChatAction, SendContact, + SendDice, SendDocument, SendGame, SendInvoice, @@ -74,17 +69,20 @@ from ..methods import ( SetChatStickerSet, SetChatTitle, SetGameScore, + SetMyCommands, SetPassportDataErrors, SetStickerPositionInSet, + SetStickerSetThumb, SetWebhook, StopMessageLiveLocation, StopPoll, + TelegramMethod, UnbanChatMember, UnpinChatMessage, UploadStickerFile, - TelegramMethod, ) from ..types import ( + BotCommand, Chat, ChatMember, ChatPermissions, @@ -111,18 +109,15 @@ from ..types import ( UserProfilePhotos, WebhookInfo, ) -from ...utils.mixins import ContextInstanceMixin -from ...utils.token import ( - validate_token, - extract_bot_id, -) +from .session.aiohttp import AiohttpSession +from .session.base import BaseSession T = TypeVar("T") class Bot(ContextInstanceMixin["Bot"]): """ - Class where located all API methods + Main bot class """ def __init__( @@ -146,21 +141,6 @@ class Bot(ContextInstanceMixin["Bot"]): """ return extract_bot_id(self.__token) - async def __call__(self, method: TelegramMethod[T]) -> T: - """ - Call API method - - :param method: - :return: - """ - return await self.session.make_request(self.__token, method) - - async def close(self) -> None: - """ - Close bot session - """ - await self.session.close() - @asynccontextmanager async def context(self, auto_close: bool = True) -> AsyncIterator[Bot]: """ @@ -177,6 +157,25 @@ class Bot(ContextInstanceMixin["Bot"]): await self.close() self.reset_current(token) + @alru_cache() # type: ignore + async def me(self) -> User: + return await self.get_me() + + async def close(self) -> None: + """ + Close bot session + """ + await self.session.close() + + async def __call__(self, method: TelegramMethod[T]) -> T: + """ + Call API method + + :param method: + :return: + """ + return await self.session.make_request(self.__token, method) + def __hash__(self) -> int: """ Get hash for the token @@ -196,10 +195,6 @@ class Bot(ContextInstanceMixin["Bot"]): return False return hash(self) == hash(other) - @alru_cache() # type: ignore - async def me(self) -> User: - return await self.get_me() - # ============================================================================================= # Group: Getting updates # Source: https://core.telegram.org/bots/api#getting-updates @@ -359,7 +354,7 @@ class Bot(ContextInstanceMixin["Bot"]): :param chat_id: Unique identifier for the target chat or username of the target channel (in the format @channelusername) - :param text: Text of the message to be sent + :param text: Text of the message to be sent, 1-4096 characters after entities parsing :param parse_mode: Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message. :param disable_web_page_preview: Disables link previews for links in this message @@ -435,7 +430,7 @@ class Bot(ContextInstanceMixin["Bot"]): get a photo from the Internet, or upload a new photo using multipart/form-data. :param caption: Photo caption (may also be used when resending photos by file_id), 0-1024 - characters + characters after entities parsing :param parse_mode: Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. :param disable_notification: Sends the message silently. Users will receive a notification @@ -488,7 +483,7 @@ class Bot(ContextInstanceMixin["Bot"]): exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get an audio file from the Internet, or upload a new one using multipart/form-data. - :param caption: Audio caption, 0-1024 characters + :param caption: Audio caption, 0-1024 characters after entities parsing :param parse_mode: Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. :param duration: Duration of the audio in seconds @@ -558,7 +553,7 @@ class Bot(ContextInstanceMixin["Bot"]): can pass 'attach://' if the thumbnail was uploaded using multipart/form-data under . :param caption: Document caption (may also be used when resending documents by file_id), - 0-1024 characters + 0-1024 characters after entities parsing :param parse_mode: Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. :param disable_notification: Sends the message silently. Users will receive a notification @@ -622,7 +617,7 @@ class Bot(ContextInstanceMixin["Bot"]): can pass 'attach://' if the thumbnail was uploaded using multipart/form-data under . :param caption: Video caption (may also be used when resending videos by file_id), 0-1024 - characters + characters after entities parsing :param parse_mode: Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. :param supports_streaming: Pass True, if the uploaded video is suitable for streaming @@ -690,7 +685,7 @@ class Bot(ContextInstanceMixin["Bot"]): can pass 'attach://' if the thumbnail was uploaded using multipart/form-data under . :param caption: Animation caption (may also be used when resending animation by file_id), - 0-1024 characters + 0-1024 characters after entities parsing :param parse_mode: Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. :param disable_notification: Sends the message silently. Users will receive a notification @@ -731,7 +726,7 @@ class Bot(ContextInstanceMixin["Bot"]): ) -> Message: """ Use this method to send audio files, if you want Telegram clients to display the file as a - playable voice message. For this to work, your audio must be in an .ogg file encoded with + playable voice message. For this to work, your audio must be in an .OGG file encoded with OPUS (other formats may be sent as Audio or Document). On success, the sent Message is returned. Bots can currently send voice messages of up to 50 MB in size, this limit may be changed in the future. @@ -744,7 +739,7 @@ class Bot(ContextInstanceMixin["Bot"]): the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. - :param caption: Voice message caption, 0-1024 characters + :param caption: Voice message caption, 0-1024 characters after entities parsing :param parse_mode: Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. :param duration: Duration of the voice message in seconds @@ -1121,6 +1116,40 @@ class Bot(ContextInstanceMixin["Bot"]): ) return await self(call) + async def send_dice( + self, + chat_id: Union[int, str], + disable_notification: Optional[bool] = None, + reply_to_message_id: Optional[int] = None, + reply_markup: Optional[ + Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply] + ] = None, + ) -> Message: + """ + Use this method to send a dice, which will have a random value from 1 to 6. On success, + the sent Message is returned. (Yes, we're aware of the 'proper' singular of die. But it's + awkward, and we decided to help it change. One dice at a time!) + + Source: https://core.telegram.org/bots/api#senddice + + :param chat_id: Unique identifier for the target chat or username of the target channel + (in the format @channelusername) + :param disable_notification: Sends the message silently. Users will receive a notification + with no sound. + :param reply_to_message_id: If the message is a reply, ID of the original message + :param reply_markup: Additional interface options. A JSON-serialized object for an inline + keyboard, custom reply keyboard, instructions to remove reply + keyboard or to force a reply from the user. + :return: On success, the sent Message is returned. + """ + call = SendDice( + chat_id=chat_id, + disable_notification=disable_notification, + reply_to_message_id=reply_to_message_id, + reply_markup=reply_markup, + ) + return await self(call) + async def send_chat_action(self, chat_id: Union[int, str], action: str,) -> bool: """ Use this method when you need to tell the user that something is happening on the bot's @@ -1631,6 +1660,31 @@ class Bot(ContextInstanceMixin["Bot"]): ) return await self(call) + async def set_my_commands(self, commands: List[BotCommand],) -> bool: + """ + Use this method to change the list of the bot's commands. Returns True on success. + + Source: https://core.telegram.org/bots/api#setmycommands + + :param commands: A JSON-serialized list of bot commands to be set as the list of the bot's + commands. At most 100 commands can be specified. + :return: Returns True on success. + """ + call = SetMyCommands(commands=commands,) + return await self(call) + + async def get_my_commands(self,) -> List[BotCommand]: + """ + Use this method to get the current list of the bot's commands. Requires no parameters. + Returns Array of BotCommand on success. + + Source: https://core.telegram.org/bots/api#getmycommands + + :return: Returns Array of BotCommand on success. + """ + call = GetMyCommands() + return await self(call) + # ============================================================================================= # Group: Updating messages # Source: https://core.telegram.org/bots/api#updating-messages @@ -1652,7 +1706,7 @@ class Bot(ContextInstanceMixin["Bot"]): Source: https://core.telegram.org/bots/api#editmessagetext - :param text: New text of the message + :param text: New text of the message, 1-4096 characters after entities parsing :param chat_id: Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername) @@ -1700,7 +1754,7 @@ class Bot(ContextInstanceMixin["Bot"]): message to edit :param inline_message_id: Required if chat_id and message_id are not specified. Identifier of the inline message - :param caption: New caption of the message + :param caption: New caption of the message, 0-1024 characters after entities parsing :param parse_mode: Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. :param reply_markup: A JSON-serialized object for an inline keyboard. @@ -1814,6 +1868,8 @@ class Bot(ContextInstanceMixin["Bot"]): Use this method to delete a message, including service messages, with the following limitations: - A message can only be deleted if it was sent less than 48 hours ago. + - A dice message in a private chat can only be deleted if it was sent more than 24 hours + ago. - Bots can delete outgoing messages in private chats, groups, and supergroups. - Bots can delete incoming messages in private chats. - Bots granted can_post_messages permissions can delete outgoing messages in channels. @@ -1857,7 +1913,7 @@ class Bot(ContextInstanceMixin["Bot"]): (in the format @channelusername) :param sticker: Sticker to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for - Telegram to get a .webp file from the Internet, or upload a new one using + Telegram to get a .WEBP file from the Internet, or upload a new one using multipart/form-data. :param disable_notification: Sends the message silently. Users will receive a notification with no sound. @@ -1890,7 +1946,7 @@ class Bot(ContextInstanceMixin["Bot"]): async def upload_sticker_file(self, user_id: int, png_sticker: InputFile,) -> File: """ - Use this method to upload a .png file with a sticker for later use in createNewStickerSet + Use this method to upload a .PNG file with a sticker for later use in createNewStickerSet and addStickerToSet methods (can be used multiple times). Returns the uploaded File on success. @@ -1910,14 +1966,16 @@ class Bot(ContextInstanceMixin["Bot"]): user_id: int, name: str, title: str, - png_sticker: Union[InputFile, str], emojis: str, + png_sticker: Optional[Union[InputFile, str]] = None, + tgs_sticker: Optional[InputFile] = None, contains_masks: Optional[bool] = None, mask_position: Optional[MaskPosition] = None, ) -> bool: """ - Use this method to create new sticker set owned by a user. The bot will be able to edit - the created sticker set. Returns True on success. + Use this method to create a new sticker set owned by a user. The bot will be able to edit + the sticker set thus created. You must use exactly one of the fields png_sticker or + tgs_sticker. Returns True on success. Source: https://core.telegram.org/bots/api#createnewstickerset @@ -1927,13 +1985,16 @@ class Bot(ContextInstanceMixin["Bot"]): begin with a letter, can't contain consecutive underscores and must end in '_by_'. is case insensitive. 1-64 characters. :param title: Sticker set title, 1-64 characters - :param png_sticker: Png image with the sticker, must be up to 512 kilobytes in size, + :param emojis: One or more emoji corresponding to the sticker + :param png_sticker: PNG image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. - :param emojis: One or more emoji corresponding to the sticker + :param tgs_sticker: TGS animation with the sticker, uploaded using multipart/form-data. + See https://core.telegram.org/animated_stickers#technical-requirements + for technical requirements :param contains_masks: Pass True, if a set of mask stickers should be created :param mask_position: A JSON-serialized object for position where the mask should be placed on faces @@ -1943,8 +2004,9 @@ class Bot(ContextInstanceMixin["Bot"]): user_id=user_id, name=name, title=title, - png_sticker=png_sticker, emojis=emojis, + png_sticker=png_sticker, + tgs_sticker=tgs_sticker, contains_masks=contains_masks, mask_position=mask_position, ) @@ -1956,22 +2018,29 @@ class Bot(ContextInstanceMixin["Bot"]): name: str, png_sticker: Union[InputFile, str], emojis: str, + tgs_sticker: Optional[InputFile] = None, mask_position: Optional[MaskPosition] = None, ) -> bool: """ - Use this method to add a new sticker to a set created by the bot. Returns True on success. + Use this method to add a new sticker to a set created by the bot. You must use exactly one + of the fields png_sticker or tgs_sticker. Animated stickers can be added to animated + sticker sets and only to them. Animated sticker sets can have up to 50 stickers. Static + sticker sets can have up to 120 stickers. Returns True on success. Source: https://core.telegram.org/bots/api#addstickertoset :param user_id: User identifier of sticker set owner :param name: Sticker set name - :param png_sticker: Png image with the sticker, must be up to 512 kilobytes in size, + :param png_sticker: PNG image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. :param emojis: One or more emoji corresponding to the sticker + :param tgs_sticker: TGS animation with the sticker, uploaded using multipart/form-data. + See https://core.telegram.org/animated_stickers#technical-requirements + for technical requirements :param mask_position: A JSON-serialized object for position where the mask should be placed on faces :return: Returns True on success. @@ -1981,13 +2050,14 @@ class Bot(ContextInstanceMixin["Bot"]): name=name, png_sticker=png_sticker, emojis=emojis, + tgs_sticker=tgs_sticker, mask_position=mask_position, ) return await self(call) async def set_sticker_position_in_set(self, sticker: str, position: int,) -> bool: """ - Use this method to move a sticker in a set created by the bot to a specific position . + Use this method to move a sticker in a set created by the bot to a specific position. Returns True on success. Source: https://core.telegram.org/bots/api#setstickerpositioninset @@ -2012,6 +2082,31 @@ class Bot(ContextInstanceMixin["Bot"]): call = DeleteStickerFromSet(sticker=sticker,) return await self(call) + async def set_sticker_set_thumb( + self, name: str, user_id: int, thumb: Optional[Union[InputFile, str]] = None, + ) -> bool: + """ + Use this method to set the thumbnail of a sticker set. Animated thumbnails can be set for + animated sticker sets only. Returns True on success. + + Source: https://core.telegram.org/bots/api#setstickersetthumb + + :param name: Sticker set name + :param user_id: User identifier of the sticker set owner + :param thumb: A PNG image with the thumbnail, must be up to 128 kilobytes in size and have + width and height exactly 100px, or a TGS animation with the thumbnail up to + 32 kilobytes in size; see + https://core.telegram.org/animated_stickers#technical-requirements for + animated sticker technical requirements. Pass a file_id as a String to send + a file that already exists on the Telegram servers, pass an HTTP URL as a + String for Telegram to get a file from the Internet, or upload a new one + using multipart/form-data.. Animated sticker set thumbnail can't be uploaded + via HTTP URL. + :return: Returns True on success. + """ + call = SetStickerSetThumb(name=name, user_id=user_id, thumb=thumb,) + return await self(call) + # ============================================================================================= # Group: Inline mode # Source: https://core.telegram.org/bots/api#inline-mode diff --git a/aiogram/api/client/session/base.py b/aiogram/api/client/session/base.py index b7eeabd3..700810f1 100644 --- a/aiogram/api/client/session/base.py +++ b/aiogram/api/client/session/base.py @@ -4,15 +4,7 @@ import abc import datetime import json from types import TracebackType -from typing import ( - Any, - AsyncGenerator, - Callable, - Optional, - Type, - TypeVar, - Union, -) +from typing import Any, AsyncGenerator, Callable, Optional, Type, TypeVar, Union from aiogram.utils.exceptions import TelegramAPIError diff --git a/aiogram/api/methods/__init__.py b/aiogram/api/methods/__init__.py index b1a1344e..52785ed0 100644 --- a/aiogram/api/methods/__init__.py +++ b/aiogram/api/methods/__init__.py @@ -24,6 +24,7 @@ from .get_chat_members_count import GetChatMembersCount from .get_file import GetFile from .get_game_high_scores import GetGameHighScores from .get_me import GetMe +from .get_my_commands import GetMyCommands from .get_sticker_set import GetStickerSet from .get_updates import GetUpdates from .get_user_profile_photos import GetUserProfilePhotos @@ -37,6 +38,7 @@ from .send_animation import SendAnimation from .send_audio import SendAudio from .send_chat_action import SendChatAction from .send_contact import SendContact +from .send_dice import SendDice from .send_document import SendDocument from .send_game import SendGame from .send_invoice import SendInvoice @@ -57,8 +59,10 @@ from .set_chat_photo import SetChatPhoto from .set_chat_sticker_set import SetChatStickerSet from .set_chat_title import SetChatTitle from .set_game_score import SetGameScore +from .set_my_commands import SetMyCommands from .set_passport_data_errors import SetPassportDataErrors from .set_sticker_position_in_set import SetStickerPositionInSet +from .set_sticker_set_thumb import SetStickerSetThumb from .set_webhook import SetWebhook from .stop_message_live_location import StopMessageLiveLocation from .stop_poll import StopPoll @@ -91,6 +95,7 @@ __all__ = ( "SendVenue", "SendContact", "SendPoll", + "SendDice", "SendChatAction", "GetUserProfilePhotos", "GetFile", @@ -115,6 +120,8 @@ __all__ = ( "SetChatStickerSet", "DeleteChatStickerSet", "AnswerCallbackQuery", + "SetMyCommands", + "GetMyCommands", "EditMessageText", "EditMessageCaption", "EditMessageMedia", @@ -128,6 +135,7 @@ __all__ = ( "AddStickerToSet", "SetStickerPositionInSet", "DeleteStickerFromSet", + "SetStickerSetThumb", "AnswerInlineQuery", "SendInvoice", "AnswerShippingQuery", diff --git a/aiogram/api/methods/add_sticker_to_set.py b/aiogram/api/methods/add_sticker_to_set.py index 57c1d2a7..517d21fc 100644 --- a/aiogram/api/methods/add_sticker_to_set.py +++ b/aiogram/api/methods/add_sticker_to_set.py @@ -6,7 +6,10 @@ from .base import Request, TelegramMethod, prepare_file class AddStickerToSet(TelegramMethod[bool]): """ - Use this method to add a new sticker to a set created by the bot. Returns True on success. + Use this method to add a new sticker to a set created by the bot. You must use exactly one of + the fields png_sticker or tgs_sticker. Animated stickers can be added to animated sticker sets + and only to them. Animated sticker sets can have up to 50 stickers. Static sticker sets can + have up to 120 stickers. Returns True on success. Source: https://core.telegram.org/bots/api#addstickertoset """ @@ -18,19 +21,24 @@ class AddStickerToSet(TelegramMethod[bool]): name: str """Sticker set name""" png_sticker: Union[InputFile, str] - """Png image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed + """PNG image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data.""" emojis: str """One or more emoji corresponding to the sticker""" + tgs_sticker: Optional[InputFile] = None + """TGS animation with the sticker, uploaded using multipart/form-data. See + https://core.telegram.org/animated_stickers#technical-requirements for technical + requirements""" mask_position: Optional[MaskPosition] = None """A JSON-serialized object for position where the mask should be placed on faces""" def build_request(self) -> Request: - data: Dict[str, Any] = self.dict(exclude={"png_sticker"}) + data: Dict[str, Any] = self.dict(exclude={"png_sticker", "tgs_sticker"}) files: Dict[str, InputFile] = {} prepare_file(data=data, files=files, name="png_sticker", value=self.png_sticker) + prepare_file(data=data, files=files, name="tgs_sticker", value=self.tgs_sticker) return Request(method="addStickerToSet", data=data, files=files) diff --git a/aiogram/api/methods/base.py b/aiogram/api/methods/base.py index e7fa1f2c..72eafa05 100644 --- a/aiogram/api/methods/base.py +++ b/aiogram/api/methods/base.py @@ -2,16 +2,7 @@ from __future__ import annotations import abc import secrets -from typing import ( - Generator, - TYPE_CHECKING, - Any, - Dict, - Generic, - Optional, - TypeVar, - Union, -) +from typing import TYPE_CHECKING, Any, Dict, Generator, Generic, Optional, TypeVar, Union from pydantic import BaseConfig, BaseModel, Extra from pydantic.generics import GenericModel diff --git a/aiogram/api/methods/create_new_sticker_set.py b/aiogram/api/methods/create_new_sticker_set.py index 72c3f699..f495986c 100644 --- a/aiogram/api/methods/create_new_sticker_set.py +++ b/aiogram/api/methods/create_new_sticker_set.py @@ -6,8 +6,9 @@ from .base import Request, TelegramMethod, prepare_file class CreateNewStickerSet(TelegramMethod[bool]): """ - Use this method to create new sticker set owned by a user. The bot will be able to edit the - created sticker set. Returns True on success. + Use this method to create a new sticker set owned by a user. The bot will be able to edit the + sticker set thus created. You must use exactly one of the fields png_sticker or tgs_sticker. + Returns True on success. Source: https://core.telegram.org/bots/api#createnewstickerset """ @@ -23,22 +24,27 @@ class CreateNewStickerSet(TelegramMethod[bool]): case insensitive. 1-64 characters.""" title: str """Sticker set title, 1-64 characters""" - png_sticker: Union[InputFile, str] - """Png image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed + emojis: str + """One or more emoji corresponding to the sticker""" + png_sticker: Optional[Union[InputFile, str]] = None + """PNG image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data.""" - emojis: str - """One or more emoji corresponding to the sticker""" + tgs_sticker: Optional[InputFile] = None + """TGS animation with the sticker, uploaded using multipart/form-data. See + https://core.telegram.org/animated_stickers#technical-requirements for technical + requirements""" contains_masks: Optional[bool] = None """Pass True, if a set of mask stickers should be created""" mask_position: Optional[MaskPosition] = None """A JSON-serialized object for position where the mask should be placed on faces""" def build_request(self) -> Request: - data: Dict[str, Any] = self.dict(exclude={"png_sticker"}) + data: Dict[str, Any] = self.dict(exclude={"png_sticker", "tgs_sticker"}) files: Dict[str, InputFile] = {} prepare_file(data=data, files=files, name="png_sticker", value=self.png_sticker) + prepare_file(data=data, files=files, name="tgs_sticker", value=self.tgs_sticker) return Request(method="createNewStickerSet", data=data, files=files) diff --git a/aiogram/api/methods/delete_message.py b/aiogram/api/methods/delete_message.py index 7032ad61..a38df0c0 100644 --- a/aiogram/api/methods/delete_message.py +++ b/aiogram/api/methods/delete_message.py @@ -8,6 +8,7 @@ class DeleteMessage(TelegramMethod[bool]): Use this method to delete a message, including service messages, with the following limitations: - A message can only be deleted if it was sent less than 48 hours ago. + - A dice message in a private chat can only be deleted if it was sent more than 24 hours ago. - Bots can delete outgoing messages in private chats, groups, and supergroups. - Bots can delete incoming messages in private chats. - Bots granted can_post_messages permissions can delete outgoing messages in channels. diff --git a/aiogram/api/methods/edit_message_caption.py b/aiogram/api/methods/edit_message_caption.py index f5ec110d..75b5cc69 100644 --- a/aiogram/api/methods/edit_message_caption.py +++ b/aiogram/api/methods/edit_message_caption.py @@ -22,7 +22,7 @@ class EditMessageCaption(TelegramMethod[Union[Message, bool]]): inline_message_id: Optional[str] = None """Required if chat_id and message_id are not specified. Identifier of the inline message""" caption: Optional[str] = None - """New caption of the message""" + """New caption of the message, 0-1024 characters after entities parsing""" parse_mode: Optional[str] = None """Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.""" diff --git a/aiogram/api/methods/edit_message_text.py b/aiogram/api/methods/edit_message_text.py index 8306ff06..5c3c4c4c 100644 --- a/aiogram/api/methods/edit_message_text.py +++ b/aiogram/api/methods/edit_message_text.py @@ -15,7 +15,7 @@ class EditMessageText(TelegramMethod[Union[Message, bool]]): __returning__ = Union[Message, bool] text: str - """New text of the message""" + """New text of the message, 1-4096 characters after entities parsing""" chat_id: Optional[Union[int, str]] = None """Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)""" diff --git a/aiogram/api/methods/get_my_commands.py b/aiogram/api/methods/get_my_commands.py new file mode 100644 index 00000000..1e1d8f1f --- /dev/null +++ b/aiogram/api/methods/get_my_commands.py @@ -0,0 +1,20 @@ +from typing import Any, Dict, List + +from ..types import BotCommand +from .base import Request, TelegramMethod + + +class GetMyCommands(TelegramMethod[List[BotCommand]]): + """ + Use this method to get the current list of the bot's commands. Requires no parameters. Returns + Array of BotCommand on success. + + Source: https://core.telegram.org/bots/api#getmycommands + """ + + __returning__ = List[BotCommand] + + def build_request(self) -> Request: + data: Dict[str, Any] = self.dict() + + return Request(method="getMyCommands", data=data) diff --git a/aiogram/api/methods/send_animation.py b/aiogram/api/methods/send_animation.py index 343019d2..27007d1b 100644 --- a/aiogram/api/methods/send_animation.py +++ b/aiogram/api/methods/send_animation.py @@ -43,7 +43,8 @@ class SendAnimation(TelegramMethod[Message]): file, so you can pass 'attach://' if the thumbnail was uploaded using multipart/form-data under .""" caption: Optional[str] = None - """Animation caption (may also be used when resending animation by file_id), 0-1024 characters""" + """Animation caption (may also be used when resending animation by file_id), 0-1024 characters + after entities parsing""" parse_mode: Optional[str] = None """Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.""" diff --git a/aiogram/api/methods/send_audio.py b/aiogram/api/methods/send_audio.py index fbbcd618..a67ca833 100644 --- a/aiogram/api/methods/send_audio.py +++ b/aiogram/api/methods/send_audio.py @@ -32,7 +32,7 @@ class SendAudio(TelegramMethod[Message]): Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get an audio file from the Internet, or upload a new one using multipart/form-data.""" caption: Optional[str] = None - """Audio caption, 0-1024 characters""" + """Audio caption, 0-1024 characters after entities parsing""" parse_mode: Optional[str] = None """Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.""" diff --git a/aiogram/api/methods/send_dice.py b/aiogram/api/methods/send_dice.py new file mode 100644 index 00000000..42a8b3a6 --- /dev/null +++ b/aiogram/api/methods/send_dice.py @@ -0,0 +1,40 @@ +from typing import Any, Dict, Optional, Union + +from ..types import ( + ForceReply, + InlineKeyboardMarkup, + Message, + ReplyKeyboardMarkup, + ReplyKeyboardRemove, +) +from .base import Request, TelegramMethod + + +class SendDice(TelegramMethod[Message]): + """ + Use this method to send a dice, which will have a random value from 1 to 6. On success, the + sent Message is returned. (Yes, we're aware of the 'proper' singular of die. But it's awkward, + and we decided to help it change. One dice at a time!) + + Source: https://core.telegram.org/bots/api#senddice + """ + + __returning__ = Message + + chat_id: Union[int, str] + """Unique identifier for the target chat or username of the target channel (in the format + @channelusername)""" + disable_notification: Optional[bool] = None + """Sends the message silently. Users will receive a notification with no sound.""" + reply_to_message_id: Optional[int] = None + """If the message is a reply, ID of the original message""" + reply_markup: Optional[ + Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply] + ] = None + """Additional interface options. A JSON-serialized object for an inline keyboard, custom reply + keyboard, instructions to remove reply keyboard or to force a reply from the user.""" + + def build_request(self) -> Request: + data: Dict[str, Any] = self.dict() + + return Request(method="sendDice", data=data) diff --git a/aiogram/api/methods/send_document.py b/aiogram/api/methods/send_document.py index c8bca68b..3c070539 100644 --- a/aiogram/api/methods/send_document.py +++ b/aiogram/api/methods/send_document.py @@ -37,7 +37,8 @@ class SendDocument(TelegramMethod[Message]): file, so you can pass 'attach://' if the thumbnail was uploaded using multipart/form-data under .""" caption: Optional[str] = None - """Document caption (may also be used when resending documents by file_id), 0-1024 characters""" + """Document caption (may also be used when resending documents by file_id), 0-1024 characters + after entities parsing""" parse_mode: Optional[str] = None """Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.""" diff --git a/aiogram/api/methods/send_message.py b/aiogram/api/methods/send_message.py index 15e3c7c3..849a1f5b 100644 --- a/aiogram/api/methods/send_message.py +++ b/aiogram/api/methods/send_message.py @@ -23,7 +23,7 @@ class SendMessage(TelegramMethod[Message]): """Unique identifier for the target chat or username of the target channel (in the format @channelusername)""" text: str - """Text of the message to be sent""" + """Text of the message to be sent, 1-4096 characters after entities parsing""" parse_mode: Optional[str] = None """Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message.""" diff --git a/aiogram/api/methods/send_photo.py b/aiogram/api/methods/send_photo.py index d737e145..328b29b6 100644 --- a/aiogram/api/methods/send_photo.py +++ b/aiogram/api/methods/send_photo.py @@ -28,7 +28,8 @@ class SendPhoto(TelegramMethod[Message]): (recommended), pass an HTTP URL as a String for Telegram to get a photo from the Internet, or upload a new photo using multipart/form-data.""" caption: Optional[str] = None - """Photo caption (may also be used when resending photos by file_id), 0-1024 characters""" + """Photo caption (may also be used when resending photos by file_id), 0-1024 characters after + entities parsing""" parse_mode: Optional[str] = None """Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.""" diff --git a/aiogram/api/methods/send_poll.py b/aiogram/api/methods/send_poll.py index ce8f26cb..8a71fe20 100644 --- a/aiogram/api/methods/send_poll.py +++ b/aiogram/api/methods/send_poll.py @@ -25,7 +25,7 @@ class SendPoll(TelegramMethod[Message]): question: str """Poll question, 1-255 characters""" options: List[str] - """List of answer options, 2-10 strings 1-100 characters each""" + """A JSON-serialized list of answer options, 2-10 strings 1-100 characters each""" is_anonymous: Optional[bool] = None """True, if the poll needs to be anonymous, defaults to True""" type: Optional[str] = None diff --git a/aiogram/api/methods/send_sticker.py b/aiogram/api/methods/send_sticker.py index 06cc5369..e110b2f8 100644 --- a/aiogram/api/methods/send_sticker.py +++ b/aiogram/api/methods/send_sticker.py @@ -26,7 +26,7 @@ class SendSticker(TelegramMethod[Message]): @channelusername)""" sticker: Union[InputFile, str] """Sticker to send. Pass a file_id as String to send a file that exists on the Telegram - servers (recommended), pass an HTTP URL as a String for Telegram to get a .webp file from + servers (recommended), pass an HTTP URL as a String for Telegram to get a .WEBP file from the Internet, or upload a new one using multipart/form-data.""" disable_notification: Optional[bool] = None """Sends the message silently. Users will receive a notification with no sound.""" diff --git a/aiogram/api/methods/send_video.py b/aiogram/api/methods/send_video.py index a7702c1a..07c4a3b6 100644 --- a/aiogram/api/methods/send_video.py +++ b/aiogram/api/methods/send_video.py @@ -43,7 +43,8 @@ class SendVideo(TelegramMethod[Message]): file, so you can pass 'attach://' if the thumbnail was uploaded using multipart/form-data under .""" caption: Optional[str] = None - """Video caption (may also be used when resending videos by file_id), 0-1024 characters""" + """Video caption (may also be used when resending videos by file_id), 0-1024 characters after + entities parsing""" parse_mode: Optional[str] = None """Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.""" diff --git a/aiogram/api/methods/send_voice.py b/aiogram/api/methods/send_voice.py index 2829e69c..17522782 100644 --- a/aiogram/api/methods/send_voice.py +++ b/aiogram/api/methods/send_voice.py @@ -14,7 +14,7 @@ from .base import Request, TelegramMethod, prepare_file class SendVoice(TelegramMethod[Message]): """ Use this method to send audio files, if you want Telegram clients to display the file as a - playable voice message. For this to work, your audio must be in an .ogg file encoded with OPUS + playable voice message. For this to work, your audio must be in an .OGG file encoded with OPUS (other formats may be sent as Audio or Document). On success, the sent Message is returned. Bots can currently send voice messages of up to 50 MB in size, this limit may be changed in the future. @@ -32,7 +32,7 @@ class SendVoice(TelegramMethod[Message]): servers (recommended), pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data.""" caption: Optional[str] = None - """Voice message caption, 0-1024 characters""" + """Voice message caption, 0-1024 characters after entities parsing""" parse_mode: Optional[str] = None """Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.""" diff --git a/aiogram/api/methods/set_my_commands.py b/aiogram/api/methods/set_my_commands.py new file mode 100644 index 00000000..97ac9bcb --- /dev/null +++ b/aiogram/api/methods/set_my_commands.py @@ -0,0 +1,23 @@ +from typing import Any, Dict, List + +from ..types import BotCommand +from .base import Request, TelegramMethod + + +class SetMyCommands(TelegramMethod[bool]): + """ + Use this method to change the list of the bot's commands. Returns True on success. + + Source: https://core.telegram.org/bots/api#setmycommands + """ + + __returning__ = bool + + commands: List[BotCommand] + """A JSON-serialized list of bot commands to be set as the list of the bot's commands. At most + 100 commands can be specified.""" + + def build_request(self) -> Request: + data: Dict[str, Any] = self.dict() + + return Request(method="setMyCommands", data=data) diff --git a/aiogram/api/methods/set_sticker_position_in_set.py b/aiogram/api/methods/set_sticker_position_in_set.py index c5b4a8a5..378a39d3 100644 --- a/aiogram/api/methods/set_sticker_position_in_set.py +++ b/aiogram/api/methods/set_sticker_position_in_set.py @@ -5,7 +5,7 @@ from .base import Request, TelegramMethod class SetStickerPositionInSet(TelegramMethod[bool]): """ - Use this method to move a sticker in a set created by the bot to a specific position . Returns + Use this method to move a sticker in a set created by the bot to a specific position. Returns True on success. Source: https://core.telegram.org/bots/api#setstickerpositioninset diff --git a/aiogram/api/methods/set_sticker_set_thumb.py b/aiogram/api/methods/set_sticker_set_thumb.py new file mode 100644 index 00000000..5ccd3bf3 --- /dev/null +++ b/aiogram/api/methods/set_sticker_set_thumb.py @@ -0,0 +1,36 @@ +from typing import Any, Dict, Optional, Union + +from ..types import InputFile +from .base import Request, TelegramMethod, prepare_file + + +class SetStickerSetThumb(TelegramMethod[bool]): + """ + Use this method to set the thumbnail of a sticker set. Animated thumbnails can be set for + animated sticker sets only. Returns True on success. + + Source: https://core.telegram.org/bots/api#setstickersetthumb + """ + + __returning__ = bool + + name: str + """Sticker set name""" + user_id: int + """User identifier of the sticker set owner""" + thumb: Optional[Union[InputFile, str]] = None + """A PNG image with the thumbnail, must be up to 128 kilobytes in size and have width and + height exactly 100px, or a TGS animation with the thumbnail up to 32 kilobytes in size; see + https://core.telegram.org/animated_stickers#technical-requirements for animated sticker + technical requirements. Pass a file_id as a String to send a file that already exists on + the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the + Internet, or upload a new one using multipart/form-data.. Animated sticker set thumbnail + can't be uploaded via HTTP URL.""" + + def build_request(self) -> Request: + data: Dict[str, Any] = self.dict(exclude={"thumb"}) + + files: Dict[str, InputFile] = {} + prepare_file(data=data, files=files, name="thumb", value=self.thumb) + + return Request(method="setStickerSetThumb", data=data, files=files) diff --git a/aiogram/api/methods/upload_sticker_file.py b/aiogram/api/methods/upload_sticker_file.py index 247d42af..e9eea3f0 100644 --- a/aiogram/api/methods/upload_sticker_file.py +++ b/aiogram/api/methods/upload_sticker_file.py @@ -6,7 +6,7 @@ from .base import Request, TelegramMethod, prepare_file class UploadStickerFile(TelegramMethod[File]): """ - Use this method to upload a .png file with a sticker for later use in createNewStickerSet and + Use this method to upload a .PNG file with a sticker for later use in createNewStickerSet and addStickerToSet methods (can be used multiple times). Returns the uploaded File on success. Source: https://core.telegram.org/bots/api#uploadstickerfile diff --git a/aiogram/api/types/__init__.py b/aiogram/api/types/__init__.py index fc94a7a7..429b6f41 100644 --- a/aiogram/api/types/__init__.py +++ b/aiogram/api/types/__init__.py @@ -1,6 +1,7 @@ from .animation import Animation from .audio import Audio from .base import TelegramObject +from .bot_command import BotCommand from .callback_game import CallbackGame from .callback_query import CallbackQuery from .chat import Chat @@ -9,6 +10,7 @@ from .chat_permissions import ChatPermissions from .chat_photo import ChatPhoto from .chosen_inline_result import ChosenInlineResult from .contact import Contact +from .dice import Dice from .document import Document from .encrypted_credentials import EncryptedCredentials from .encrypted_passport_element import EncryptedPassportElement @@ -121,6 +123,7 @@ __all__ = ( "PollOption", "PollAnswer", "Poll", + "Dice", "UserProfilePhotos", "File", "ReplyKeyboardMarkup", @@ -135,6 +138,7 @@ __all__ = ( "ChatPhoto", "ChatMember", "ChatPermissions", + "BotCommand", "ResponseParameters", "InputMedia", "InputMediaPhoto", diff --git a/aiogram/api/types/bot_command.py b/aiogram/api/types/bot_command.py new file mode 100644 index 00000000..96ef0a31 --- /dev/null +++ b/aiogram/api/types/bot_command.py @@ -0,0 +1,17 @@ +from __future__ import annotations + +from .base import MutableTelegramObject + + +class BotCommand(MutableTelegramObject): + """ + This object represents a bot command. + + Source: https://core.telegram.org/bots/api#botcommand + """ + + command: str + """Text of the command, 1-32 characters. Can contain only lowercase English letters, digits + and underscores.""" + description: str + """Description of the command, 3-256 characters.""" diff --git a/aiogram/api/types/dice.py b/aiogram/api/types/dice.py new file mode 100644 index 00000000..3b1436c6 --- /dev/null +++ b/aiogram/api/types/dice.py @@ -0,0 +1,15 @@ +from __future__ import annotations + +from .base import TelegramObject + + +class Dice(TelegramObject): + """ + This object represents a dice with random value from 1 to 6. (Yes, we're aware of the 'proper' + singular of die. But it's awkward, and we decided to help it change. One dice at a time!) + + Source: https://core.telegram.org/bots/api#dice + """ + + value: int + """Value of the dice, 1-6""" diff --git a/aiogram/api/types/inline_query_result_audio.py b/aiogram/api/types/inline_query_result_audio.py index 0290ee7e..c47104ba 100644 --- a/aiogram/api/types/inline_query_result_audio.py +++ b/aiogram/api/types/inline_query_result_audio.py @@ -31,7 +31,7 @@ class InlineQueryResultAudio(InlineQueryResult): title: str """Title""" caption: Optional[str] = None - """Caption, 0-1024 characters""" + """Caption, 0-1024 characters after entities parsing""" parse_mode: Optional[str] = None """Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.""" diff --git a/aiogram/api/types/inline_query_result_cached_audio.py b/aiogram/api/types/inline_query_result_cached_audio.py index 8f6fe23f..426ea462 100644 --- a/aiogram/api/types/inline_query_result_cached_audio.py +++ b/aiogram/api/types/inline_query_result_cached_audio.py @@ -29,7 +29,7 @@ class InlineQueryResultCachedAudio(InlineQueryResult): audio_file_id: str """A valid file identifier for the audio file""" caption: Optional[str] = None - """Caption, 0-1024 characters""" + """Caption, 0-1024 characters after entities parsing""" parse_mode: Optional[str] = None """Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.""" diff --git a/aiogram/api/types/inline_query_result_cached_document.py b/aiogram/api/types/inline_query_result_cached_document.py index 860dbcc8..27bcd27e 100644 --- a/aiogram/api/types/inline_query_result_cached_document.py +++ b/aiogram/api/types/inline_query_result_cached_document.py @@ -33,7 +33,7 @@ class InlineQueryResultCachedDocument(InlineQueryResult): description: Optional[str] = None """Short description of the result""" caption: Optional[str] = None - """Caption of the document to be sent, 0-1024 characters""" + """Caption of the document to be sent, 0-1024 characters after entities parsing""" parse_mode: Optional[str] = None """Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.""" diff --git a/aiogram/api/types/inline_query_result_cached_gif.py b/aiogram/api/types/inline_query_result_cached_gif.py index f237c5fb..2b85bcd9 100644 --- a/aiogram/api/types/inline_query_result_cached_gif.py +++ b/aiogram/api/types/inline_query_result_cached_gif.py @@ -29,7 +29,7 @@ class InlineQueryResultCachedGif(InlineQueryResult): title: Optional[str] = None """Title for the result""" caption: Optional[str] = None - """Caption of the GIF file to be sent, 0-1024 characters""" + """Caption of the GIF file to be sent, 0-1024 characters after entities parsing""" parse_mode: Optional[str] = None """Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.""" diff --git a/aiogram/api/types/inline_query_result_cached_mpeg4_gif.py b/aiogram/api/types/inline_query_result_cached_mpeg4_gif.py index 0b770121..5611e114 100644 --- a/aiogram/api/types/inline_query_result_cached_mpeg4_gif.py +++ b/aiogram/api/types/inline_query_result_cached_mpeg4_gif.py @@ -30,7 +30,7 @@ class InlineQueryResultCachedMpeg4Gif(InlineQueryResult): title: Optional[str] = None """Title for the result""" caption: Optional[str] = None - """Caption of the MPEG-4 file to be sent, 0-1024 characters""" + """Caption of the MPEG-4 file to be sent, 0-1024 characters after entities parsing""" parse_mode: Optional[str] = None """Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.""" diff --git a/aiogram/api/types/inline_query_result_cached_photo.py b/aiogram/api/types/inline_query_result_cached_photo.py index 1c163285..da865bed 100644 --- a/aiogram/api/types/inline_query_result_cached_photo.py +++ b/aiogram/api/types/inline_query_result_cached_photo.py @@ -31,7 +31,7 @@ class InlineQueryResultCachedPhoto(InlineQueryResult): description: Optional[str] = None """Short description of the result""" caption: Optional[str] = None - """Caption of the photo to be sent, 0-1024 characters""" + """Caption of the photo to be sent, 0-1024 characters after entities parsing""" parse_mode: Optional[str] = None """Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.""" diff --git a/aiogram/api/types/inline_query_result_cached_video.py b/aiogram/api/types/inline_query_result_cached_video.py index 3114e9e2..db71f4f2 100644 --- a/aiogram/api/types/inline_query_result_cached_video.py +++ b/aiogram/api/types/inline_query_result_cached_video.py @@ -31,7 +31,7 @@ class InlineQueryResultCachedVideo(InlineQueryResult): description: Optional[str] = None """Short description of the result""" caption: Optional[str] = None - """Caption of the video to be sent, 0-1024 characters""" + """Caption of the video to be sent, 0-1024 characters after entities parsing""" parse_mode: Optional[str] = None """Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.""" diff --git a/aiogram/api/types/inline_query_result_cached_voice.py b/aiogram/api/types/inline_query_result_cached_voice.py index 4ba72004..9d65b6fd 100644 --- a/aiogram/api/types/inline_query_result_cached_voice.py +++ b/aiogram/api/types/inline_query_result_cached_voice.py @@ -31,7 +31,7 @@ class InlineQueryResultCachedVoice(InlineQueryResult): title: str """Voice message title""" caption: Optional[str] = None - """Caption, 0-1024 characters""" + """Caption, 0-1024 characters after entities parsing""" parse_mode: Optional[str] = None """Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.""" diff --git a/aiogram/api/types/inline_query_result_document.py b/aiogram/api/types/inline_query_result_document.py index 97fb5209..625b4675 100644 --- a/aiogram/api/types/inline_query_result_document.py +++ b/aiogram/api/types/inline_query_result_document.py @@ -34,7 +34,7 @@ class InlineQueryResultDocument(InlineQueryResult): mime_type: str """Mime type of the content of the file, either 'application/pdf' or 'application/zip'""" caption: Optional[str] = None - """Caption of the document to be sent, 0-1024 characters""" + """Caption of the document to be sent, 0-1024 characters after entities parsing""" parse_mode: Optional[str] = None """Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.""" diff --git a/aiogram/api/types/inline_query_result_gif.py b/aiogram/api/types/inline_query_result_gif.py index 3f4abfb4..ffaa7a66 100644 --- a/aiogram/api/types/inline_query_result_gif.py +++ b/aiogram/api/types/inline_query_result_gif.py @@ -37,7 +37,7 @@ class InlineQueryResultGif(InlineQueryResult): title: Optional[str] = None """Title for the result""" caption: Optional[str] = None - """Caption of the GIF file to be sent, 0-1024 characters""" + """Caption of the GIF file to be sent, 0-1024 characters after entities parsing""" parse_mode: Optional[str] = None """Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.""" diff --git a/aiogram/api/types/inline_query_result_mpeg4_gif.py b/aiogram/api/types/inline_query_result_mpeg4_gif.py index 8edaf79b..59d1ef01 100644 --- a/aiogram/api/types/inline_query_result_mpeg4_gif.py +++ b/aiogram/api/types/inline_query_result_mpeg4_gif.py @@ -38,7 +38,7 @@ class InlineQueryResultMpeg4Gif(InlineQueryResult): title: Optional[str] = None """Title for the result""" caption: Optional[str] = None - """Caption of the MPEG-4 file to be sent, 0-1024 characters""" + """Caption of the MPEG-4 file to be sent, 0-1024 characters after entities parsing""" parse_mode: Optional[str] = None """Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.""" diff --git a/aiogram/api/types/inline_query_result_photo.py b/aiogram/api/types/inline_query_result_photo.py index 0a08bdc1..7ee7e4f5 100644 --- a/aiogram/api/types/inline_query_result_photo.py +++ b/aiogram/api/types/inline_query_result_photo.py @@ -37,7 +37,7 @@ class InlineQueryResultPhoto(InlineQueryResult): description: Optional[str] = None """Short description of the result""" caption: Optional[str] = None - """Caption of the photo to be sent, 0-1024 characters""" + """Caption of the photo to be sent, 0-1024 characters after entities parsing""" parse_mode: Optional[str] = None """Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.""" diff --git a/aiogram/api/types/inline_query_result_video.py b/aiogram/api/types/inline_query_result_video.py index ecc3663a..a0010fea 100644 --- a/aiogram/api/types/inline_query_result_video.py +++ b/aiogram/api/types/inline_query_result_video.py @@ -35,7 +35,7 @@ class InlineQueryResultVideo(InlineQueryResult): title: str """Title for the result""" caption: Optional[str] = None - """Caption of the video to be sent, 0-1024 characters""" + """Caption of the video to be sent, 0-1024 characters after entities parsing""" parse_mode: Optional[str] = None """Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.""" diff --git a/aiogram/api/types/inline_query_result_voice.py b/aiogram/api/types/inline_query_result_voice.py index d04ca805..b4b10f4f 100644 --- a/aiogram/api/types/inline_query_result_voice.py +++ b/aiogram/api/types/inline_query_result_voice.py @@ -13,7 +13,7 @@ if TYPE_CHECKING: # pragma: no cover class InlineQueryResultVoice(InlineQueryResult): """ - Represents a link to a voice recording in an .ogg container encoded with OPUS. By default, + Represents a link to a voice recording in an .OGG container encoded with OPUS. By default, this voice recording will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the the voice message. @@ -32,7 +32,7 @@ class InlineQueryResultVoice(InlineQueryResult): title: str """Recording title""" caption: Optional[str] = None - """Caption, 0-1024 characters""" + """Caption, 0-1024 characters after entities parsing""" parse_mode: Optional[str] = None """Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.""" diff --git a/aiogram/api/types/input_file.py b/aiogram/api/types/input_file.py index 27b452cb..0b6c1442 100644 --- a/aiogram/api/types/input_file.py +++ b/aiogram/api/types/input_file.py @@ -4,13 +4,7 @@ import io import os from abc import ABC, abstractmethod from pathlib import Path -from typing import ( - AsyncGenerator, - AsyncIterator, - Iterator, - Optional, - Union, -) +from typing import AsyncGenerator, AsyncIterator, Iterator, Optional, Union import aiofiles as aiofiles diff --git a/aiogram/api/types/input_media_animation.py b/aiogram/api/types/input_media_animation.py index 5e4439b4..de994e85 100644 --- a/aiogram/api/types/input_media_animation.py +++ b/aiogram/api/types/input_media_animation.py @@ -32,7 +32,7 @@ class InputMediaAnimation(InputMedia): file, so you can pass 'attach://' if the thumbnail was uploaded using multipart/form-data under .""" caption: Optional[str] = None - """Caption of the animation to be sent, 0-1024 characters""" + """Caption of the animation to be sent, 0-1024 characters after entities parsing""" parse_mode: Optional[str] = None """Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.""" diff --git a/aiogram/api/types/input_media_audio.py b/aiogram/api/types/input_media_audio.py index 73bba3be..9d700101 100644 --- a/aiogram/api/types/input_media_audio.py +++ b/aiogram/api/types/input_media_audio.py @@ -32,7 +32,7 @@ class InputMediaAudio(InputMedia): file, so you can pass 'attach://' if the thumbnail was uploaded using multipart/form-data under .""" caption: Optional[str] = None - """Caption of the audio to be sent, 0-1024 characters""" + """Caption of the audio to be sent, 0-1024 characters after entities parsing""" parse_mode: Optional[str] = None """Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.""" diff --git a/aiogram/api/types/input_media_document.py b/aiogram/api/types/input_media_document.py index 1c9d2b31..5f95b233 100644 --- a/aiogram/api/types/input_media_document.py +++ b/aiogram/api/types/input_media_document.py @@ -32,7 +32,7 @@ class InputMediaDocument(InputMedia): file, so you can pass 'attach://' if the thumbnail was uploaded using multipart/form-data under .""" caption: Optional[str] = None - """Caption of the document to be sent, 0-1024 characters""" + """Caption of the document to be sent, 0-1024 characters after entities parsing""" parse_mode: Optional[str] = None """Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.""" diff --git a/aiogram/api/types/input_media_photo.py b/aiogram/api/types/input_media_photo.py index 60b9227c..7698d95d 100644 --- a/aiogram/api/types/input_media_photo.py +++ b/aiogram/api/types/input_media_photo.py @@ -25,7 +25,7 @@ class InputMediaPhoto(InputMedia): 'attach://' to upload a new one using multipart/form-data under name.""" caption: Optional[str] = None - """Caption of the photo to be sent, 0-1024 characters""" + """Caption of the photo to be sent, 0-1024 characters after entities parsing""" parse_mode: Optional[str] = None """Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.""" diff --git a/aiogram/api/types/input_media_video.py b/aiogram/api/types/input_media_video.py index 4537fa80..a0cdd46f 100644 --- a/aiogram/api/types/input_media_video.py +++ b/aiogram/api/types/input_media_video.py @@ -32,7 +32,7 @@ class InputMediaVideo(InputMedia): file, so you can pass 'attach://' if the thumbnail was uploaded using multipart/form-data under .""" caption: Optional[str] = None - """Caption of the video to be sent, 0-1024 characters""" + """Caption of the video to be sent, 0-1024 characters after entities parsing""" parse_mode: Optional[str] = None """Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.""" diff --git a/aiogram/api/types/message.py b/aiogram/api/types/message.py index 5af79d25..f4b9e655 100644 --- a/aiogram/api/types/message.py +++ b/aiogram/api/types/message.py @@ -13,6 +13,7 @@ if TYPE_CHECKING: # pragma: no cover from .audio import Audio from .chat import Chat from .contact import Contact + from .dice import Dice from .document import Document from .force_reply import ForceReply from .game import Game @@ -95,7 +96,7 @@ class Message(TelegramObject): author_signature: Optional[str] = None """Signature of the post author for messages in channels""" text: Optional[str] = None - """For text messages, the actual UTF-8 text of the message, 0-4096 characters.""" + """For text messages, the actual UTF-8 text of the message, 0-4096 characters""" entities: Optional[List[MessageEntity]] = None """For text messages, special entities like usernames, URLs, bot commands, etc. that appear in the text""" @@ -131,6 +132,8 @@ class Message(TelegramObject): """Message is a venue, information about the venue""" poll: Optional[Poll] = None """Message is a native poll, information about the poll""" + dice: Optional[Dice] = None + """Message is a dice with random value from 1 to 6""" new_chat_members: Optional[List[User]] = None """New members that were added to the group or supergroup and information about them (the bot itself may be one of these members)""" @@ -1479,7 +1482,8 @@ class ContentType(helper.Helper): DELETE_CHAT_PHOTO = helper.Item() # delete_chat_photo GROUP_CHAT_CREATED = helper.Item() # group_chat_created PASSPORT_DATA = helper.Item() # passport_data - POLL = helper.Item() + POLL = helper.Item() # poll + DICE = helper.Item() # dice UNKNOWN = helper.Item() # unknown ANY = helper.Item() # any diff --git a/aiogram/api/types/sticker.py b/aiogram/api/types/sticker.py index 1743de6b..23d22bfc 100644 --- a/aiogram/api/types/sticker.py +++ b/aiogram/api/types/sticker.py @@ -28,7 +28,7 @@ class Sticker(TelegramObject): is_animated: bool """True, if the sticker is animated""" thumb: Optional[PhotoSize] = None - """Sticker thumbnail in the .webp or .jpg format""" + """Sticker thumbnail in the .WEBP or .JPG format""" emoji: Optional[str] = None """Emoji associated with the sticker""" set_name: Optional[str] = None diff --git a/aiogram/api/types/sticker_set.py b/aiogram/api/types/sticker_set.py index cec9b3be..2b9e7ab1 100644 --- a/aiogram/api/types/sticker_set.py +++ b/aiogram/api/types/sticker_set.py @@ -1,10 +1,11 @@ from __future__ import annotations -from typing import TYPE_CHECKING, List +from typing import TYPE_CHECKING, List, Optional from .base import TelegramObject if TYPE_CHECKING: # pragma: no cover + from .photo_size import PhotoSize from .sticker import Sticker @@ -25,3 +26,5 @@ class StickerSet(TelegramObject): """True, if the sticker set contains masks""" stickers: List[Sticker] """List of all set stickers""" + thumb: Optional[PhotoSize] = None + """Sticker set thumbnail in the .WEBP or .TGS format""" diff --git a/aiogram/dispatcher/event/handler.py b/aiogram/dispatcher/event/handler.py index 5df6f28d..98bd5070 100644 --- a/aiogram/dispatcher/event/handler.py +++ b/aiogram/dispatcher/event/handler.py @@ -1,17 +1,7 @@ import inspect from dataclasses import dataclass, field from functools import partial -from typing import ( - Any, - Awaitable, - Callable, - Dict, - List, - Optional, - Tuple, - Union, - Type, -) +from typing import Any, Awaitable, Callable, Dict, List, Optional, Tuple, Type, Union from aiogram.dispatcher.filters.base import BaseFilter from aiogram.dispatcher.handler.base import BaseHandler diff --git a/aiogram/dispatcher/filters/__init__.py b/aiogram/dispatcher/filters/__init__.py index 3baca36f..25db7020 100644 --- a/aiogram/dispatcher/filters/__init__.py +++ b/aiogram/dispatcher/filters/__init__.py @@ -1,8 +1,4 @@ -from typing import ( - Dict, - Tuple, - Type, -) +from typing import Dict, Tuple, Type from .base import BaseFilter from .command import Command, CommandObject diff --git a/aiogram/dispatcher/filters/base.py b/aiogram/dispatcher/filters/base.py index a71c484a..04631dfc 100644 --- a/aiogram/dispatcher/filters/base.py +++ b/aiogram/dispatcher/filters/base.py @@ -1,12 +1,5 @@ from abc import ABC, abstractmethod -from typing import ( - TYPE_CHECKING, - Any, - Dict, - Union, - Callable, - Awaitable, -) +from typing import TYPE_CHECKING, Any, Awaitable, Callable, Dict, Union from pydantic import BaseModel diff --git a/aiogram/dispatcher/handler/base.py b/aiogram/dispatcher/handler/base.py index bf8f9785..e4000d1a 100644 --- a/aiogram/dispatcher/handler/base.py +++ b/aiogram/dispatcher/handler/base.py @@ -1,12 +1,5 @@ from abc import ABC, abstractmethod -from typing import ( - TYPE_CHECKING, - Any, - Dict, - Generic, - TypeVar, - cast, -) +from typing import TYPE_CHECKING, Any, Dict, Generic, TypeVar, cast from aiogram import Bot from aiogram.api.types import Update diff --git a/aiogram/dispatcher/handler/message.py b/aiogram/dispatcher/handler/message.py index 7e7e0ab6..a25daddc 100644 --- a/aiogram/dispatcher/handler/message.py +++ b/aiogram/dispatcher/handler/message.py @@ -1,8 +1,5 @@ from abc import ABC -from typing import ( - Optional, - cast, -) +from typing import Optional, cast from aiogram.api.types import Chat, Message, User from aiogram.dispatcher.filters import CommandObject diff --git a/aiogram/dispatcher/router.py b/aiogram/dispatcher/router.py index 44a47255..0b5cde3c 100644 --- a/aiogram/dispatcher/router.py +++ b/aiogram/dispatcher/router.py @@ -3,12 +3,7 @@ from __future__ import annotations import warnings from typing import Any, Dict, List, Optional, Union -from ..api.types import ( - Chat, - TelegramObject, - Update, - User, -) +from ..api.types import Chat, TelegramObject, Update, User from ..utils.imports import import_module from ..utils.warnings import CodeHasNoEffect from .event.observer import EventObserver, SkipHandler, TelegramEventObserver diff --git a/aiogram/utils/helper.py b/aiogram/utils/helper.py index 11e67ab4..e582a4f0 100644 --- a/aiogram/utils/helper.py +++ b/aiogram/utils/helper.py @@ -14,15 +14,7 @@ Example: <<< ['barItem', 'bazItem', 'fooItem', 'lorem'] """ import inspect -from typing import ( - Any, - Callable, - Iterable, - List, - Optional, - Union, - cast, -) +from typing import Any, Callable, Iterable, List, Optional, Union, cast PROPS_KEYS_ATTR_NAME = "_props_keys" diff --git a/aiogram/utils/mixins.py b/aiogram/utils/mixins.py index 8676ea33..f2def5d6 100644 --- a/aiogram/utils/mixins.py +++ b/aiogram/utils/mixins.py @@ -1,20 +1,12 @@ from __future__ import annotations -import contextvars -from typing import ( - Any, - ClassVar, - Generic, - Optional, - TypeVar, - cast, - overload, - Dict, -) -__all__ = ("ContextInstanceMixin", "DataMixin") +import contextvars +from typing import Any, ClassVar, Dict, Generic, Optional, TypeVar, cast, overload from typing_extensions import Literal +__all__ = ("ContextInstanceMixin", "DataMixin") + class DataMixin: @property @@ -56,18 +48,24 @@ class ContextInstanceMixin(Generic[ContextInstance]): def get_current(cls) -> Optional[ContextInstance]: # pragma: no cover ... - @overload # noqa: F811, it's overload, not redefinition + @overload @classmethod - def get_current(cls, no_error: Literal[True]) -> Optional[ContextInstance]: # pragma: no cover # noqa: F811 + def get_current( # noqa: F811 + cls, no_error: Literal[True] + ) -> Optional[ContextInstance]: # pragma: no cover ... - @overload # noqa: F811, it's overload, not redefinition + @overload @classmethod - def get_current(cls, no_error: Literal[False]) -> ContextInstance: # pragma: no cover # noqa: F811 + def get_current( # noqa: F811 + cls, no_error: Literal[False] + ) -> ContextInstance: # pragma: no cover ... - @classmethod # noqa: F811, it's overload, not redefinition - def get_current(cls, no_error: bool = True) -> Optional[ContextInstance]: # pragma: no cover # noqa: F811 + @classmethod + def get_current( # noqa: F811 + cls, no_error: bool = True + ) -> Optional[ContextInstance]: # pragma: no cover # on mypy 0.770 I catch that contextvars.ContextVar always contextvars.ContextVar[Any] cls.__context_instance = cast( contextvars.ContextVar[ContextInstance], cls.__context_instance diff --git a/docs/_api_version.md b/docs/_api_version.md index b3d791d7..4f8c6396 100644 --- a/docs/_api_version.md +++ b/docs/_api_version.md @@ -1 +1 @@ -4.6 +4.7 diff --git a/docs/api/methods/add_sticker_to_set.md b/docs/api/methods/add_sticker_to_set.md index b98b85d5..910b072d 100644 --- a/docs/api/methods/add_sticker_to_set.md +++ b/docs/api/methods/add_sticker_to_set.md @@ -2,7 +2,7 @@ ## Description -Use this method to add a new sticker to a set created by the bot. Returns True on success. +Use this method to add a new sticker to a set created by the bot. You must use exactly one of the fields png_sticker or tgs_sticker. Animated stickers can be added to animated sticker sets and only to them. Animated sticker sets can have up to 50 stickers. Static sticker sets can have up to 120 stickers. Returns True on success. ## Arguments @@ -11,8 +11,9 @@ Use this method to add a new sticker to a set created by the bot. Returns True o | - | - | - | | `user_id` | `#!python3 int` | User identifier of sticker set owner | | `name` | `#!python3 str` | Sticker set name | -| `png_sticker` | `#!python3 Union[InputFile, str]` | Png image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. | +| `png_sticker` | `#!python3 Union[InputFile, str]` | PNG image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. | | `emojis` | `#!python3 str` | One or more emoji corresponding to the sticker | +| `tgs_sticker` | `#!python3 Optional[InputFile]` | Optional. TGS animation with the sticker, uploaded using multipart/form-data. See https://core.telegram.org/animated_stickers#technical-requirements for technical requirements | | `mask_position` | `#!python3 Optional[MaskPosition]` | Optional. A JSON-serialized object for position where the mask should be placed on faces | @@ -26,8 +27,7 @@ Description: Returns True on success. ## Usage - -### As bot method bot +### As bot method ```python3 result: bool = await bot.add_sticker_to_set(...) @@ -56,7 +56,6 @@ return AddStickerToSet(...) ``` - ## Related pages: - [Official documentation](https://core.telegram.org/bots/api#addstickertoset) diff --git a/docs/api/methods/answer_callback_query.md b/docs/api/methods/answer_callback_query.md index 14fe48ff..202ecb49 100644 --- a/docs/api/methods/answer_callback_query.md +++ b/docs/api/methods/answer_callback_query.md @@ -28,8 +28,7 @@ Description: On success, True is returned. ## Usage - -### As bot method bot +### As bot method ```python3 result: bool = await bot.answer_callback_query(...) @@ -58,7 +57,6 @@ return AnswerCallbackQuery(...) ``` - ## Related pages: - [Official documentation](https://core.telegram.org/bots/api#answercallbackquery) diff --git a/docs/api/methods/answer_inline_query.md b/docs/api/methods/answer_inline_query.md index 819544b1..88add63d 100644 --- a/docs/api/methods/answer_inline_query.md +++ b/docs/api/methods/answer_inline_query.md @@ -30,8 +30,7 @@ Description: On success, True is returned. ## Usage - -### As bot method bot +### As bot method ```python3 result: bool = await bot.answer_inline_query(...) @@ -60,7 +59,6 @@ return AnswerInlineQuery(...) ``` - ## Related pages: - [Official documentation](https://core.telegram.org/bots/api#answerinlinequery) diff --git a/docs/api/methods/answer_pre_checkout_query.md b/docs/api/methods/answer_pre_checkout_query.md index cbc8cbcd..e836fe96 100644 --- a/docs/api/methods/answer_pre_checkout_query.md +++ b/docs/api/methods/answer_pre_checkout_query.md @@ -24,8 +24,7 @@ Description: On success, True is returned. ## Usage - -### As bot method bot +### As bot method ```python3 result: bool = await bot.answer_pre_checkout_query(...) @@ -54,7 +53,6 @@ return AnswerPreCheckoutQuery(...) ``` - ## Related pages: - [Official documentation](https://core.telegram.org/bots/api#answerprecheckoutquery) diff --git a/docs/api/methods/answer_shipping_query.md b/docs/api/methods/answer_shipping_query.md index ddf25f0f..6ac4948b 100644 --- a/docs/api/methods/answer_shipping_query.md +++ b/docs/api/methods/answer_shipping_query.md @@ -25,8 +25,7 @@ Description: On success, True is returned. ## Usage - -### As bot method bot +### As bot method ```python3 result: bool = await bot.answer_shipping_query(...) @@ -55,7 +54,6 @@ return AnswerShippingQuery(...) ``` - ## Related pages: - [Official documentation](https://core.telegram.org/bots/api#answershippingquery) diff --git a/docs/api/methods/create_new_sticker_set.md b/docs/api/methods/create_new_sticker_set.md index 8e9ada88..f1f36a38 100644 --- a/docs/api/methods/create_new_sticker_set.md +++ b/docs/api/methods/create_new_sticker_set.md @@ -2,7 +2,7 @@ ## Description -Use this method to create new sticker set owned by a user. The bot will be able to edit the created sticker set. Returns True on success. +Use this method to create a new sticker set owned by a user. The bot will be able to edit the sticker set thus created. You must use exactly one of the fields png_sticker or tgs_sticker. Returns True on success. ## Arguments @@ -12,8 +12,9 @@ Use this method to create new sticker set owned by a user. The bot will be able | `user_id` | `#!python3 int` | User identifier of created sticker set owner | | `name` | `#!python3 str` | Short name of sticker set, to be used in t.me/addstickers/ URLs (e.g., animals). Can contain only english letters, digits and underscores. Must begin with a letter, can't contain consecutive underscores and must end in '_by_'. is case insensitive. 1-64 characters. | | `title` | `#!python3 str` | Sticker set title, 1-64 characters | -| `png_sticker` | `#!python3 Union[InputFile, str]` | Png image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. | | `emojis` | `#!python3 str` | One or more emoji corresponding to the sticker | +| `png_sticker` | `#!python3 Optional[Union[InputFile, str]]` | Optional. PNG image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. | +| `tgs_sticker` | `#!python3 Optional[InputFile]` | Optional. TGS animation with the sticker, uploaded using multipart/form-data. See https://core.telegram.org/animated_stickers#technical-requirements for technical requirements | | `contains_masks` | `#!python3 Optional[bool]` | Optional. Pass True, if a set of mask stickers should be created | | `mask_position` | `#!python3 Optional[MaskPosition]` | Optional. A JSON-serialized object for position where the mask should be placed on faces | @@ -28,8 +29,7 @@ Description: Returns True on success. ## Usage - -### As bot method bot +### As bot method ```python3 result: bool = await bot.create_new_sticker_set(...) @@ -58,7 +58,6 @@ return CreateNewStickerSet(...) ``` - ## Related pages: - [Official documentation](https://core.telegram.org/bots/api#createnewstickerset) diff --git a/docs/api/methods/delete_chat_photo.md b/docs/api/methods/delete_chat_photo.md index cfe0b7d4..44d93dcb 100644 --- a/docs/api/methods/delete_chat_photo.md +++ b/docs/api/methods/delete_chat_photo.md @@ -22,8 +22,7 @@ Description: Returns True on success. ## Usage - -### As bot method bot +### As bot method ```python3 result: bool = await bot.delete_chat_photo(...) @@ -52,7 +51,6 @@ return DeleteChatPhoto(...) ``` - ## Related pages: - [Official documentation](https://core.telegram.org/bots/api#deletechatphoto) diff --git a/docs/api/methods/delete_chat_sticker_set.md b/docs/api/methods/delete_chat_sticker_set.md index 083f4bdd..9946efaf 100644 --- a/docs/api/methods/delete_chat_sticker_set.md +++ b/docs/api/methods/delete_chat_sticker_set.md @@ -22,8 +22,7 @@ Description: Use the field can_set_sticker_set optionally returned in getChat re ## Usage - -### As bot method bot +### As bot method ```python3 result: bool = await bot.delete_chat_sticker_set(...) @@ -52,7 +51,6 @@ return DeleteChatStickerSet(...) ``` - ## Related pages: - [Official documentation](https://core.telegram.org/bots/api#deletechatstickerset) diff --git a/docs/api/methods/delete_message.md b/docs/api/methods/delete_message.md index fc50f66e..a6f42e08 100644 --- a/docs/api/methods/delete_message.md +++ b/docs/api/methods/delete_message.md @@ -6,6 +6,8 @@ Use this method to delete a message, including service messages, with the follow - A message can only be deleted if it was sent less than 48 hours ago. +- A dice message in a private chat can only be deleted if it was sent more than 24 hours ago. + - Bots can delete outgoing messages in private chats, groups, and supergroups. - Bots can delete incoming messages in private chats. @@ -37,8 +39,7 @@ Description: Returns True on success. ## Usage - -### As bot method bot +### As bot method ```python3 result: bool = await bot.delete_message(...) @@ -67,7 +68,6 @@ return DeleteMessage(...) ``` - ## Related pages: - [Official documentation](https://core.telegram.org/bots/api#deletemessage) diff --git a/docs/api/methods/delete_sticker_from_set.md b/docs/api/methods/delete_sticker_from_set.md index 4b6dcfd3..7414d9d6 100644 --- a/docs/api/methods/delete_sticker_from_set.md +++ b/docs/api/methods/delete_sticker_from_set.md @@ -22,8 +22,7 @@ Description: Returns True on success. ## Usage - -### As bot method bot +### As bot method ```python3 result: bool = await bot.delete_sticker_from_set(...) @@ -52,7 +51,6 @@ return DeleteStickerFromSet(...) ``` - ## Related pages: - [Official documentation](https://core.telegram.org/bots/api#deletestickerfromset) diff --git a/docs/api/methods/delete_webhook.md b/docs/api/methods/delete_webhook.md index 888b227e..93b51ea4 100644 --- a/docs/api/methods/delete_webhook.md +++ b/docs/api/methods/delete_webhook.md @@ -16,8 +16,7 @@ Description: Returns True on success. ## Usage - -### As bot method bot +### As bot method ```python3 result: bool = await bot.delete_webhook(...) @@ -46,7 +45,6 @@ return DeleteWebhook(...) ``` - ## Related pages: - [Official documentation](https://core.telegram.org/bots/api#deletewebhook) diff --git a/docs/api/methods/edit_message_caption.md b/docs/api/methods/edit_message_caption.md index cdaecdae..7f2c6556 100644 --- a/docs/api/methods/edit_message_caption.md +++ b/docs/api/methods/edit_message_caption.md @@ -12,7 +12,7 @@ Use this method to edit captions of messages. On success, if edited message is s | `chat_id` | `#!python3 Optional[Union[int, str]]` | Optional. Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername) | | `message_id` | `#!python3 Optional[int]` | Optional. Required if inline_message_id is not specified. Identifier of the message to edit | | `inline_message_id` | `#!python3 Optional[str]` | Optional. Required if chat_id and message_id are not specified. Identifier of the inline message | -| `caption` | `#!python3 Optional[str]` | Optional. New caption of the message | +| `caption` | `#!python3 Optional[str]` | Optional. New caption of the message, 0-1024 characters after entities parsing | | `parse_mode` | `#!python3 Optional[str]` | Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. | | `reply_markup` | `#!python3 Optional[InlineKeyboardMarkup]` | Optional. A JSON-serialized object for an inline keyboard. | @@ -27,8 +27,7 @@ Description: On success, if edited message is sent by the bot, the edited Messag ## Usage - -### As bot method bot +### As bot method ```python3 result: Union[Message, bool] = await bot.edit_message_caption(...) @@ -57,7 +56,6 @@ return EditMessageCaption(...) ``` - ## Related pages: - [Official documentation](https://core.telegram.org/bots/api#editmessagecaption) diff --git a/docs/api/methods/edit_message_live_location.md b/docs/api/methods/edit_message_live_location.md index e3a9ff39..93be46c4 100644 --- a/docs/api/methods/edit_message_live_location.md +++ b/docs/api/methods/edit_message_live_location.md @@ -27,8 +27,7 @@ Description: On success, if the edited message was sent by the bot, the edited M ## Usage - -### As bot method bot +### As bot method ```python3 result: Union[Message, bool] = await bot.edit_message_live_location(...) @@ -57,7 +56,6 @@ return EditMessageLiveLocation(...) ``` - ## Related pages: - [Official documentation](https://core.telegram.org/bots/api#editmessagelivelocation) diff --git a/docs/api/methods/edit_message_media.md b/docs/api/methods/edit_message_media.md index 5d25baa5..63927ea3 100644 --- a/docs/api/methods/edit_message_media.md +++ b/docs/api/methods/edit_message_media.md @@ -26,8 +26,7 @@ Description: On success, if the edited message was sent by the bot, the edited M ## Usage - -### As bot method bot +### As bot method ```python3 result: Union[Message, bool] = await bot.edit_message_media(...) @@ -56,7 +55,6 @@ return EditMessageMedia(...) ``` - ## Related pages: - [Official documentation](https://core.telegram.org/bots/api#editmessagemedia) diff --git a/docs/api/methods/edit_message_reply_markup.md b/docs/api/methods/edit_message_reply_markup.md index efbda5aa..d5a4693a 100644 --- a/docs/api/methods/edit_message_reply_markup.md +++ b/docs/api/methods/edit_message_reply_markup.md @@ -25,8 +25,7 @@ Description: On success, if edited message is sent by the bot, the edited Messag ## Usage - -### As bot method bot +### As bot method ```python3 result: Union[Message, bool] = await bot.edit_message_reply_markup(...) @@ -55,7 +54,6 @@ return EditMessageReplyMarkup(...) ``` - ## Related pages: - [Official documentation](https://core.telegram.org/bots/api#editmessagereplymarkup) diff --git a/docs/api/methods/edit_message_text.md b/docs/api/methods/edit_message_text.md index 6fa574c9..8931a835 100644 --- a/docs/api/methods/edit_message_text.md +++ b/docs/api/methods/edit_message_text.md @@ -9,7 +9,7 @@ Use this method to edit text and game messages. On success, if edited message is | Name | Type | Description | | - | - | - | -| `text` | `#!python3 str` | New text of the message | +| `text` | `#!python3 str` | New text of the message, 1-4096 characters after entities parsing | | `chat_id` | `#!python3 Optional[Union[int, str]]` | Optional. Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername) | | `message_id` | `#!python3 Optional[int]` | Optional. Required if inline_message_id is not specified. Identifier of the message to edit | | `inline_message_id` | `#!python3 Optional[str]` | Optional. Required if chat_id and message_id are not specified. Identifier of the inline message | @@ -28,8 +28,7 @@ Description: On success, if edited message is sent by the bot, the edited Messag ## Usage - -### As bot method bot +### As bot method ```python3 result: Union[Message, bool] = await bot.edit_message_text(...) @@ -58,7 +57,6 @@ return EditMessageText(...) ``` - ## Related pages: - [Official documentation](https://core.telegram.org/bots/api#editmessagetext) diff --git a/docs/api/methods/export_chat_invite_link.md b/docs/api/methods/export_chat_invite_link.md index 8fc0d888..cfa43df6 100644 --- a/docs/api/methods/export_chat_invite_link.md +++ b/docs/api/methods/export_chat_invite_link.md @@ -24,8 +24,7 @@ Description: Returns the new invite link as String on success. ## Usage - -### As bot method bot +### As bot method ```python3 result: str = await bot.export_chat_invite_link(...) @@ -54,7 +53,6 @@ return ExportChatInviteLink(...) ``` - ## Related pages: - [Official documentation](https://core.telegram.org/bots/api#exportchatinvitelink) diff --git a/docs/api/methods/forward_message.md b/docs/api/methods/forward_message.md index 755d4b43..6ac41bee 100644 --- a/docs/api/methods/forward_message.md +++ b/docs/api/methods/forward_message.md @@ -25,8 +25,7 @@ Description: On success, the sent Message is returned. ## Usage - -### As bot method bot +### As bot method ```python3 result: Message = await bot.forward_message(...) @@ -55,7 +54,6 @@ return ForwardMessage(...) ``` - ## Related pages: - [Official documentation](https://core.telegram.org/bots/api#forwardmessage) diff --git a/docs/api/methods/get_chat.md b/docs/api/methods/get_chat.md index c216afa2..f5388c0d 100644 --- a/docs/api/methods/get_chat.md +++ b/docs/api/methods/get_chat.md @@ -22,8 +22,7 @@ Description: Returns a Chat object on success. ## Usage - -### As bot method bot +### As bot method ```python3 result: Chat = await bot.get_chat(...) diff --git a/docs/api/methods/get_chat_administrators.md b/docs/api/methods/get_chat_administrators.md index d7047f7e..646d0e09 100644 --- a/docs/api/methods/get_chat_administrators.md +++ b/docs/api/methods/get_chat_administrators.md @@ -22,8 +22,7 @@ Description: On success, returns an Array of ChatMember objects that contains in ## Usage - -### As bot method bot +### As bot method ```python3 result: List[ChatMember] = await bot.get_chat_administrators(...) diff --git a/docs/api/methods/get_chat_member.md b/docs/api/methods/get_chat_member.md index 2198e1fe..91d96299 100644 --- a/docs/api/methods/get_chat_member.md +++ b/docs/api/methods/get_chat_member.md @@ -23,8 +23,7 @@ Description: Returns a ChatMember object on success. ## Usage - -### As bot method bot +### As bot method ```python3 result: ChatMember = await bot.get_chat_member(...) diff --git a/docs/api/methods/get_chat_members_count.md b/docs/api/methods/get_chat_members_count.md index e1cb3312..e97f7142 100644 --- a/docs/api/methods/get_chat_members_count.md +++ b/docs/api/methods/get_chat_members_count.md @@ -22,8 +22,7 @@ Description: Returns Int on success. ## Usage - -### As bot method bot +### As bot method ```python3 result: int = await bot.get_chat_members_count(...) diff --git a/docs/api/methods/get_file.md b/docs/api/methods/get_file.md index c449135b..145211d8 100644 --- a/docs/api/methods/get_file.md +++ b/docs/api/methods/get_file.md @@ -24,8 +24,7 @@ Description: On success, a File object is returned. ## Usage - -### As bot method bot +### As bot method ```python3 result: File = await bot.get_file(...) diff --git a/docs/api/methods/get_game_high_scores.md b/docs/api/methods/get_game_high_scores.md index b97514c6..0b0390d1 100644 --- a/docs/api/methods/get_game_high_scores.md +++ b/docs/api/methods/get_game_high_scores.md @@ -27,8 +27,7 @@ Description: Will return the score of the specified user and several of his neig ## Usage - -### As bot method bot +### As bot method ```python3 result: List[GameHighScore] = await bot.get_game_high_scores(...) diff --git a/docs/api/methods/get_me.md b/docs/api/methods/get_me.md index b2994f25..12fe6f8b 100644 --- a/docs/api/methods/get_me.md +++ b/docs/api/methods/get_me.md @@ -16,8 +16,7 @@ Description: Returns basic information about the bot in form of a User object. ## Usage - -### As bot method bot +### As bot method ```python3 result: User = await bot.get_me(...) diff --git a/docs/api/methods/get_my_commands.md b/docs/api/methods/get_my_commands.md new file mode 100644 index 00000000..0508e8aa --- /dev/null +++ b/docs/api/methods/get_my_commands.md @@ -0,0 +1,48 @@ +# getMyCommands + +## Description + +Use this method to get the current list of the bot's commands. Requires no parameters. Returns Array of BotCommand on success. + + + + +## Response + +Type: `#!python3 List[BotCommand]` + +Description: Returns Array of BotCommand on success. + + +## Usage + +### As bot method + +```python3 +result: List[BotCommand] = await bot.get_my_commands(...) +``` + +### Method as object + +Imports: + +- `from aiogram.methods import GetMyCommands` +- `from aiogram.api.methods import GetMyCommands` +- `from aiogram.api.methods.get_my_commands import GetMyCommands` + +#### In handlers with current bot +```python3 +result: List[BotCommand] = await GetMyCommands(...) +``` + +#### With specific bot +```python3 +result: List[BotCommand] = await bot(GetMyCommands(...)) +``` + + + +## Related pages: + +- [Official documentation](https://core.telegram.org/bots/api#getmycommands) +- [aiogram.types.BotCommand](../types/bot_command.md) diff --git a/docs/api/methods/get_sticker_set.md b/docs/api/methods/get_sticker_set.md index 983f1331..0d5efd9c 100644 --- a/docs/api/methods/get_sticker_set.md +++ b/docs/api/methods/get_sticker_set.md @@ -22,8 +22,7 @@ Description: On success, a StickerSet object is returned. ## Usage - -### As bot method bot +### As bot method ```python3 result: StickerSet = await bot.get_sticker_set(...) diff --git a/docs/api/methods/get_updates.md b/docs/api/methods/get_updates.md index 22576520..e7850ed4 100644 --- a/docs/api/methods/get_updates.md +++ b/docs/api/methods/get_updates.md @@ -31,8 +31,7 @@ Description: An Array of Update objects is returned. ## Usage - -### As bot method bot +### As bot method ```python3 result: List[Update] = await bot.get_updates(...) diff --git a/docs/api/methods/get_user_profile_photos.md b/docs/api/methods/get_user_profile_photos.md index 0b69b59d..a02a2a99 100644 --- a/docs/api/methods/get_user_profile_photos.md +++ b/docs/api/methods/get_user_profile_photos.md @@ -24,8 +24,7 @@ Description: Returns a UserProfilePhotos object. ## Usage - -### As bot method bot +### As bot method ```python3 result: UserProfilePhotos = await bot.get_user_profile_photos(...) diff --git a/docs/api/methods/get_webhook_info.md b/docs/api/methods/get_webhook_info.md index 2428a6af..2a35184e 100644 --- a/docs/api/methods/get_webhook_info.md +++ b/docs/api/methods/get_webhook_info.md @@ -16,8 +16,7 @@ Description: On success, returns a WebhookInfo object. If the bot is using getUp ## Usage - -### As bot method bot +### As bot method ```python3 result: WebhookInfo = await bot.get_webhook_info(...) diff --git a/docs/api/methods/index.md b/docs/api/methods/index.md index 58bfd230..7b2467fc 100644 --- a/docs/api/methods/index.md +++ b/docs/api/methods/index.md @@ -2,7 +2,6 @@ Here is list of all available API methods: - - Getting updates - [getUpdates](get_updates.md) - [setWebhook](set_webhook.md) @@ -26,6 +25,7 @@ Here is list of all available API methods: - [sendVenue](send_venue.md) - [sendContact](send_contact.md) - [sendPoll](send_poll.md) + - [sendDice](send_dice.md) - [sendChatAction](send_chat_action.md) - [getUserProfilePhotos](get_user_profile_photos.md) - [getFile](get_file.md) @@ -50,6 +50,8 @@ Here is list of all available API methods: - [setChatStickerSet](set_chat_sticker_set.md) - [deleteChatStickerSet](delete_chat_sticker_set.md) - [answerCallbackQuery](answer_callback_query.md) + - [setMyCommands](set_my_commands.md) + - [getMyCommands](get_my_commands.md) - Updating messages - [editMessageText](edit_message_text.md) - [editMessageCaption](edit_message_caption.md) @@ -65,6 +67,7 @@ Here is list of all available API methods: - [addStickerToSet](add_sticker_to_set.md) - [setStickerPositionInSet](set_sticker_position_in_set.md) - [deleteStickerFromSet](delete_sticker_from_set.md) + - [setStickerSetThumb](set_sticker_set_thumb.md) - Inline mode - [answerInlineQuery](answer_inline_query.md) - Payments diff --git a/docs/api/methods/kick_chat_member.md b/docs/api/methods/kick_chat_member.md index 0a475e03..d58e5664 100644 --- a/docs/api/methods/kick_chat_member.md +++ b/docs/api/methods/kick_chat_member.md @@ -24,8 +24,7 @@ Description: In the case of supergroups and channels, the user will not be able ## Usage - -### As bot method bot +### As bot method ```python3 result: bool = await bot.kick_chat_member(...) @@ -54,7 +53,6 @@ return KickChatMember(...) ``` - ## Related pages: - [Official documentation](https://core.telegram.org/bots/api#kickchatmember) diff --git a/docs/api/methods/leave_chat.md b/docs/api/methods/leave_chat.md index 284c72f1..102b673f 100644 --- a/docs/api/methods/leave_chat.md +++ b/docs/api/methods/leave_chat.md @@ -22,8 +22,7 @@ Description: Returns True on success. ## Usage - -### As bot method bot +### As bot method ```python3 result: bool = await bot.leave_chat(...) @@ -52,7 +51,6 @@ return LeaveChat(...) ``` - ## Related pages: - [Official documentation](https://core.telegram.org/bots/api#leavechat) diff --git a/docs/api/methods/pin_chat_message.md b/docs/api/methods/pin_chat_message.md index 1d9fd53e..27b97337 100644 --- a/docs/api/methods/pin_chat_message.md +++ b/docs/api/methods/pin_chat_message.md @@ -24,8 +24,7 @@ Description: Returns True on success. ## Usage - -### As bot method bot +### As bot method ```python3 result: bool = await bot.pin_chat_message(...) @@ -54,7 +53,6 @@ return PinChatMessage(...) ``` - ## Related pages: - [Official documentation](https://core.telegram.org/bots/api#pinchatmessage) diff --git a/docs/api/methods/promote_chat_member.md b/docs/api/methods/promote_chat_member.md index e2fd6202..eae50d26 100644 --- a/docs/api/methods/promote_chat_member.md +++ b/docs/api/methods/promote_chat_member.md @@ -31,8 +31,7 @@ Description: Returns True on success. ## Usage - -### As bot method bot +### As bot method ```python3 result: bool = await bot.promote_chat_member(...) @@ -61,7 +60,6 @@ return PromoteChatMember(...) ``` - ## Related pages: - [Official documentation](https://core.telegram.org/bots/api#promotechatmember) diff --git a/docs/api/methods/restrict_chat_member.md b/docs/api/methods/restrict_chat_member.md index fa438eb9..50ed84fa 100644 --- a/docs/api/methods/restrict_chat_member.md +++ b/docs/api/methods/restrict_chat_member.md @@ -25,8 +25,7 @@ Description: Returns True on success. ## Usage - -### As bot method bot +### As bot method ```python3 result: bool = await bot.restrict_chat_member(...) @@ -55,7 +54,6 @@ return RestrictChatMember(...) ``` - ## Related pages: - [Official documentation](https://core.telegram.org/bots/api#restrictchatmember) diff --git a/docs/api/methods/send_animation.md b/docs/api/methods/send_animation.md index 3ea76968..b383ca61 100644 --- a/docs/api/methods/send_animation.md +++ b/docs/api/methods/send_animation.md @@ -15,7 +15,7 @@ Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without s | `width` | `#!python3 Optional[int]` | Optional. Animation width | | `height` | `#!python3 Optional[int]` | Optional. Animation height | | `thumb` | `#!python3 Optional[Union[InputFile, str]]` | Optional. Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass 'attach://' if the thumbnail was uploaded using multipart/form-data under . | -| `caption` | `#!python3 Optional[str]` | Optional. Animation caption (may also be used when resending animation by file_id), 0-1024 characters | +| `caption` | `#!python3 Optional[str]` | Optional. Animation caption (may also be used when resending animation by file_id), 0-1024 characters after entities parsing | | `parse_mode` | `#!python3 Optional[str]` | Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. | | `disable_notification` | `#!python3 Optional[bool]` | Optional. Sends the message silently. Users will receive a notification with no sound. | | `reply_to_message_id` | `#!python3 Optional[int]` | Optional. If the message is a reply, ID of the original message | @@ -32,8 +32,7 @@ Description: On success, the sent Message is returned. ## Usage - -### As bot method bot +### As bot method ```python3 result: Message = await bot.send_animation(...) @@ -62,7 +61,6 @@ return SendAnimation(...) ``` - ## Related pages: - [Official documentation](https://core.telegram.org/bots/api#sendanimation) diff --git a/docs/api/methods/send_audio.md b/docs/api/methods/send_audio.md index 1aadc59d..dede2bc1 100644 --- a/docs/api/methods/send_audio.md +++ b/docs/api/methods/send_audio.md @@ -13,7 +13,7 @@ For sending voice messages, use the sendVoice method instead. | - | - | - | | `chat_id` | `#!python3 Union[int, str]` | Unique identifier for the target chat or username of the target channel (in the format @channelusername) | | `audio` | `#!python3 Union[InputFile, str]` | Audio file to send. Pass a file_id as String to send an audio file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get an audio file from the Internet, or upload a new one using multipart/form-data. | -| `caption` | `#!python3 Optional[str]` | Optional. Audio caption, 0-1024 characters | +| `caption` | `#!python3 Optional[str]` | Optional. Audio caption, 0-1024 characters after entities parsing | | `parse_mode` | `#!python3 Optional[str]` | Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. | | `duration` | `#!python3 Optional[int]` | Optional. Duration of the audio in seconds | | `performer` | `#!python3 Optional[str]` | Optional. Performer | @@ -34,8 +34,7 @@ Description: On success, the sent Message is returned. ## Usage - -### As bot method bot +### As bot method ```python3 result: Message = await bot.send_audio(...) @@ -64,7 +63,6 @@ return SendAudio(...) ``` - ## Related pages: - [Official documentation](https://core.telegram.org/bots/api#sendaudio) diff --git a/docs/api/methods/send_chat_action.md b/docs/api/methods/send_chat_action.md index 59e23a75..b85847f6 100644 --- a/docs/api/methods/send_chat_action.md +++ b/docs/api/methods/send_chat_action.md @@ -27,8 +27,7 @@ Description: Returns True on success. ## Usage - -### As bot method bot +### As bot method ```python3 result: bool = await bot.send_chat_action(...) @@ -57,7 +56,6 @@ return SendChatAction(...) ``` - ## Related pages: - [Official documentation](https://core.telegram.org/bots/api#sendchataction) diff --git a/docs/api/methods/send_contact.md b/docs/api/methods/send_contact.md index b9de4bcf..fbe0e670 100644 --- a/docs/api/methods/send_contact.md +++ b/docs/api/methods/send_contact.md @@ -29,8 +29,7 @@ Description: On success, the sent Message is returned. ## Usage - -### As bot method bot +### As bot method ```python3 result: Message = await bot.send_contact(...) @@ -59,7 +58,6 @@ return SendContact(...) ``` - ## Related pages: - [Official documentation](https://core.telegram.org/bots/api#sendcontact) diff --git a/docs/api/methods/send_dice.md b/docs/api/methods/send_dice.md new file mode 100644 index 00000000..86180563 --- /dev/null +++ b/docs/api/methods/send_dice.md @@ -0,0 +1,64 @@ +# sendDice + +## Description + +Use this method to send a dice, which will have a random value from 1 to 6. On success, the sent Message is returned. (Yes, we're aware of the 'proper' singular of die. But it's awkward, and we decided to help it change. One dice at a time!) + + +## Arguments + +| Name | Type | Description | +| - | - | - | +| `chat_id` | `#!python3 Union[int, str]` | Unique identifier for the target chat or username of the target channel (in the format @channelusername) | +| `disable_notification` | `#!python3 Optional[bool]` | Optional. Sends the message silently. Users will receive a notification with no sound. | +| `reply_to_message_id` | `#!python3 Optional[int]` | Optional. If the message is a reply, ID of the original message | +| `reply_markup` | `#!python3 Optional[Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]]` | Optional. Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user. | + + + +## Response + +Type: `#!python3 Message` + +Description: On success, the sent Message is returned. + + +## Usage + +### As bot method + +```python3 +result: Message = await bot.send_dice(...) +``` + +### Method as object + +Imports: + +- `from aiogram.methods import SendDice` +- `from aiogram.api.methods import SendDice` +- `from aiogram.api.methods.send_dice import SendDice` + +#### In handlers with current bot +```python3 +result: Message = await SendDice(...) +``` + +#### With specific bot +```python3 +result: Message = await bot(SendDice(...)) +``` +#### As reply into Webhook in handler +```python3 +return SendDice(...) +``` + + +## Related pages: + +- [Official documentation](https://core.telegram.org/bots/api#senddice) +- [aiogram.types.ForceReply](../types/force_reply.md) +- [aiogram.types.InlineKeyboardMarkup](../types/inline_keyboard_markup.md) +- [aiogram.types.Message](../types/message.md) +- [aiogram.types.ReplyKeyboardMarkup](../types/reply_keyboard_markup.md) +- [aiogram.types.ReplyKeyboardRemove](../types/reply_keyboard_remove.md) diff --git a/docs/api/methods/send_document.md b/docs/api/methods/send_document.md index 9b0134b8..99a869c4 100644 --- a/docs/api/methods/send_document.md +++ b/docs/api/methods/send_document.md @@ -12,7 +12,7 @@ Use this method to send general files. On success, the sent Message is returned. | `chat_id` | `#!python3 Union[int, str]` | Unique identifier for the target chat or username of the target channel (in the format @channelusername) | | `document` | `#!python3 Union[InputFile, str]` | File to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. | | `thumb` | `#!python3 Optional[Union[InputFile, str]]` | Optional. Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass 'attach://' if the thumbnail was uploaded using multipart/form-data under . | -| `caption` | `#!python3 Optional[str]` | Optional. Document caption (may also be used when resending documents by file_id), 0-1024 characters | +| `caption` | `#!python3 Optional[str]` | Optional. Document caption (may also be used when resending documents by file_id), 0-1024 characters after entities parsing | | `parse_mode` | `#!python3 Optional[str]` | Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. | | `disable_notification` | `#!python3 Optional[bool]` | Optional. Sends the message silently. Users will receive a notification with no sound. | | `reply_to_message_id` | `#!python3 Optional[int]` | Optional. If the message is a reply, ID of the original message | @@ -29,8 +29,7 @@ Description: On success, the sent Message is returned. ## Usage - -### As bot method bot +### As bot method ```python3 result: Message = await bot.send_document(...) @@ -59,7 +58,6 @@ return SendDocument(...) ``` - ## Related pages: - [Official documentation](https://core.telegram.org/bots/api#senddocument) diff --git a/docs/api/methods/send_game.md b/docs/api/methods/send_game.md index 47b66405..15daff9b 100644 --- a/docs/api/methods/send_game.md +++ b/docs/api/methods/send_game.md @@ -26,8 +26,7 @@ Description: On success, the sent Message is returned. ## Usage - -### As bot method bot +### As bot method ```python3 result: Message = await bot.send_game(...) @@ -56,7 +55,6 @@ return SendGame(...) ``` - ## Related pages: - [Official documentation](https://core.telegram.org/bots/api#sendgame) diff --git a/docs/api/methods/send_invoice.md b/docs/api/methods/send_invoice.md index 9eeab6ab..9620b2ca 100644 --- a/docs/api/methods/send_invoice.md +++ b/docs/api/methods/send_invoice.md @@ -44,8 +44,7 @@ Description: On success, the sent Message is returned. ## Usage - -### As bot method bot +### As bot method ```python3 result: Message = await bot.send_invoice(...) @@ -74,7 +73,6 @@ return SendInvoice(...) ``` - ## Related pages: - [Official documentation](https://core.telegram.org/bots/api#sendinvoice) diff --git a/docs/api/methods/send_location.md b/docs/api/methods/send_location.md index 26b6d72b..98cbe531 100644 --- a/docs/api/methods/send_location.md +++ b/docs/api/methods/send_location.md @@ -28,8 +28,7 @@ Description: On success, the sent Message is returned. ## Usage - -### As bot method bot +### As bot method ```python3 result: Message = await bot.send_location(...) @@ -58,7 +57,6 @@ return SendLocation(...) ``` - ## Related pages: - [Official documentation](https://core.telegram.org/bots/api#sendlocation) diff --git a/docs/api/methods/send_media_group.md b/docs/api/methods/send_media_group.md index 522a849b..b15ccacc 100644 --- a/docs/api/methods/send_media_group.md +++ b/docs/api/methods/send_media_group.md @@ -25,8 +25,7 @@ Description: On success, an array of the sent Messages is returned. ## Usage - -### As bot method bot +### As bot method ```python3 result: List[Message] = await bot.send_media_group(...) @@ -55,7 +54,6 @@ return SendMediaGroup(...) ``` - ## Related pages: - [Official documentation](https://core.telegram.org/bots/api#sendmediagroup) diff --git a/docs/api/methods/send_message.md b/docs/api/methods/send_message.md index bb1137df..67b740ba 100644 --- a/docs/api/methods/send_message.md +++ b/docs/api/methods/send_message.md @@ -10,7 +10,7 @@ Use this method to send text messages. On success, the sent Message is returned. | Name | Type | Description | | - | - | - | | `chat_id` | `#!python3 Union[int, str]` | Unique identifier for the target chat or username of the target channel (in the format @channelusername) | -| `text` | `#!python3 str` | Text of the message to be sent | +| `text` | `#!python3 str` | Text of the message to be sent, 1-4096 characters after entities parsing | | `parse_mode` | `#!python3 Optional[str]` | Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message. | | `disable_web_page_preview` | `#!python3 Optional[bool]` | Optional. Disables link previews for links in this message | | `disable_notification` | `#!python3 Optional[bool]` | Optional. Sends the message silently. Users will receive a notification with no sound. | @@ -28,8 +28,7 @@ Description: On success, the sent Message is returned. ## Usage - -### As bot method bot +### As bot method ```python3 result: Message = await bot.send_message(...) @@ -58,7 +57,6 @@ return SendMessage(...) ``` - ## Related pages: - [Official documentation](https://core.telegram.org/bots/api#sendmessage) diff --git a/docs/api/methods/send_photo.md b/docs/api/methods/send_photo.md index e52f8bf8..d2667a85 100644 --- a/docs/api/methods/send_photo.md +++ b/docs/api/methods/send_photo.md @@ -11,7 +11,7 @@ Use this method to send photos. On success, the sent Message is returned. | - | - | - | | `chat_id` | `#!python3 Union[int, str]` | Unique identifier for the target chat or username of the target channel (in the format @channelusername) | | `photo` | `#!python3 Union[InputFile, str]` | Photo to send. Pass a file_id as String to send a photo that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a photo from the Internet, or upload a new photo using multipart/form-data. | -| `caption` | `#!python3 Optional[str]` | Optional. Photo caption (may also be used when resending photos by file_id), 0-1024 characters | +| `caption` | `#!python3 Optional[str]` | Optional. Photo caption (may also be used when resending photos by file_id), 0-1024 characters after entities parsing | | `parse_mode` | `#!python3 Optional[str]` | Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. | | `disable_notification` | `#!python3 Optional[bool]` | Optional. Sends the message silently. Users will receive a notification with no sound. | | `reply_to_message_id` | `#!python3 Optional[int]` | Optional. If the message is a reply, ID of the original message | @@ -28,8 +28,7 @@ Description: On success, the sent Message is returned. ## Usage - -### As bot method bot +### As bot method ```python3 result: Message = await bot.send_photo(...) @@ -58,7 +57,6 @@ return SendPhoto(...) ``` - ## Related pages: - [Official documentation](https://core.telegram.org/bots/api#sendphoto) diff --git a/docs/api/methods/send_poll.md b/docs/api/methods/send_poll.md index af14ded1..175dc2eb 100644 --- a/docs/api/methods/send_poll.md +++ b/docs/api/methods/send_poll.md @@ -32,8 +32,7 @@ Description: On success, the sent Message is returned. ## Usage - -### As bot method bot +### As bot method ```python3 result: Message = await bot.send_poll(...) @@ -62,7 +61,6 @@ return SendPoll(...) ``` - ## Related pages: - [Official documentation](https://core.telegram.org/bots/api#sendpoll) diff --git a/docs/api/methods/send_sticker.md b/docs/api/methods/send_sticker.md index 2195256d..a48fd62f 100644 --- a/docs/api/methods/send_sticker.md +++ b/docs/api/methods/send_sticker.md @@ -10,7 +10,7 @@ Use this method to send static .WEBP or animated .TGS stickers. On success, the | Name | Type | Description | | - | - | - | | `chat_id` | `#!python3 Union[int, str]` | Unique identifier for the target chat or username of the target channel (in the format @channelusername) | -| `sticker` | `#!python3 Union[InputFile, str]` | Sticker to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a .webp file from the Internet, or upload a new one using multipart/form-data. | +| `sticker` | `#!python3 Union[InputFile, str]` | Sticker to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a .WEBP file from the Internet, or upload a new one using multipart/form-data. | | `disable_notification` | `#!python3 Optional[bool]` | Optional. Sends the message silently. Users will receive a notification with no sound. | | `reply_to_message_id` | `#!python3 Optional[int]` | Optional. If the message is a reply, ID of the original message | | `reply_markup` | `#!python3 Optional[Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]]` | Optional. Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user. | @@ -26,8 +26,7 @@ Description: On success, the sent Message is returned. ## Usage - -### As bot method bot +### As bot method ```python3 result: Message = await bot.send_sticker(...) @@ -56,7 +55,6 @@ return SendSticker(...) ``` - ## Related pages: - [Official documentation](https://core.telegram.org/bots/api#sendsticker) diff --git a/docs/api/methods/send_venue.md b/docs/api/methods/send_venue.md index 95509b55..8dcf3c69 100644 --- a/docs/api/methods/send_venue.md +++ b/docs/api/methods/send_venue.md @@ -31,8 +31,7 @@ Description: On success, the sent Message is returned. ## Usage - -### As bot method bot +### As bot method ```python3 result: Message = await bot.send_venue(...) @@ -61,7 +60,6 @@ return SendVenue(...) ``` - ## Related pages: - [Official documentation](https://core.telegram.org/bots/api#sendvenue) diff --git a/docs/api/methods/send_video.md b/docs/api/methods/send_video.md index 1cd459f8..87077d72 100644 --- a/docs/api/methods/send_video.md +++ b/docs/api/methods/send_video.md @@ -15,7 +15,7 @@ Use this method to send video files, Telegram clients support mp4 videos (other | `width` | `#!python3 Optional[int]` | Optional. Video width | | `height` | `#!python3 Optional[int]` | Optional. Video height | | `thumb` | `#!python3 Optional[Union[InputFile, str]]` | Optional. Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass 'attach://' if the thumbnail was uploaded using multipart/form-data under . | -| `caption` | `#!python3 Optional[str]` | Optional. Video caption (may also be used when resending videos by file_id), 0-1024 characters | +| `caption` | `#!python3 Optional[str]` | Optional. Video caption (may also be used when resending videos by file_id), 0-1024 characters after entities parsing | | `parse_mode` | `#!python3 Optional[str]` | Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. | | `supports_streaming` | `#!python3 Optional[bool]` | Optional. Pass True, if the uploaded video is suitable for streaming | | `disable_notification` | `#!python3 Optional[bool]` | Optional. Sends the message silently. Users will receive a notification with no sound. | @@ -33,8 +33,7 @@ Description: On success, the sent Message is returned. ## Usage - -### As bot method bot +### As bot method ```python3 result: Message = await bot.send_video(...) @@ -63,7 +62,6 @@ return SendVideo(...) ``` - ## Related pages: - [Official documentation](https://core.telegram.org/bots/api#sendvideo) diff --git a/docs/api/methods/send_video_note.md b/docs/api/methods/send_video_note.md index d2e60ff9..6aac0df3 100644 --- a/docs/api/methods/send_video_note.md +++ b/docs/api/methods/send_video_note.md @@ -29,8 +29,7 @@ Description: On success, the sent Message is returned. ## Usage - -### As bot method bot +### As bot method ```python3 result: Message = await bot.send_video_note(...) @@ -59,7 +58,6 @@ return SendVideoNote(...) ``` - ## Related pages: - [Official documentation](https://core.telegram.org/bots/api#sendvideonote) diff --git a/docs/api/methods/send_voice.md b/docs/api/methods/send_voice.md index f71790fd..becd34f7 100644 --- a/docs/api/methods/send_voice.md +++ b/docs/api/methods/send_voice.md @@ -2,7 +2,7 @@ ## Description -Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message. For this to work, your audio must be in an .ogg file encoded with OPUS (other formats may be sent as Audio or Document). On success, the sent Message is returned. Bots can currently send voice messages of up to 50 MB in size, this limit may be changed in the future. +Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message. For this to work, your audio must be in an .OGG file encoded with OPUS (other formats may be sent as Audio or Document). On success, the sent Message is returned. Bots can currently send voice messages of up to 50 MB in size, this limit may be changed in the future. ## Arguments @@ -11,7 +11,7 @@ Use this method to send audio files, if you want Telegram clients to display the | - | - | - | | `chat_id` | `#!python3 Union[int, str]` | Unique identifier for the target chat or username of the target channel (in the format @channelusername) | | `voice` | `#!python3 Union[InputFile, str]` | Audio file to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. | -| `caption` | `#!python3 Optional[str]` | Optional. Voice message caption, 0-1024 characters | +| `caption` | `#!python3 Optional[str]` | Optional. Voice message caption, 0-1024 characters after entities parsing | | `parse_mode` | `#!python3 Optional[str]` | Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. | | `duration` | `#!python3 Optional[int]` | Optional. Duration of the voice message in seconds | | `disable_notification` | `#!python3 Optional[bool]` | Optional. Sends the message silently. Users will receive a notification with no sound. | @@ -29,8 +29,7 @@ Description: On success, the sent Message is returned. ## Usage - -### As bot method bot +### As bot method ```python3 result: Message = await bot.send_voice(...) @@ -59,7 +58,6 @@ return SendVoice(...) ``` - ## Related pages: - [Official documentation](https://core.telegram.org/bots/api#sendvoice) diff --git a/docs/api/methods/set_chat_administrator_custom_title.md b/docs/api/methods/set_chat_administrator_custom_title.md index dd301d2f..f58ae5bf 100644 --- a/docs/api/methods/set_chat_administrator_custom_title.md +++ b/docs/api/methods/set_chat_administrator_custom_title.md @@ -24,8 +24,7 @@ Description: Returns True on success. ## Usage - -### As bot method bot +### As bot method ```python3 result: bool = await bot.set_chat_administrator_custom_title(...) @@ -54,7 +53,6 @@ return SetChatAdministratorCustomTitle(...) ``` - ## Related pages: - [Official documentation](https://core.telegram.org/bots/api#setchatadministratorcustomtitle) diff --git a/docs/api/methods/set_chat_description.md b/docs/api/methods/set_chat_description.md index ce555f3f..9750f139 100644 --- a/docs/api/methods/set_chat_description.md +++ b/docs/api/methods/set_chat_description.md @@ -23,8 +23,7 @@ Description: Returns True on success. ## Usage - -### As bot method bot +### As bot method ```python3 result: bool = await bot.set_chat_description(...) @@ -53,7 +52,6 @@ return SetChatDescription(...) ``` - ## Related pages: - [Official documentation](https://core.telegram.org/bots/api#setchatdescription) diff --git a/docs/api/methods/set_chat_permissions.md b/docs/api/methods/set_chat_permissions.md index 3f975e51..2c04f480 100644 --- a/docs/api/methods/set_chat_permissions.md +++ b/docs/api/methods/set_chat_permissions.md @@ -23,8 +23,7 @@ Description: Returns True on success. ## Usage - -### As bot method bot +### As bot method ```python3 result: bool = await bot.set_chat_permissions(...) @@ -53,7 +52,6 @@ return SetChatPermissions(...) ``` - ## Related pages: - [Official documentation](https://core.telegram.org/bots/api#setchatpermissions) diff --git a/docs/api/methods/set_chat_photo.md b/docs/api/methods/set_chat_photo.md index 8d17dc21..657c9025 100644 --- a/docs/api/methods/set_chat_photo.md +++ b/docs/api/methods/set_chat_photo.md @@ -23,8 +23,7 @@ Description: Returns True on success. ## Usage - -### As bot method bot +### As bot method ```python3 result: bool = await bot.set_chat_photo(...) diff --git a/docs/api/methods/set_chat_sticker_set.md b/docs/api/methods/set_chat_sticker_set.md index dda34637..89841af2 100644 --- a/docs/api/methods/set_chat_sticker_set.md +++ b/docs/api/methods/set_chat_sticker_set.md @@ -23,8 +23,7 @@ Description: Use the field can_set_sticker_set optionally returned in getChat re ## Usage - -### As bot method bot +### As bot method ```python3 result: bool = await bot.set_chat_sticker_set(...) @@ -53,7 +52,6 @@ return SetChatStickerSet(...) ``` - ## Related pages: - [Official documentation](https://core.telegram.org/bots/api#setchatstickerset) diff --git a/docs/api/methods/set_chat_title.md b/docs/api/methods/set_chat_title.md index d4162ce5..90b32c3b 100644 --- a/docs/api/methods/set_chat_title.md +++ b/docs/api/methods/set_chat_title.md @@ -23,8 +23,7 @@ Description: Returns True on success. ## Usage - -### As bot method bot +### As bot method ```python3 result: bool = await bot.set_chat_title(...) @@ -53,7 +52,6 @@ return SetChatTitle(...) ``` - ## Related pages: - [Official documentation](https://core.telegram.org/bots/api#setchattitle) diff --git a/docs/api/methods/set_game_score.md b/docs/api/methods/set_game_score.md index ff09795c..80401159 100644 --- a/docs/api/methods/set_game_score.md +++ b/docs/api/methods/set_game_score.md @@ -28,8 +28,7 @@ Description: On success, if the message was sent by the bot, returns the edited ## Usage - -### As bot method bot +### As bot method ```python3 result: Union[Message, bool] = await bot.set_game_score(...) @@ -58,7 +57,6 @@ return SetGameScore(...) ``` - ## Related pages: - [Official documentation](https://core.telegram.org/bots/api#setgamescore) diff --git a/docs/api/methods/set_my_commands.md b/docs/api/methods/set_my_commands.md new file mode 100644 index 00000000..6f84ddf4 --- /dev/null +++ b/docs/api/methods/set_my_commands.md @@ -0,0 +1,57 @@ +# setMyCommands + +## Description + +Use this method to change the list of the bot's commands. Returns True on success. + + +## Arguments + +| Name | Type | Description | +| - | - | - | +| `commands` | `#!python3 List[BotCommand]` | A JSON-serialized list of bot commands to be set as the list of the bot's commands. At most 100 commands can be specified. | + + + +## Response + +Type: `#!python3 bool` + +Description: Returns True on success. + + +## Usage + +### As bot method + +```python3 +result: bool = await bot.set_my_commands(...) +``` + +### Method as object + +Imports: + +- `from aiogram.methods import SetMyCommands` +- `from aiogram.api.methods import SetMyCommands` +- `from aiogram.api.methods.set_my_commands import SetMyCommands` + +#### In handlers with current bot +```python3 +result: bool = await SetMyCommands(...) +``` + +#### With specific bot +```python3 +result: bool = await bot(SetMyCommands(...)) +``` +#### As reply into Webhook in handler +```python3 +return SetMyCommands(...) +``` + + +## Related pages: + +- [Official documentation](https://core.telegram.org/bots/api#setmycommands) +- [aiogram.types.BotCommand](../types/bot_command.md) diff --git a/docs/api/methods/set_passport_data_errors.md b/docs/api/methods/set_passport_data_errors.md index e00d2e89..3cc82934 100644 --- a/docs/api/methods/set_passport_data_errors.md +++ b/docs/api/methods/set_passport_data_errors.md @@ -25,8 +25,7 @@ Description: The user will not be able to re-submit their Passport to you until ## Usage - -### As bot method bot +### As bot method ```python3 result: bool = await bot.set_passport_data_errors(...) @@ -55,7 +54,6 @@ return SetPassportDataErrors(...) ``` - ## Related pages: - [Official documentation](https://core.telegram.org/bots/api#setpassportdataerrors) diff --git a/docs/api/methods/set_sticker_position_in_set.md b/docs/api/methods/set_sticker_position_in_set.md index 7a67dab9..9e0a094a 100644 --- a/docs/api/methods/set_sticker_position_in_set.md +++ b/docs/api/methods/set_sticker_position_in_set.md @@ -2,7 +2,7 @@ ## Description -Use this method to move a sticker in a set created by the bot to a specific position . Returns True on success. +Use this method to move a sticker in a set created by the bot to a specific position. Returns True on success. ## Arguments @@ -23,8 +23,7 @@ Description: Returns True on success. ## Usage - -### As bot method bot +### As bot method ```python3 result: bool = await bot.set_sticker_position_in_set(...) @@ -53,7 +52,6 @@ return SetStickerPositionInSet(...) ``` - ## Related pages: - [Official documentation](https://core.telegram.org/bots/api#setstickerpositioninset) diff --git a/docs/api/methods/set_sticker_set_thumb.md b/docs/api/methods/set_sticker_set_thumb.md new file mode 100644 index 00000000..ffc2b1d5 --- /dev/null +++ b/docs/api/methods/set_sticker_set_thumb.md @@ -0,0 +1,60 @@ +# setStickerSetThumb + +## Description + +Use this method to set the thumbnail of a sticker set. Animated thumbnails can be set for animated sticker sets only. Returns True on success. + + +## Arguments + +| Name | Type | Description | +| - | - | - | +| `name` | `#!python3 str` | Sticker set name | +| `user_id` | `#!python3 int` | User identifier of the sticker set owner | +| `thumb` | `#!python3 Optional[Union[InputFile, str]]` | Optional. A PNG image with the thumbnail, must be up to 128 kilobytes in size and have width and height exactly 100px, or a TGS animation with the thumbnail up to 32 kilobytes in size; see https://core.telegram.org/animated_stickers#technical-requirements for animated sticker technical requirements. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data.. Animated sticker set thumbnail can't be uploaded via HTTP URL. | + + + +## Response + +Type: `#!python3 bool` + +Description: Returns True on success. + + +## Usage + +### As bot method + +```python3 +result: bool = await bot.set_sticker_set_thumb(...) +``` + +### Method as object + +Imports: + +- `from aiogram.methods import SetStickerSetThumb` +- `from aiogram.api.methods import SetStickerSetThumb` +- `from aiogram.api.methods.set_sticker_set_thumb import SetStickerSetThumb` + +#### In handlers with current bot +```python3 +result: bool = await SetStickerSetThumb(...) +``` + +#### With specific bot +```python3 +result: bool = await bot(SetStickerSetThumb(...)) +``` +#### As reply into Webhook in handler +```python3 +return SetStickerSetThumb(...) +``` + + +## Related pages: + +- [Official documentation](https://core.telegram.org/bots/api#setstickersetthumb) +- [aiogram.types.InputFile](../types/input_file.md) +- [How to upload file?](../sending_files.md) diff --git a/docs/api/methods/set_webhook.md b/docs/api/methods/set_webhook.md index 4af9a71b..95e82a86 100644 --- a/docs/api/methods/set_webhook.md +++ b/docs/api/methods/set_webhook.md @@ -37,8 +37,7 @@ Description: Returns True on success. ## Usage - -### As bot method bot +### As bot method ```python3 result: bool = await bot.set_webhook(...) @@ -67,7 +66,6 @@ return SetWebhook(...) ``` - ## Related pages: - [Official documentation](https://core.telegram.org/bots/api#setwebhook) diff --git a/docs/api/methods/stop_message_live_location.md b/docs/api/methods/stop_message_live_location.md index 32dbaa19..76748df3 100644 --- a/docs/api/methods/stop_message_live_location.md +++ b/docs/api/methods/stop_message_live_location.md @@ -25,8 +25,7 @@ Description: On success, if the message was sent by the bot, the sent Message is ## Usage - -### As bot method bot +### As bot method ```python3 result: Union[Message, bool] = await bot.stop_message_live_location(...) @@ -55,7 +54,6 @@ return StopMessageLiveLocation(...) ``` - ## Related pages: - [Official documentation](https://core.telegram.org/bots/api#stopmessagelivelocation) diff --git a/docs/api/methods/stop_poll.md b/docs/api/methods/stop_poll.md index 797da7ec..a251ee73 100644 --- a/docs/api/methods/stop_poll.md +++ b/docs/api/methods/stop_poll.md @@ -24,8 +24,7 @@ Description: On success, the stopped Poll with the final results is returned. ## Usage - -### As bot method bot +### As bot method ```python3 result: Poll = await bot.stop_poll(...) @@ -54,7 +53,6 @@ return StopPoll(...) ``` - ## Related pages: - [Official documentation](https://core.telegram.org/bots/api#stoppoll) diff --git a/docs/api/methods/unban_chat_member.md b/docs/api/methods/unban_chat_member.md index 2c18ed5e..1620ccf7 100644 --- a/docs/api/methods/unban_chat_member.md +++ b/docs/api/methods/unban_chat_member.md @@ -23,8 +23,7 @@ Description: The user will not return to the group or channel automatically, but ## Usage - -### As bot method bot +### As bot method ```python3 result: bool = await bot.unban_chat_member(...) @@ -53,7 +52,6 @@ return UnbanChatMember(...) ``` - ## Related pages: - [Official documentation](https://core.telegram.org/bots/api#unbanchatmember) diff --git a/docs/api/methods/unpin_chat_message.md b/docs/api/methods/unpin_chat_message.md index b49bf991..fc60f74e 100644 --- a/docs/api/methods/unpin_chat_message.md +++ b/docs/api/methods/unpin_chat_message.md @@ -22,8 +22,7 @@ Description: Returns True on success. ## Usage - -### As bot method bot +### As bot method ```python3 result: bool = await bot.unpin_chat_message(...) @@ -52,7 +51,6 @@ return UnpinChatMessage(...) ``` - ## Related pages: - [Official documentation](https://core.telegram.org/bots/api#unpinchatmessage) diff --git a/docs/api/methods/upload_sticker_file.md b/docs/api/methods/upload_sticker_file.md index b14b250e..8777df2e 100644 --- a/docs/api/methods/upload_sticker_file.md +++ b/docs/api/methods/upload_sticker_file.md @@ -2,7 +2,7 @@ ## Description -Use this method to upload a .png file with a sticker for later use in createNewStickerSet and addStickerToSet methods (can be used multiple times). Returns the uploaded File on success. +Use this method to upload a .PNG file with a sticker for later use in createNewStickerSet and addStickerToSet methods (can be used multiple times). Returns the uploaded File on success. ## Arguments @@ -23,8 +23,7 @@ Description: Returns the uploaded File on success. ## Usage - -### As bot method bot +### As bot method ```python3 result: File = await bot.upload_sticker_file(...) diff --git a/docs/api/types/bot_command.md b/docs/api/types/bot_command.md new file mode 100644 index 00000000..383161da --- /dev/null +++ b/docs/api/types/bot_command.md @@ -0,0 +1,25 @@ +# BotCommand + +## Description + +This object represents a bot command. + + +## Attributes + +| Name | Type | Description | +| - | - | - | +| `command` | `#!python str` | Text of the command, 1-32 characters. Can contain only lowercase English letters, digits and underscores. | +| `description` | `#!python str` | Description of the command, 3-256 characters. | + + + +## Location + +- `from aiogram.types import BotCommand` +- `from aiogram.api.types import BotCommand` +- `from aiogram.api.types.bot_command import BotCommand` + +## Related pages: + +- [Official documentation](https://core.telegram.org/bots/api#botcommand) diff --git a/docs/api/types/dice.md b/docs/api/types/dice.md new file mode 100644 index 00000000..1eb938f8 --- /dev/null +++ b/docs/api/types/dice.md @@ -0,0 +1,24 @@ +# Dice + +## Description + +This object represents a dice with random value from 1 to 6. (Yes, we're aware of the 'proper' singular of die. But it's awkward, and we decided to help it change. One dice at a time!) + + +## Attributes + +| Name | Type | Description | +| - | - | - | +| `value` | `#!python int` | Value of the dice, 1-6 | + + + +## Location + +- `from aiogram.types import Dice` +- `from aiogram.api.types import Dice` +- `from aiogram.api.types.dice import Dice` + +## Related pages: + +- [Official documentation](https://core.telegram.org/bots/api#dice) diff --git a/docs/api/types/index.md b/docs/api/types/index.md index 3b43ad2f..c0916cfe 100644 --- a/docs/api/types/index.md +++ b/docs/api/types/index.md @@ -2,7 +2,6 @@ Here is list of all available API types: - - Getting updates - [Update](update.md) - [WebhookInfo](webhook_info.md) @@ -24,6 +23,7 @@ Here is list of all available API types: - [PollOption](poll_option.md) - [PollAnswer](poll_answer.md) - [Poll](poll.md) + - [Dice](dice.md) - [UserProfilePhotos](user_profile_photos.md) - [File](file.md) - [ReplyKeyboardMarkup](reply_keyboard_markup.md) @@ -38,6 +38,7 @@ Here is list of all available API types: - [ChatPhoto](chat_photo.md) - [ChatMember](chat_member.md) - [ChatPermissions](chat_permissions.md) + - [BotCommand](bot_command.md) - [ResponseParameters](response_parameters.md) - [InputMedia](input_media.md) - [InputMediaPhoto](input_media_photo.md) diff --git a/docs/api/types/inline_query.md b/docs/api/types/inline_query.md index 583d6a60..cd3c7545 100644 --- a/docs/api/types/inline_query.md +++ b/docs/api/types/inline_query.md @@ -11,7 +11,7 @@ This object represents an incoming inline query. When the user sends an empty qu | - | - | - | | `id` | `#!python str` | Unique identifier for this query | | `from_user` | `#!python User` | Sender | -| `query` | `#!python str` | Text of the query (up to 512 characters) | +| `query` | `#!python str` | Text of the query (up to 256 characters) | | `offset` | `#!python str` | Offset of the results to be returned, can be controlled by the bot | | `location` | `#!python Optional[Location]` | Optional. Sender location, only for bots that request user location | diff --git a/docs/api/types/inline_query_result_audio.md b/docs/api/types/inline_query_result_audio.md index 38d1bb91..4a4257ea 100644 --- a/docs/api/types/inline_query_result_audio.md +++ b/docs/api/types/inline_query_result_audio.md @@ -15,7 +15,7 @@ Note: This will only work in Telegram versions released after 9 April, 2016. Old | `id` | `#!python str` | Unique identifier for this result, 1-64 bytes | | `audio_url` | `#!python str` | A valid URL for the audio file | | `title` | `#!python str` | Title | -| `caption` | `#!python Optional[str]` | Optional. Caption, 0-1024 characters | +| `caption` | `#!python Optional[str]` | Optional. Caption, 0-1024 characters after entities parsing | | `parse_mode` | `#!python Optional[str]` | Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. | | `performer` | `#!python Optional[str]` | Optional. Performer | | `audio_duration` | `#!python Optional[int]` | Optional. Audio duration in seconds | diff --git a/docs/api/types/inline_query_result_cached_audio.md b/docs/api/types/inline_query_result_cached_audio.md index c1110f8e..2fdbeb0e 100644 --- a/docs/api/types/inline_query_result_cached_audio.md +++ b/docs/api/types/inline_query_result_cached_audio.md @@ -14,7 +14,7 @@ Note: This will only work in Telegram versions released after 9 April, 2016. Old | `type` | `#!python str` | Type of the result, must be audio | | `id` | `#!python str` | Unique identifier for this result, 1-64 bytes | | `audio_file_id` | `#!python str` | A valid file identifier for the audio file | -| `caption` | `#!python Optional[str]` | Optional. Caption, 0-1024 characters | +| `caption` | `#!python Optional[str]` | Optional. Caption, 0-1024 characters after entities parsing | | `parse_mode` | `#!python Optional[str]` | Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. | | `reply_markup` | `#!python Optional[InlineKeyboardMarkup]` | Optional. Inline keyboard attached to the message | | `input_message_content` | `#!python Optional[InputMessageContent]` | Optional. Content of the message to be sent instead of the audio | diff --git a/docs/api/types/inline_query_result_cached_document.md b/docs/api/types/inline_query_result_cached_document.md index 7401235f..0fc60042 100644 --- a/docs/api/types/inline_query_result_cached_document.md +++ b/docs/api/types/inline_query_result_cached_document.md @@ -16,7 +16,7 @@ Note: This will only work in Telegram versions released after 9 April, 2016. Old | `title` | `#!python str` | Title for the result | | `document_file_id` | `#!python str` | A valid file identifier for the file | | `description` | `#!python Optional[str]` | Optional. Short description of the result | -| `caption` | `#!python Optional[str]` | Optional. Caption of the document to be sent, 0-1024 characters | +| `caption` | `#!python Optional[str]` | Optional. Caption of the document to be sent, 0-1024 characters after entities parsing | | `parse_mode` | `#!python Optional[str]` | Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. | | `reply_markup` | `#!python Optional[InlineKeyboardMarkup]` | Optional. Inline keyboard attached to the message | | `input_message_content` | `#!python Optional[InputMessageContent]` | Optional. Content of the message to be sent instead of the file | diff --git a/docs/api/types/inline_query_result_cached_gif.md b/docs/api/types/inline_query_result_cached_gif.md index 44c4820d..575582af 100644 --- a/docs/api/types/inline_query_result_cached_gif.md +++ b/docs/api/types/inline_query_result_cached_gif.md @@ -13,7 +13,7 @@ Represents a link to an animated GIF file stored on the Telegram servers. By def | `id` | `#!python str` | Unique identifier for this result, 1-64 bytes | | `gif_file_id` | `#!python str` | A valid file identifier for the GIF file | | `title` | `#!python Optional[str]` | Optional. Title for the result | -| `caption` | `#!python Optional[str]` | Optional. Caption of the GIF file to be sent, 0-1024 characters | +| `caption` | `#!python Optional[str]` | Optional. Caption of the GIF file to be sent, 0-1024 characters after entities parsing | | `parse_mode` | `#!python Optional[str]` | Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. | | `reply_markup` | `#!python Optional[InlineKeyboardMarkup]` | Optional. Inline keyboard attached to the message | | `input_message_content` | `#!python Optional[InputMessageContent]` | Optional. Content of the message to be sent instead of the GIF animation | diff --git a/docs/api/types/inline_query_result_cached_mpeg4_gif.md b/docs/api/types/inline_query_result_cached_mpeg4_gif.md index 0ae5bbf6..1efd7acf 100644 --- a/docs/api/types/inline_query_result_cached_mpeg4_gif.md +++ b/docs/api/types/inline_query_result_cached_mpeg4_gif.md @@ -13,7 +13,7 @@ Represents a link to a video animation (H.264/MPEG-4 AVC video without sound) st | `id` | `#!python str` | Unique identifier for this result, 1-64 bytes | | `mpeg4_file_id` | `#!python str` | A valid file identifier for the MP4 file | | `title` | `#!python Optional[str]` | Optional. Title for the result | -| `caption` | `#!python Optional[str]` | Optional. Caption of the MPEG-4 file to be sent, 0-1024 characters | +| `caption` | `#!python Optional[str]` | Optional. Caption of the MPEG-4 file to be sent, 0-1024 characters after entities parsing | | `parse_mode` | `#!python Optional[str]` | Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. | | `reply_markup` | `#!python Optional[InlineKeyboardMarkup]` | Optional. Inline keyboard attached to the message | | `input_message_content` | `#!python Optional[InputMessageContent]` | Optional. Content of the message to be sent instead of the video animation | diff --git a/docs/api/types/inline_query_result_cached_photo.md b/docs/api/types/inline_query_result_cached_photo.md index 1ce40aa8..e06c6a73 100644 --- a/docs/api/types/inline_query_result_cached_photo.md +++ b/docs/api/types/inline_query_result_cached_photo.md @@ -14,7 +14,7 @@ Represents a link to a photo stored on the Telegram servers. By default, this ph | `photo_file_id` | `#!python str` | A valid file identifier of the photo | | `title` | `#!python Optional[str]` | Optional. Title for the result | | `description` | `#!python Optional[str]` | Optional. Short description of the result | -| `caption` | `#!python Optional[str]` | Optional. Caption of the photo to be sent, 0-1024 characters | +| `caption` | `#!python Optional[str]` | Optional. Caption of the photo to be sent, 0-1024 characters after entities parsing | | `parse_mode` | `#!python Optional[str]` | Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. | | `reply_markup` | `#!python Optional[InlineKeyboardMarkup]` | Optional. Inline keyboard attached to the message | | `input_message_content` | `#!python Optional[InputMessageContent]` | Optional. Content of the message to be sent instead of the photo | diff --git a/docs/api/types/inline_query_result_cached_video.md b/docs/api/types/inline_query_result_cached_video.md index 6e12fbbc..c0620726 100644 --- a/docs/api/types/inline_query_result_cached_video.md +++ b/docs/api/types/inline_query_result_cached_video.md @@ -14,7 +14,7 @@ Represents a link to a video file stored on the Telegram servers. By default, th | `video_file_id` | `#!python str` | A valid file identifier for the video file | | `title` | `#!python str` | Title for the result | | `description` | `#!python Optional[str]` | Optional. Short description of the result | -| `caption` | `#!python Optional[str]` | Optional. Caption of the video to be sent, 0-1024 characters | +| `caption` | `#!python Optional[str]` | Optional. Caption of the video to be sent, 0-1024 characters after entities parsing | | `parse_mode` | `#!python Optional[str]` | Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. | | `reply_markup` | `#!python Optional[InlineKeyboardMarkup]` | Optional. Inline keyboard attached to the message | | `input_message_content` | `#!python Optional[InputMessageContent]` | Optional. Content of the message to be sent instead of the video | diff --git a/docs/api/types/inline_query_result_cached_voice.md b/docs/api/types/inline_query_result_cached_voice.md index aadcbd0e..28d00e6b 100644 --- a/docs/api/types/inline_query_result_cached_voice.md +++ b/docs/api/types/inline_query_result_cached_voice.md @@ -15,7 +15,7 @@ Note: This will only work in Telegram versions released after 9 April, 2016. Old | `id` | `#!python str` | Unique identifier for this result, 1-64 bytes | | `voice_file_id` | `#!python str` | A valid file identifier for the voice message | | `title` | `#!python str` | Voice message title | -| `caption` | `#!python Optional[str]` | Optional. Caption, 0-1024 characters | +| `caption` | `#!python Optional[str]` | Optional. Caption, 0-1024 characters after entities parsing | | `parse_mode` | `#!python Optional[str]` | Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. | | `reply_markup` | `#!python Optional[InlineKeyboardMarkup]` | Optional. Inline keyboard attached to the message | | `input_message_content` | `#!python Optional[InputMessageContent]` | Optional. Content of the message to be sent instead of the voice message | diff --git a/docs/api/types/inline_query_result_document.md b/docs/api/types/inline_query_result_document.md index 05c783d7..9ebbf1a7 100644 --- a/docs/api/types/inline_query_result_document.md +++ b/docs/api/types/inline_query_result_document.md @@ -16,7 +16,7 @@ Note: This will only work in Telegram versions released after 9 April, 2016. Old | `title` | `#!python str` | Title for the result | | `document_url` | `#!python str` | A valid URL for the file | | `mime_type` | `#!python str` | Mime type of the content of the file, either 'application/pdf' or 'application/zip' | -| `caption` | `#!python Optional[str]` | Optional. Caption of the document to be sent, 0-1024 characters | +| `caption` | `#!python Optional[str]` | Optional. Caption of the document to be sent, 0-1024 characters after entities parsing | | `parse_mode` | `#!python Optional[str]` | Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. | | `description` | `#!python Optional[str]` | Optional. Short description of the result | | `reply_markup` | `#!python Optional[InlineKeyboardMarkup]` | Optional. Inline keyboard attached to the message | diff --git a/docs/api/types/inline_query_result_gif.md b/docs/api/types/inline_query_result_gif.md index 4365c243..59a3a6e3 100644 --- a/docs/api/types/inline_query_result_gif.md +++ b/docs/api/types/inline_query_result_gif.md @@ -17,7 +17,7 @@ Represents a link to an animated GIF file. By default, this animated GIF file wi | `gif_height` | `#!python Optional[int]` | Optional. Height of the GIF | | `gif_duration` | `#!python Optional[int]` | Optional. Duration of the GIF | | `title` | `#!python Optional[str]` | Optional. Title for the result | -| `caption` | `#!python Optional[str]` | Optional. Caption of the GIF file to be sent, 0-1024 characters | +| `caption` | `#!python Optional[str]` | Optional. Caption of the GIF file to be sent, 0-1024 characters after entities parsing | | `parse_mode` | `#!python Optional[str]` | Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. | | `reply_markup` | `#!python Optional[InlineKeyboardMarkup]` | Optional. Inline keyboard attached to the message | | `input_message_content` | `#!python Optional[InputMessageContent]` | Optional. Content of the message to be sent instead of the GIF animation | diff --git a/docs/api/types/inline_query_result_mpeg4_gif.md b/docs/api/types/inline_query_result_mpeg4_gif.md index 934611ab..3b03d8ef 100644 --- a/docs/api/types/inline_query_result_mpeg4_gif.md +++ b/docs/api/types/inline_query_result_mpeg4_gif.md @@ -17,7 +17,7 @@ Represents a link to a video animation (H.264/MPEG-4 AVC video without sound). B | `mpeg4_height` | `#!python Optional[int]` | Optional. Video height | | `mpeg4_duration` | `#!python Optional[int]` | Optional. Video duration | | `title` | `#!python Optional[str]` | Optional. Title for the result | -| `caption` | `#!python Optional[str]` | Optional. Caption of the MPEG-4 file to be sent, 0-1024 characters | +| `caption` | `#!python Optional[str]` | Optional. Caption of the MPEG-4 file to be sent, 0-1024 characters after entities parsing | | `parse_mode` | `#!python Optional[str]` | Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. | | `reply_markup` | `#!python Optional[InlineKeyboardMarkup]` | Optional. Inline keyboard attached to the message | | `input_message_content` | `#!python Optional[InputMessageContent]` | Optional. Content of the message to be sent instead of the video animation | diff --git a/docs/api/types/inline_query_result_photo.md b/docs/api/types/inline_query_result_photo.md index 96d71636..3c13c787 100644 --- a/docs/api/types/inline_query_result_photo.md +++ b/docs/api/types/inline_query_result_photo.md @@ -17,7 +17,7 @@ Represents a link to a photo. By default, this photo will be sent by the user wi | `photo_height` | `#!python Optional[int]` | Optional. Height of the photo | | `title` | `#!python Optional[str]` | Optional. Title for the result | | `description` | `#!python Optional[str]` | Optional. Short description of the result | -| `caption` | `#!python Optional[str]` | Optional. Caption of the photo to be sent, 0-1024 characters | +| `caption` | `#!python Optional[str]` | Optional. Caption of the photo to be sent, 0-1024 characters after entities parsing | | `parse_mode` | `#!python Optional[str]` | Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. | | `reply_markup` | `#!python Optional[InlineKeyboardMarkup]` | Optional. Inline keyboard attached to the message | | `input_message_content` | `#!python Optional[InputMessageContent]` | Optional. Content of the message to be sent instead of the photo | diff --git a/docs/api/types/inline_query_result_video.md b/docs/api/types/inline_query_result_video.md index b212f03a..3a503511 100644 --- a/docs/api/types/inline_query_result_video.md +++ b/docs/api/types/inline_query_result_video.md @@ -17,7 +17,7 @@ If an InlineQueryResultVideo message contains an embedded video (e.g., YouTube), | `mime_type` | `#!python str` | Mime type of the content of video url, 'text/html' or 'video/mp4' | | `thumb_url` | `#!python str` | URL of the thumbnail (jpeg only) for the video | | `title` | `#!python str` | Title for the result | -| `caption` | `#!python Optional[str]` | Optional. Caption of the video to be sent, 0-1024 characters | +| `caption` | `#!python Optional[str]` | Optional. Caption of the video to be sent, 0-1024 characters after entities parsing | | `parse_mode` | `#!python Optional[str]` | Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. | | `video_width` | `#!python Optional[int]` | Optional. Video width | | `video_height` | `#!python Optional[int]` | Optional. Video height | diff --git a/docs/api/types/inline_query_result_voice.md b/docs/api/types/inline_query_result_voice.md index f7725c5a..c3907b7b 100644 --- a/docs/api/types/inline_query_result_voice.md +++ b/docs/api/types/inline_query_result_voice.md @@ -2,7 +2,7 @@ ## Description -Represents a link to a voice recording in an .ogg container encoded with OPUS. By default, this voice recording will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the the voice message. +Represents a link to a voice recording in an .OGG container encoded with OPUS. By default, this voice recording will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the the voice message. Note: This will only work in Telegram versions released after 9 April, 2016. Older clients will ignore them. @@ -15,7 +15,7 @@ Note: This will only work in Telegram versions released after 9 April, 2016. Old | `id` | `#!python str` | Unique identifier for this result, 1-64 bytes | | `voice_url` | `#!python str` | A valid URL for the voice recording | | `title` | `#!python str` | Recording title | -| `caption` | `#!python Optional[str]` | Optional. Caption, 0-1024 characters | +| `caption` | `#!python Optional[str]` | Optional. Caption, 0-1024 characters after entities parsing | | `parse_mode` | `#!python Optional[str]` | Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. | | `voice_duration` | `#!python Optional[int]` | Optional. Recording duration in seconds | | `reply_markup` | `#!python Optional[InlineKeyboardMarkup]` | Optional. Inline keyboard attached to the message | diff --git a/docs/api/types/input_media_animation.md b/docs/api/types/input_media_animation.md index ce0c3132..be9ebf4f 100644 --- a/docs/api/types/input_media_animation.md +++ b/docs/api/types/input_media_animation.md @@ -12,7 +12,7 @@ Represents an animation file (GIF or H.264/MPEG-4 AVC video without sound) to be | `type` | `#!python str` | Type of the result, must be animation | | `media` | `#!python Union[str, InputFile]` | File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass 'attach://' to upload a new one using multipart/form-data under name. | | `thumb` | `#!python Optional[Union[InputFile, str]]` | Optional. Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass 'attach://' if the thumbnail was uploaded using multipart/form-data under . | -| `caption` | `#!python Optional[str]` | Optional. Caption of the animation to be sent, 0-1024 characters | +| `caption` | `#!python Optional[str]` | Optional. Caption of the animation to be sent, 0-1024 characters after entities parsing | | `parse_mode` | `#!python Optional[str]` | Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. | | `width` | `#!python Optional[int]` | Optional. Animation width | | `height` | `#!python Optional[int]` | Optional. Animation height | diff --git a/docs/api/types/input_media_audio.md b/docs/api/types/input_media_audio.md index dac0d773..45e699f5 100644 --- a/docs/api/types/input_media_audio.md +++ b/docs/api/types/input_media_audio.md @@ -12,7 +12,7 @@ Represents an audio file to be treated as music to be sent. | `type` | `#!python str` | Type of the result, must be audio | | `media` | `#!python Union[str, InputFile]` | File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass 'attach://' to upload a new one using multipart/form-data under name. | | `thumb` | `#!python Optional[Union[InputFile, str]]` | Optional. Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass 'attach://' if the thumbnail was uploaded using multipart/form-data under . | -| `caption` | `#!python Optional[str]` | Optional. Caption of the audio to be sent, 0-1024 characters | +| `caption` | `#!python Optional[str]` | Optional. Caption of the audio to be sent, 0-1024 characters after entities parsing | | `parse_mode` | `#!python Optional[str]` | Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. | | `duration` | `#!python Optional[int]` | Optional. Duration of the audio in seconds | | `performer` | `#!python Optional[str]` | Optional. Performer of the audio | diff --git a/docs/api/types/input_media_document.md b/docs/api/types/input_media_document.md index 77877ebe..62a9d39e 100644 --- a/docs/api/types/input_media_document.md +++ b/docs/api/types/input_media_document.md @@ -12,7 +12,7 @@ Represents a general file to be sent. | `type` | `#!python str` | Type of the result, must be document | | `media` | `#!python Union[str, InputFile]` | File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass 'attach://' to upload a new one using multipart/form-data under name. | | `thumb` | `#!python Optional[Union[InputFile, str]]` | Optional. Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass 'attach://' if the thumbnail was uploaded using multipart/form-data under . | -| `caption` | `#!python Optional[str]` | Optional. Caption of the document to be sent, 0-1024 characters | +| `caption` | `#!python Optional[str]` | Optional. Caption of the document to be sent, 0-1024 characters after entities parsing | | `parse_mode` | `#!python Optional[str]` | Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. | diff --git a/docs/api/types/input_media_photo.md b/docs/api/types/input_media_photo.md index 29c903e6..9d75feff 100644 --- a/docs/api/types/input_media_photo.md +++ b/docs/api/types/input_media_photo.md @@ -11,7 +11,7 @@ Represents a photo to be sent. | - | - | - | | `type` | `#!python str` | Type of the result, must be photo | | `media` | `#!python Union[str, InputFile]` | File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass 'attach://' to upload a new one using multipart/form-data under name. | -| `caption` | `#!python Optional[str]` | Optional. Caption of the photo to be sent, 0-1024 characters | +| `caption` | `#!python Optional[str]` | Optional. Caption of the photo to be sent, 0-1024 characters after entities parsing | | `parse_mode` | `#!python Optional[str]` | Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. | diff --git a/docs/api/types/input_media_video.md b/docs/api/types/input_media_video.md index 5a45d03d..3779cd1c 100644 --- a/docs/api/types/input_media_video.md +++ b/docs/api/types/input_media_video.md @@ -12,7 +12,7 @@ Represents a video to be sent. | `type` | `#!python str` | Type of the result, must be video | | `media` | `#!python Union[str, InputFile]` | File to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass 'attach://' to upload a new one using multipart/form-data under name. | | `thumb` | `#!python Optional[Union[InputFile, str]]` | Optional. Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass 'attach://' if the thumbnail was uploaded using multipart/form-data under . | -| `caption` | `#!python Optional[str]` | Optional. Caption of the video to be sent, 0-1024 characters | +| `caption` | `#!python Optional[str]` | Optional. Caption of the video to be sent, 0-1024 characters after entities parsing | | `parse_mode` | `#!python Optional[str]` | Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption. | | `width` | `#!python Optional[int]` | Optional. Video width | | `height` | `#!python Optional[int]` | Optional. Video height | diff --git a/docs/api/types/keyboard_button.md b/docs/api/types/keyboard_button.md index 9177caa2..d09616e1 100644 --- a/docs/api/types/keyboard_button.md +++ b/docs/api/types/keyboard_button.md @@ -4,9 +4,9 @@ This object represents one button of the reply keyboard. For simple text buttons String can be used instead of this object to specify text of the button. Optional fields request_contact, request_location, and request_poll are mutually exclusive. -Note: request_contact and request_location options will only work in Telegram versions released after 9 April, 2016. Older clients will receive unsupported message. +Note: request_contact and request_location options will only work in Telegram versions released after 9 April, 2016. Older clients will display unsupported message. -Note: request_poll option will only work in Telegram versions released after 23 January, 2020. Older clients will receive unsupported message. +Note: request_poll option will only work in Telegram versions released after 23 January, 2020. Older clients will display unsupported message. ## Attributes diff --git a/docs/api/types/message.md b/docs/api/types/message.md index df9b711d..c265d656 100644 --- a/docs/api/types/message.md +++ b/docs/api/types/message.md @@ -19,11 +19,11 @@ This object represents a message. | `forward_signature` | `#!python Optional[str]` | Optional. For messages forwarded from channels, signature of the post author if present | | `forward_sender_name` | `#!python Optional[str]` | Optional. Sender's name for messages forwarded from users who disallow adding a link to their account in forwarded messages | | `forward_date` | `#!python Optional[int]` | Optional. For forwarded messages, date the original message was sent in Unix time | -| `reply_to_message` | `#!python Optional[send_to_message.mdMessReply to message with to_messageage]` | Optional. For replies, the original message. Note that the Message object in this field will not contain further reply_to_message fields even if it itself is a reply. | +| `reply_to_message` | `#!python Optional[Message]` | Optional. For replies, the original message. Note that the Message object in this field will not contain further reply_to_message fields even if it itself is a reply. | | `edit_date` | `#!python Optional[int]` | Optional. Date the message was last edited in Unix time | | `media_group_id` | `#!python Optional[str]` | Optional. The unique identifier of a media message group this message belongs to | | `author_signature` | `#!python Optional[str]` | Optional. Signature of the post author for messages in channels | -| `text` | `#!python Optional[str]` | Optional. For text messages, the actual UTF-8 text of the message, 0-4096 characters. | +| `text` | `#!python Optional[str]` | Optional. For text messages, the actual UTF-8 text of the message, 0-4096 characters | | `entities` | `#!python Optional[List[MessageEntity]]` | Optional. For text messages, special entities like usernames, URLs, bot commands, etc. that appear in the text | | `caption_entities` | `#!python Optional[List[MessageEntity]]` | Optional. For messages with a caption, special entities like usernames, URLs, bot commands, etc. that appear in the caption | | `audio` | `#!python Optional[Audio]` | Optional. Message is an audio file, information about the file | @@ -40,6 +40,7 @@ This object represents a message. | `location` | `#!python Optional[Location]` | Optional. Message is a shared location, information about the location | | `venue` | `#!python Optional[Venue]` | Optional. Message is a venue, information about the venue | | `poll` | `#!python Optional[Poll]` | Optional. Message is a native poll, information about the poll | +| `dice` | `#!python Optional[Dice]` | Optional. Message is a dice with random value from 1 to 6 | | `new_chat_members` | `#!python Optional[List[User]]` | Optional. New members that were added to the group or supergroup and information about them (the bot itself may be one of these members) | | `left_chat_member` | `#!python Optional[User]` | Optional. A member was removed from the group, information about them (this member may be the bot itself) | | `new_chat_title` | `#!python Optional[str]` | Optional. A chat title was changed to this value | @@ -55,7 +56,7 @@ This object represents a message. | `successful_payment` | `#!python Optional[SuccessfulPayment]` | Optional. Message is a service message about a successful payment, information about the payment. | | `connected_website` | `#!python Optional[str]` | Optional. The domain name of the website on which the user has logged in. | | `passport_data` | `#!python Optional[PassportData]` | Optional. Telegram Passport data | -| `reply_markup` | `#!python Optional[send_markup.mdInliReply to message with markupneKeyboardMarkup]` | Optional. Inline keyboard attached to the message. login_url buttons are represented as ordinary url buttons. | +| `reply_markup` | `#!python Optional[InlineKeyboardMarkup]` | Optional. Inline keyboard attached to the message. login_url buttons are represented as ordinary url buttons. | @@ -101,6 +102,7 @@ This methods has the same specification with the API but without `chat_id` and ` - [aiogram.types.Audio](../types/audio.md) - [aiogram.types.Chat](../types/chat.md) - [aiogram.types.Contact](../types/contact.md) +- [aiogram.types.Dice](../types/dice.md) - [aiogram.types.Document](../types/document.md) - [aiogram.types.Game](../types/game.md) - [aiogram.types.InlineKeyboardMarkup](../types/inline_keyboard_markup.md) diff --git a/docs/api/types/sticker.md b/docs/api/types/sticker.md index dde51a74..2d864b66 100644 --- a/docs/api/types/sticker.md +++ b/docs/api/types/sticker.md @@ -14,7 +14,7 @@ This object represents a sticker. | `width` | `#!python int` | Sticker width | | `height` | `#!python int` | Sticker height | | `is_animated` | `#!python bool` | True, if the sticker is animated | -| `thumb` | `#!python Optional[PhotoSize]` | Optional. Sticker thumbnail in the .webp or .jpg format | +| `thumb` | `#!python Optional[PhotoSize]` | Optional. Sticker thumbnail in the .WEBP or .JPG format | | `emoji` | `#!python Optional[str]` | Optional. Emoji associated with the sticker | | `set_name` | `#!python Optional[str]` | Optional. Name of the sticker set to which the sticker belongs | | `mask_position` | `#!python Optional[MaskPosition]` | Optional. For mask stickers, the position where the mask should be placed | diff --git a/docs/api/types/sticker_set.md b/docs/api/types/sticker_set.md index 91f4909a..150f4f7a 100644 --- a/docs/api/types/sticker_set.md +++ b/docs/api/types/sticker_set.md @@ -14,6 +14,7 @@ This object represents a sticker set. | `is_animated` | `#!python bool` | True, if the sticker set contains animated stickers | | `contains_masks` | `#!python bool` | True, if the sticker set contains masks | | `stickers` | `#!python List[Sticker]` | List of all set stickers | +| `thumb` | `#!python Optional[PhotoSize]` | Optional. Sticker set thumbnail in the .WEBP or .TGS format | @@ -26,4 +27,5 @@ This object represents a sticker set. ## Related pages: - [Official documentation](https://core.telegram.org/bots/api#stickerset) +- [aiogram.types.PhotoSize](../types/photo_size.md) - [aiogram.types.Sticker](../types/sticker.md) diff --git a/mkdocs.yml b/mkdocs.yml index c5b69163..d64deb09 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -42,7 +42,7 @@ nav: - Bot API: - api/index.md - Methods: - - Overview: api/methods/index.md + - Available methods: api/methods/index.md - Getting updates: - api/methods/get_updates.md - api/methods/set_webhook.md @@ -66,6 +66,7 @@ nav: - api/methods/send_venue.md - api/methods/send_contact.md - api/methods/send_poll.md + - api/methods/send_dice.md - api/methods/send_chat_action.md - api/methods/get_user_profile_photos.md - api/methods/get_file.md @@ -90,6 +91,8 @@ nav: - api/methods/set_chat_sticker_set.md - api/methods/delete_chat_sticker_set.md - api/methods/answer_callback_query.md + - api/methods/set_my_commands.md + - api/methods/get_my_commands.md - Updating messages: - api/methods/edit_message_text.md - api/methods/edit_message_caption.md @@ -105,6 +108,7 @@ nav: - api/methods/add_sticker_to_set.md - api/methods/set_sticker_position_in_set.md - api/methods/delete_sticker_from_set.md + - api/methods/set_sticker_set_thumb.md - Inline mode: - api/methods/answer_inline_query.md - Payments: @@ -118,7 +122,7 @@ nav: - api/methods/set_game_score.md - api/methods/get_game_high_scores.md - Types: - - Overview: api/types/index.md + - Available types: api/types/index.md - Getting updates: - api/types/update.md - api/types/webhook_info.md @@ -137,9 +141,10 @@ nav: - api/types/contact.md - api/types/location.md - api/types/venue.md - - api/types/poll_answer.md - api/types/poll_option.md + - api/types/poll_answer.md - api/types/poll.md + - api/types/dice.md - api/types/user_profile_photos.md - api/types/file.md - api/types/reply_keyboard_markup.md @@ -154,6 +159,7 @@ nav: - api/types/chat_photo.md - api/types/chat_member.md - api/types/chat_permissions.md + - api/types/bot_command.md - api/types/response_parameters.md - api/types/input_media.md - api/types/input_media_photo.md @@ -223,7 +229,7 @@ nav: - api/types/game.md - api/types/callback_game.md - api/types/game_high_score.md - - api/sending_files.md + - api/sending_files.md - Dispatcher: - dispatcher/index.md - dispatcher/router.md diff --git a/poetry.lock b/poetry.lock index f20ab5b1..e74f26aa 100644 --- a/poetry.lock +++ b/poetry.lock @@ -242,7 +242,7 @@ marker = "python_version >= \"3.5\" and python_version < \"3.8\" or python_versi name = "importlib-metadata" optional = false python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7" -version = "1.5.0" +version = "1.6.0" [package.dependencies] zipp = ">=0.5" @@ -550,7 +550,7 @@ description = "Utility library for gitignore style pattern matching of file path name = "pathspec" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" -version = "0.7.0" +version = "0.8.0" [[package]] category = "dev" @@ -594,7 +594,7 @@ description = "Library for building powerful interactive command lines in Python name = "prompt-toolkit" optional = false python-versions = ">=3.6.1" -version = "3.0.4" +version = "3.0.5" [package.dependencies] wcwidth = "*" @@ -670,7 +670,7 @@ description = "Python parsing module" name = "pyparsing" optional = false python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*" -version = "2.4.6" +version = "2.4.7" [[package]] category = "dev" @@ -733,7 +733,7 @@ description = "pytest plugin for generating HTML reports" name = "pytest-html" optional = false python-versions = ">=3.6" -version = "2.1.0" +version = "2.1.1" [package.dependencies] pytest = ">=5.0" @@ -799,7 +799,7 @@ description = "YAML parser and emitter for Python" name = "pyyaml" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" -version = "5.3" +version = "5.3.1" [[package]] category = "dev" @@ -807,7 +807,7 @@ description = "Alternative regular expression module, to replace re." name = "regex" optional = false python-versions = "*" -version = "2020.2.20" +version = "2020.4.4" [[package]] category = "dev" @@ -863,7 +863,7 @@ description = "Backported and Experimental Type Hints for Python 3.5+" name = "typing-extensions" optional = false python-versions = "*" -version = "3.7.4.1" +version = "3.7.4.2" [[package]] category = "main" @@ -880,7 +880,7 @@ description = "Measures number of Terminal column cells of wide-character codes" name = "wcwidth" optional = false python-versions = "*" -version = "0.1.8" +version = "0.1.9" [[package]] category = "main" @@ -1045,8 +1045,8 @@ idna = [ {file = "idna-2.9.tar.gz", hash = "sha256:7588d1c14ae4c77d74036e8c22ff447b26d0fde8f007354fd48a7814db15b7cb"}, ] importlib-metadata = [ - {file = "importlib_metadata-1.5.0-py2.py3-none-any.whl", hash = "sha256:b97607a1a18a5100839aec1dc26a1ea17ee0d93b20b0f008d80a5a050afb200b"}, - {file = "importlib_metadata-1.5.0.tar.gz", hash = "sha256:06f5b3a99029c7134207dd882428a66992a9de2bef7c2b699b5641f9886c3302"}, + {file = "importlib_metadata-1.6.0-py2.py3-none-any.whl", hash = "sha256:2a688cbaa90e0cc587f1df48bdc97a6eadccdcd9c35fb3f976a09e3b5016d90f"}, + {file = "importlib_metadata-1.6.0.tar.gz", hash = "sha256:34513a8a0c4962bc66d35b359558fd8a5e10cd472d37aec5f66858addef32c1e"}, ] ipython = [ {file = "ipython-7.13.0-py3-none-any.whl", hash = "sha256:eb8d075de37f678424527b5ef6ea23f7b80240ca031c2dd6de5879d687a65333"}, @@ -1140,11 +1140,6 @@ markupsafe = [ {file = "MarkupSafe-1.1.1-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:ba59edeaa2fc6114428f1637ffff42da1e311e29382d81b339c1817d37ec93c6"}, {file = "MarkupSafe-1.1.1-cp37-cp37m-win32.whl", hash = "sha256:b00c1de48212e4cc9603895652c5c410df699856a2853135b3967591e4beebc2"}, {file = "MarkupSafe-1.1.1-cp37-cp37m-win_amd64.whl", hash = "sha256:9bf40443012702a1d2070043cb6291650a0841ece432556f784f004937f0f32c"}, - {file = "MarkupSafe-1.1.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:6788b695d50a51edb699cb55e35487e430fa21f1ed838122d722e0ff0ac5ba15"}, - {file = "MarkupSafe-1.1.1-cp38-cp38-manylinux1_i686.whl", hash = "sha256:cdb132fc825c38e1aeec2c8aa9338310d29d337bebbd7baa06889d09a60a1fa2"}, - {file = "MarkupSafe-1.1.1-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:13d3144e1e340870b25e7b10b98d779608c02016d5184cfb9927a9f10c689f42"}, - {file = "MarkupSafe-1.1.1-cp38-cp38-win32.whl", hash = "sha256:596510de112c685489095da617b5bcbbac7dd6384aeebeda4df6025d0256a81b"}, - {file = "MarkupSafe-1.1.1-cp38-cp38-win_amd64.whl", hash = "sha256:e8313f01ba26fbbe36c7be1966a7b7424942f670f38e666995b88d012765b9be"}, {file = "MarkupSafe-1.1.1.tar.gz", hash = "sha256:29872e92839765e546828bb7754a68c418d927cd064fd4708fab9fe9c8bb116b"}, ] mccabe = [ @@ -1218,8 +1213,8 @@ parso = [ {file = "parso-0.6.2.tar.gz", hash = "sha256:0c5659e0c6eba20636f99a04f469798dca8da279645ce5c387315b2c23912157"}, ] pathspec = [ - {file = "pathspec-0.7.0-py2.py3-none-any.whl", hash = "sha256:163b0632d4e31cef212976cf57b43d9fd6b0bac6e67c26015d611a647d5e7424"}, - {file = "pathspec-0.7.0.tar.gz", hash = "sha256:562aa70af2e0d434367d9790ad37aed893de47f1693e4201fd1d3dca15d19b96"}, + {file = "pathspec-0.8.0-py2.py3-none-any.whl", hash = "sha256:7d91249d21749788d07a2d0f94147accd8f845507400749ea19c1ec9054a12b0"}, + {file = "pathspec-0.8.0.tar.gz", hash = "sha256:da45173eb3a6f2a5a487efba21f050af2b41948be6ab52b6a1e3ff22bb8b7061"}, ] pexpect = [ {file = "pexpect-4.8.0-py2.py3-none-any.whl", hash = "sha256:0b48a55dcb3c05f3329815901ea4fc1537514d6ba867a152b581d69ae3710937"}, @@ -1234,8 +1229,8 @@ pluggy = [ {file = "pluggy-0.13.1.tar.gz", hash = "sha256:15b2acde666561e1298d71b523007ed7364de07029219b604cf808bfa1c765b0"}, ] prompt-toolkit = [ - {file = "prompt_toolkit-3.0.4-py3-none-any.whl", hash = "sha256:859e1b205b6cf6a51fa57fa34202e45365cf58f8338f0ee9f4e84a4165b37d5b"}, - {file = "prompt_toolkit-3.0.4.tar.gz", hash = "sha256:ebe6b1b08c888b84c50d7f93dee21a09af39860144ff6130aadbd61ae8d29783"}, + {file = "prompt_toolkit-3.0.5-py3-none-any.whl", hash = "sha256:df7e9e63aea609b1da3a65641ceaf5bc7d05e0a04de5bd45d05dbeffbabf9e04"}, + {file = "prompt_toolkit-3.0.5.tar.gz", hash = "sha256:563d1a4140b63ff9dd587bda9557cffb2fe73650205ab6f4383092fb882e7dc8"}, ] ptyprocess = [ {file = "ptyprocess-0.6.0-py2.py3-none-any.whl", hash = "sha256:d7cc528d76e76342423ca640335bd3633420dc1366f258cb31d05e865ef5ca1f"}, @@ -1278,8 +1273,8 @@ pymdown-extensions = [ {file = "pymdown_extensions-6.3-py2.py3-none-any.whl", hash = "sha256:66fae2683c7a1dac53184f7de57f51f8dad73f9ead2f453e94e85096cb811335"}, ] pyparsing = [ - {file = "pyparsing-2.4.6-py2.py3-none-any.whl", hash = "sha256:c342dccb5250c08d45fd6f8b4a559613ca603b57498511740e65cd11a2e7dcec"}, - {file = "pyparsing-2.4.6.tar.gz", hash = "sha256:4c830582a84fb022400b85429791bc551f1f4871c33f23e44f353119e92f969f"}, + {file = "pyparsing-2.4.7-py2.py3-none-any.whl", hash = "sha256:ef9d7589ef3c200abe66653d3f1ab1033c3c419ae9b9bdb1240a85b024efc88b"}, + {file = "pyparsing-2.4.7.tar.gz", hash = "sha256:c203ec8783bf771a155b207279b9bccb8dea02d8f0c9e5f8ead507bc3246ecc1"}, ] pytest = [ {file = "pytest-5.4.1-py3-none-any.whl", hash = "sha256:0e5b30f5cb04e887b91b1ee519fa3d89049595f428c1db76e73bd7f17b09b172"}, @@ -1294,8 +1289,8 @@ pytest-cov = [ {file = "pytest_cov-2.8.1-py2.py3-none-any.whl", hash = "sha256:cdbdef4f870408ebdbfeb44e63e07eb18bb4619fae852f6e760645fa36172626"}, ] pytest-html = [ - {file = "pytest-html-2.1.0.tar.gz", hash = "sha256:8645a8616c8ed7414678e0aeebc3b2fd7d44268773ef5e7289289ad8632c9e91"}, - {file = "pytest_html-2.1.0-py2.py3-none-any.whl", hash = "sha256:0317a0a589db59c26091ab6068b3edac8d9bc1a8bb9727ade48f806797346956"}, + {file = "pytest-html-2.1.1.tar.gz", hash = "sha256:6a4ac391e105e391208e3eb9bd294a60dd336447fd8e1acddff3a6de7f4e57c5"}, + {file = "pytest_html-2.1.1-py2.py3-none-any.whl", hash = "sha256:9e4817e8be8ddde62e8653c8934d0f296b605da3d2277a052f762c56a8b32df2"}, ] pytest-metadata = [ {file = "pytest-metadata-1.8.0.tar.gz", hash = "sha256:2071a59285de40d7541fde1eb9f1ddea1c9db165882df82781367471238b66ba"}, @@ -1314,40 +1309,40 @@ pytz = [ {file = "pytz-2019.3.tar.gz", hash = "sha256:b02c06db6cf09c12dd25137e563b31700d3b80fcc4ad23abb7a315f2789819be"}, ] pyyaml = [ - {file = "PyYAML-5.3-cp27-cp27m-win32.whl", hash = "sha256:940532b111b1952befd7db542c370887a8611660d2b9becff75d39355303d82d"}, - {file = "PyYAML-5.3-cp27-cp27m-win_amd64.whl", hash = "sha256:059b2ee3194d718896c0ad077dd8c043e5e909d9180f387ce42012662a4946d6"}, - {file = "PyYAML-5.3-cp35-cp35m-win32.whl", hash = "sha256:4fee71aa5bc6ed9d5f116327c04273e25ae31a3020386916905767ec4fc5317e"}, - {file = "PyYAML-5.3-cp35-cp35m-win_amd64.whl", hash = "sha256:dbbb2379c19ed6042e8f11f2a2c66d39cceb8aeace421bfc29d085d93eda3689"}, - {file = "PyYAML-5.3-cp36-cp36m-win32.whl", hash = "sha256:e3a057b7a64f1222b56e47bcff5e4b94c4f61faac04c7c4ecb1985e18caa3994"}, - {file = "PyYAML-5.3-cp36-cp36m-win_amd64.whl", hash = "sha256:74782fbd4d4f87ff04159e986886931456a1894c61229be9eaf4de6f6e44b99e"}, - {file = "PyYAML-5.3-cp37-cp37m-win32.whl", hash = "sha256:24521fa2890642614558b492b473bee0ac1f8057a7263156b02e8b14c88ce6f5"}, - {file = "PyYAML-5.3-cp37-cp37m-win_amd64.whl", hash = "sha256:1cf708e2ac57f3aabc87405f04b86354f66799c8e62c28c5fc5f88b5521b2dbf"}, - {file = "PyYAML-5.3-cp38-cp38-win32.whl", hash = "sha256:70024e02197337533eef7b85b068212420f950319cc8c580261963aefc75f811"}, - {file = "PyYAML-5.3-cp38-cp38-win_amd64.whl", hash = "sha256:cb1f2f5e426dc9f07a7681419fe39cee823bb74f723f36f70399123f439e9b20"}, - {file = "PyYAML-5.3.tar.gz", hash = "sha256:e9f45bd5b92c7974e59bcd2dcc8631a6b6cc380a904725fce7bc08872e691615"}, + {file = "PyYAML-5.3.1-cp27-cp27m-win32.whl", hash = "sha256:74809a57b329d6cc0fdccee6318f44b9b8649961fa73144a98735b0aaf029f1f"}, + {file = "PyYAML-5.3.1-cp27-cp27m-win_amd64.whl", hash = "sha256:240097ff019d7c70a4922b6869d8a86407758333f02203e0fc6ff79c5dcede76"}, + {file = "PyYAML-5.3.1-cp35-cp35m-win32.whl", hash = "sha256:4f4b913ca1a7319b33cfb1369e91e50354d6f07a135f3b901aca02aa95940bd2"}, + {file = "PyYAML-5.3.1-cp35-cp35m-win_amd64.whl", hash = "sha256:cc8955cfbfc7a115fa81d85284ee61147059a753344bc51098f3ccd69b0d7e0c"}, + {file = "PyYAML-5.3.1-cp36-cp36m-win32.whl", hash = "sha256:7739fc0fa8205b3ee8808aea45e968bc90082c10aef6ea95e855e10abf4a37b2"}, + {file = "PyYAML-5.3.1-cp36-cp36m-win_amd64.whl", hash = "sha256:69f00dca373f240f842b2931fb2c7e14ddbacd1397d57157a9b005a6a9942648"}, + {file = "PyYAML-5.3.1-cp37-cp37m-win32.whl", hash = "sha256:d13155f591e6fcc1ec3b30685d50bf0711574e2c0dfffd7644babf8b5102ca1a"}, + {file = "PyYAML-5.3.1-cp37-cp37m-win_amd64.whl", hash = "sha256:73f099454b799e05e5ab51423c7bcf361c58d3206fa7b0d555426b1f4d9a3eaf"}, + {file = "PyYAML-5.3.1-cp38-cp38-win32.whl", hash = "sha256:06a0d7ba600ce0b2d2fe2e78453a470b5a6e000a985dd4a4e54e436cc36b0e97"}, + {file = "PyYAML-5.3.1-cp38-cp38-win_amd64.whl", hash = "sha256:95f71d2af0ff4227885f7a6605c37fd53d3a106fcab511b8860ecca9fcf400ee"}, + {file = "PyYAML-5.3.1.tar.gz", hash = "sha256:b8eac752c5e14d3eca0e6dd9199cd627518cb5ec06add0de9d32baeee6fe645d"}, ] regex = [ - {file = "regex-2020.2.20-cp27-cp27m-win32.whl", hash = "sha256:99272d6b6a68c7ae4391908fc15f6b8c9a6c345a46b632d7fdb7ef6c883a2bbb"}, - {file = "regex-2020.2.20-cp27-cp27m-win_amd64.whl", hash = "sha256:974535648f31c2b712a6b2595969f8ab370834080e00ab24e5dbb9d19b8bfb74"}, - {file = "regex-2020.2.20-cp36-cp36m-manylinux1_i686.whl", hash = "sha256:5de40649d4f88a15c9489ed37f88f053c15400257eeb18425ac7ed0a4e119400"}, - {file = "regex-2020.2.20-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:82469a0c1330a4beb3d42568f82dffa32226ced006e0b063719468dcd40ffdf0"}, - {file = "regex-2020.2.20-cp36-cp36m-manylinux2010_i686.whl", hash = "sha256:d58a4fa7910102500722defbde6e2816b0372a4fcc85c7e239323767c74f5cbc"}, - {file = "regex-2020.2.20-cp36-cp36m-manylinux2010_x86_64.whl", hash = "sha256:f1ac2dc65105a53c1c2d72b1d3e98c2464a133b4067a51a3d2477b28449709a0"}, - {file = "regex-2020.2.20-cp36-cp36m-win32.whl", hash = "sha256:8c2b7fa4d72781577ac45ab658da44c7518e6d96e2a50d04ecb0fd8f28b21d69"}, - {file = "regex-2020.2.20-cp36-cp36m-win_amd64.whl", hash = "sha256:269f0c5ff23639316b29f31df199f401e4cb87529eafff0c76828071635d417b"}, - {file = "regex-2020.2.20-cp37-cp37m-manylinux1_i686.whl", hash = "sha256:bed7986547ce54d230fd8721aba6fd19459cdc6d315497b98686d0416efaff4e"}, - {file = "regex-2020.2.20-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:046e83a8b160aff37e7034139a336b660b01dbfe58706f9d73f5cdc6b3460242"}, - {file = "regex-2020.2.20-cp37-cp37m-manylinux2010_i686.whl", hash = "sha256:b33ebcd0222c1d77e61dbcd04a9fd139359bded86803063d3d2d197b796c63ce"}, - {file = "regex-2020.2.20-cp37-cp37m-manylinux2010_x86_64.whl", hash = "sha256:bba52d72e16a554d1894a0cc74041da50eea99a8483e591a9edf1025a66843ab"}, - {file = "regex-2020.2.20-cp37-cp37m-win32.whl", hash = "sha256:01b2d70cbaed11f72e57c1cfbaca71b02e3b98f739ce33f5f26f71859ad90431"}, - {file = "regex-2020.2.20-cp37-cp37m-win_amd64.whl", hash = "sha256:113309e819634f499d0006f6200700c8209a2a8bf6bd1bdc863a4d9d6776a5d1"}, - {file = "regex-2020.2.20-cp38-cp38-manylinux1_i686.whl", hash = "sha256:25f4ce26b68425b80a233ce7b6218743c71cf7297dbe02feab1d711a2bf90045"}, - {file = "regex-2020.2.20-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:9b64a4cc825ec4df262050c17e18f60252cdd94742b4ba1286bcfe481f1c0f26"}, - {file = "regex-2020.2.20-cp38-cp38-manylinux2010_i686.whl", hash = "sha256:9ff16d994309b26a1cdf666a6309c1ef51ad4f72f99d3392bcd7b7139577a1f2"}, - {file = "regex-2020.2.20-cp38-cp38-manylinux2010_x86_64.whl", hash = "sha256:c7f58a0e0e13fb44623b65b01052dae8e820ed9b8b654bb6296bc9c41f571b70"}, - {file = "regex-2020.2.20-cp38-cp38-win32.whl", hash = "sha256:200539b5124bc4721247a823a47d116a7a23e62cc6695744e3eb5454a8888e6d"}, - {file = "regex-2020.2.20-cp38-cp38-win_amd64.whl", hash = "sha256:7f78f963e62a61e294adb6ff5db901b629ef78cb2a1cfce3cf4eeba80c1c67aa"}, - {file = "regex-2020.2.20.tar.gz", hash = "sha256:9e9624440d754733eddbcd4614378c18713d2d9d0dc647cf9c72f64e39671be5"}, + {file = "regex-2020.4.4-cp27-cp27m-win32.whl", hash = "sha256:90742c6ff121a9c5b261b9b215cb476eea97df98ea82037ec8ac95d1be7a034f"}, + {file = "regex-2020.4.4-cp27-cp27m-win_amd64.whl", hash = "sha256:24f4f4062eb16c5bbfff6a22312e8eab92c2c99c51a02e39b4eae54ce8255cd1"}, + {file = "regex-2020.4.4-cp36-cp36m-manylinux1_i686.whl", hash = "sha256:08119f707f0ebf2da60d2f24c2f39ca616277bb67ef6c92b72cbf90cbe3a556b"}, + {file = "regex-2020.4.4-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:c9423a150d3a4fc0f3f2aae897a59919acd293f4cb397429b120a5fcd96ea3db"}, + {file = "regex-2020.4.4-cp36-cp36m-manylinux2010_i686.whl", hash = "sha256:c087bff162158536387c53647411db09b6ee3f9603c334c90943e97b1052a156"}, + {file = "regex-2020.4.4-cp36-cp36m-manylinux2010_x86_64.whl", hash = "sha256:1cbe0fa0b7f673400eb29e9ef41d4f53638f65f9a2143854de6b1ce2899185c3"}, + {file = "regex-2020.4.4-cp36-cp36m-win32.whl", hash = "sha256:0ce9537396d8f556bcfc317c65b6a0705320701e5ce511f05fc04421ba05b8a8"}, + {file = "regex-2020.4.4-cp36-cp36m-win_amd64.whl", hash = "sha256:7e1037073b1b7053ee74c3c6c0ada80f3501ec29d5f46e42669378eae6d4405a"}, + {file = "regex-2020.4.4-cp37-cp37m-manylinux1_i686.whl", hash = "sha256:4385f12aa289d79419fede43f979e372f527892ac44a541b5446617e4406c468"}, + {file = "regex-2020.4.4-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:a58dd45cb865be0ce1d5ecc4cfc85cd8c6867bea66733623e54bd95131f473b6"}, + {file = "regex-2020.4.4-cp37-cp37m-manylinux2010_i686.whl", hash = "sha256:ccccdd84912875e34c5ad2d06e1989d890d43af6c2242c6fcfa51556997af6cd"}, + {file = "regex-2020.4.4-cp37-cp37m-manylinux2010_x86_64.whl", hash = "sha256:ea4adf02d23b437684cd388d557bf76e3afa72f7fed5bbc013482cc00c816948"}, + {file = "regex-2020.4.4-cp37-cp37m-win32.whl", hash = "sha256:2294f8b70e058a2553cd009df003a20802ef75b3c629506be20687df0908177e"}, + {file = "regex-2020.4.4-cp37-cp37m-win_amd64.whl", hash = "sha256:e91ba11da11cf770f389e47c3f5c30473e6d85e06d7fd9dcba0017d2867aab4a"}, + {file = "regex-2020.4.4-cp38-cp38-manylinux1_i686.whl", hash = "sha256:5635cd1ed0a12b4c42cce18a8d2fb53ff13ff537f09de5fd791e97de27b6400e"}, + {file = "regex-2020.4.4-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:23069d9c07e115537f37270d1d5faea3e0bdded8279081c4d4d607a2ad393683"}, + {file = "regex-2020.4.4-cp38-cp38-manylinux2010_i686.whl", hash = "sha256:c162a21e0da33eb3d31a3ac17a51db5e634fc347f650d271f0305d96601dc15b"}, + {file = "regex-2020.4.4-cp38-cp38-manylinux2010_x86_64.whl", hash = "sha256:fb95debbd1a824b2c4376932f2216cc186912e389bdb0e27147778cf6acb3f89"}, + {file = "regex-2020.4.4-cp38-cp38-win32.whl", hash = "sha256:2a3bf8b48f8e37c3a40bb3f854bf0121c194e69a650b209628d951190b862de3"}, + {file = "regex-2020.4.4-cp38-cp38-win_amd64.whl", hash = "sha256:5bfed051dbff32fd8945eccca70f5e22b55e4148d2a8a45141a3b053d6455ae3"}, + {file = "regex-2020.4.4.tar.gz", hash = "sha256:295badf61a51add2d428a46b8580309c520d8b26e769868b922750cf3ce67142"}, ] six = [ {file = "six-1.14.0-py2.py3-none-any.whl", hash = "sha256:8f3cd2e254d8f793e7f3d6d9df77b92252b52637291d0f0da013c76ea2724b6c"}, @@ -1397,9 +1392,9 @@ typed-ast = [ {file = "typed_ast-1.4.1.tar.gz", hash = "sha256:8c8aaad94455178e3187ab22c8b01a3837f8ee50e09cf31f1ba129eb293ec30b"}, ] typing-extensions = [ - {file = "typing_extensions-3.7.4.1-py2-none-any.whl", hash = "sha256:910f4656f54de5993ad9304959ce9bb903f90aadc7c67a0bef07e678014e892d"}, - {file = "typing_extensions-3.7.4.1-py3-none-any.whl", hash = "sha256:cf8b63fedea4d89bab840ecbb93e75578af28f76f66c35889bd7065f5af88575"}, - {file = "typing_extensions-3.7.4.1.tar.gz", hash = "sha256:091ecc894d5e908ac75209f10d5b4f118fbdb2eb1ede6a63544054bb1edb41f2"}, + {file = "typing_extensions-3.7.4.2-py2-none-any.whl", hash = "sha256:f8d2bd89d25bc39dabe7d23df520442fa1d8969b82544370e03d88b5a591c392"}, + {file = "typing_extensions-3.7.4.2-py3-none-any.whl", hash = "sha256:6e95524d8a547a91e08f404ae485bbb71962de46967e1b71a0cb89af24e761c5"}, + {file = "typing_extensions-3.7.4.2.tar.gz", hash = "sha256:79ee589a3caca649a9bfd2a8de4709837400dfa00b6cc81962a1e6a1815969ae"}, ] uvloop = [ {file = "uvloop-0.14.0-cp35-cp35m-macosx_10_11_x86_64.whl", hash = "sha256:08b109f0213af392150e2fe6f81d33261bb5ce968a288eb698aad4f46eb711bd"}, @@ -1413,8 +1408,8 @@ uvloop = [ {file = "uvloop-0.14.0.tar.gz", hash = "sha256:123ac9c0c7dd71464f58f1b4ee0bbd81285d96cdda8bc3519281b8973e3a461e"}, ] wcwidth = [ - {file = "wcwidth-0.1.8-py2.py3-none-any.whl", hash = "sha256:8fd29383f539be45b20bd4df0dc29c20ba48654a41e661925e612311e9f3c603"}, - {file = "wcwidth-0.1.8.tar.gz", hash = "sha256:f28b3e8a6483e5d49e7f8949ac1a78314e740333ae305b4ba5defd3e74fb37a8"}, + {file = "wcwidth-0.1.9-py2.py3-none-any.whl", hash = "sha256:cafe2186b3c009a04067022ce1dcd79cb38d8d65ee4f4791b8888d6599d1bbe1"}, + {file = "wcwidth-0.1.9.tar.gz", hash = "sha256:ee73862862a156bf77ff92b09034fc4825dd3af9cf81bc5b360668d425f3c5f1"}, ] yarl = [ {file = "yarl-1.4.2-cp35-cp35m-macosx_10_13_x86_64.whl", hash = "sha256:3ce3d4f7c6b69c4e4f0704b32eca8123b9c58ae91af740481aa57d7857b5e41b"}, diff --git a/pyproject.toml b/pyproject.toml index 4ee980ee..00a0d827 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "aiogram" -version = "3.0.0-alpha.2" +version = "3.0.0-alpha.3" description = "Modern and fully asynchronous framework for Telegram Bot API" authors = ["Alex Root Junior "] license = "MIT" @@ -25,6 +25,7 @@ classifiers = [ "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", "Topic :: Software Development :: Libraries :: Application Frameworks", "Framework :: AsyncIO", "Typing :: Typed", diff --git a/tests/test_api/test_methods/test_get_my_commands.py b/tests/test_api/test_methods/test_get_my_commands.py new file mode 100644 index 00000000..0cca2287 --- /dev/null +++ b/tests/test_api/test_methods/test_get_my_commands.py @@ -0,0 +1,27 @@ +from typing import List + +import pytest + +from aiogram.api.methods import GetMyCommands, Request +from aiogram.api.types import BotCommand +from tests.mocked_bot import MockedBot + + +class TestGetMyCommands: + @pytest.mark.asyncio + async def test_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(GetMyCommands, ok=True, result=None) + + response: List[BotCommand] = await GetMyCommands() + request: Request = bot.get_request() + assert request.method == "getMyCommands" + assert response == prepare_result.result + + @pytest.mark.asyncio + async def test_bot_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(GetMyCommands, ok=True, result=None) + + response: List[BotCommand] = await bot.get_my_commands() + request: Request = bot.get_request() + assert request.method == "getMyCommands" + assert response == prepare_result.result diff --git a/tests/test_api/test_methods/test_send_dice.py b/tests/test_api/test_methods/test_send_dice.py new file mode 100644 index 00000000..1594cda4 --- /dev/null +++ b/tests/test_api/test_methods/test_send_dice.py @@ -0,0 +1,25 @@ +import pytest + +from aiogram.api.methods import Request, SendDice +from aiogram.api.types import Message +from tests.mocked_bot import MockedBot + + +class TestSendDice: + @pytest.mark.asyncio + async def test_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(SendDice, ok=True, result=None) + + response: Message = await SendDice(chat_id=42) + request: Request = bot.get_request() + assert request.method == "sendDice" + assert response == prepare_result.result + + @pytest.mark.asyncio + async def test_bot_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(SendDice, ok=True, result=None) + + response: Message = await bot.send_dice(chat_id=42) + request: Request = bot.get_request() + assert request.method == "sendDice" + assert response == prepare_result.result diff --git a/tests/test_api/test_methods/test_set_my_commands.py b/tests/test_api/test_methods/test_set_my_commands.py new file mode 100644 index 00000000..ccf9f36b --- /dev/null +++ b/tests/test_api/test_methods/test_set_my_commands.py @@ -0,0 +1,28 @@ +import pytest + +from aiogram.api.methods import Request, SetMyCommands +from aiogram.api.types import BotCommand +from tests.mocked_bot import MockedBot + + +class TestSetMyCommands: + @pytest.mark.asyncio + async def test_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(SetMyCommands, ok=True, result=None) + + response: bool = await SetMyCommands( + commands=[BotCommand(command="command", description="Bot command")], + ) + request: Request = bot.get_request() + assert request.method == "setMyCommands" + assert response == prepare_result.result + + @pytest.mark.asyncio + async def test_bot_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(SetMyCommands, ok=True, result=None) + + response: bool = await bot.set_my_commands(commands=[],) + request: Request = bot.get_request() + assert request.method == "setMyCommands" + # assert request.data == {} + assert response == prepare_result.result diff --git a/tests/test_api/test_methods/test_set_sticker_set_thumb.py b/tests/test_api/test_methods/test_set_sticker_set_thumb.py new file mode 100644 index 00000000..affb49ee --- /dev/null +++ b/tests/test_api/test_methods/test_set_sticker_set_thumb.py @@ -0,0 +1,26 @@ +import pytest + +from aiogram.api.methods import Request, SetStickerSetThumb +from tests.mocked_bot import MockedBot + + +class TestSetStickerSetThumb: + @pytest.mark.asyncio + async def test_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(SetStickerSetThumb, ok=True, result=None) + + response: bool = await SetStickerSetThumb(name="test", user_id=42) + request: Request = bot.get_request() + assert request.method == "setStickerSetThumb" + # assert request.data == {} + assert response == prepare_result.result + + @pytest.mark.asyncio + async def test_bot_method(self, bot: MockedBot): + prepare_result = bot.add_result_for(SetStickerSetThumb, ok=True, result=None) + + response: bool = await bot.set_sticker_set_thumb(name="test", user_id=42) + request: Request = bot.get_request() + assert request.method == "setStickerSetThumb" + # assert request.data == {} + assert response == prepare_result.result diff --git a/tests/test_utils/test_helper.py b/tests/test_utils/test_helper.py index b468dc6b..8125ef60 100644 --- a/tests/test_utils/test_helper.py +++ b/tests/test_utils/test_helper.py @@ -46,6 +46,7 @@ class TestHelper: class NotAHelperSubclass: A = Item() + class TestHelperMode: def test_helper_mode_all(self): assert set(HelperMode.all()) == { diff --git a/tests/test_utils/test_mixins.py b/tests/test_utils/test_mixins.py index 1f4805bd..f9fbbade 100644 --- a/tests/test_utils/test_mixins.py +++ b/tests/test_utils/test_mixins.py @@ -1,9 +1,6 @@ import pytest -from aiogram.utils.mixins import ( - ContextInstanceMixin, - DataMixin, -) +from aiogram.utils.mixins import ContextInstanceMixin, DataMixin class ContextObject(ContextInstanceMixin["ContextObject"]):