Added support of Bot API 6.2 (#975)

* Added support of Bot API 6.2
* Added changelog
* Update tests
* Update API version
* Update dependencies, pre-commit config
* Added pytest config
This commit is contained in:
Alex Root Junior 2022-08-14 16:32:29 +03:00 committed by GitHub
parent 4315ecf1a2
commit c1341ba2df
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
78 changed files with 523 additions and 785 deletions

View file

@ -1 +1 @@
6.1 6.2

View file

@ -54,7 +54,7 @@ jobs:
- uses: actions/checkout@master - uses: actions/checkout@master
- name: Set up Python ${{ matrix.python-version }} on ${{ matrix.os }} - name: Set up Python ${{ matrix.python-version }} on ${{ matrix.os }}
uses: actions/setup-python@v2 uses: actions/setup-python@v4
with: with:
python-version: ${{ matrix.python-version }} python-version: ${{ matrix.python-version }}

View file

@ -4,12 +4,18 @@ repos:
- repo: https://github.com/pre-commit/pre-commit-hooks - repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.2.0 rev: v4.2.0
hooks: hooks:
- id: end-of-file-fixer - id: "trailing-whitespace"
- id: trailing-whitespace - id: "check-case-conflict"
- id: check-merge-conflict - id: "check-merge-conflict"
- id: "debug-statements"
- id: "end-of-file-fixer"
- id: "mixed-line-ending"
- id: "check-yaml"
- id: "detect-private-key"
- id: "check-toml"
- repo: https://github.com/psf/black - repo: https://github.com/psf/black
rev: 22.3.0 rev: 22.6.0
hooks: hooks:
- id: black - id: black
files: &files '^(aiogram|tests|examples)' files: &files '^(aiogram|tests|examples)'
@ -20,9 +26,15 @@ repos:
- id: isort - id: isort
additional_dependencies: [ toml ] additional_dependencies: [ toml ]
files: *files files: *files
- repo: https://gitlab.com/pycqa/flake8 - repo: https://gitlab.com/pycqa/flake8
rev: 3.9.2 rev: 3.9.2
hooks: hooks:
- id: flake8 - id: flake8
args: [ '--config=.flake8' ] args: [ '--config=.flake8' ]
files: *files files: *files
- repo: https://github.com/floatingpurr/sync_with_poetry
rev: 0.2.0
hooks:
- id: sync_with_poetry

1
CHANGES/975.misc.rst Normal file
View file

@ -0,0 +1 @@
Added full support of `Bot API 6.2 <https://core.telegram.org/bots/api-changelog#august-12-2022>`_

View file

@ -13,7 +13,7 @@ aiogram |beta badge|
:target: https://pypi.python.org/pypi/aiogram :target: https://pypi.python.org/pypi/aiogram
:alt: Supported python versions :alt: Supported python versions
.. image:: https://img.shields.io/badge/Telegram%20Bot%20API-6.1-blue.svg?logo=telegram .. image:: https://img.shields.io/badge/Telegram%20Bot%20API-6.2-blue.svg?logo=telegram
:target: https://core.telegram.org/bots/api :target: https://core.telegram.org/bots/api
:alt: Telegram Bot API :alt: Telegram Bot API

View file

@ -36,4 +36,4 @@ __all__ = (
) )
__version__ = "3.0.0b4" __version__ = "3.0.0b4"
__api_version__ = "6.1" __api_version__ = "6.2"

View file

@ -57,6 +57,7 @@ from ..methods import (
GetChatMemberCount, GetChatMemberCount,
GetChatMembersCount, GetChatMembersCount,
GetChatMenuButton, GetChatMenuButton,
GetCustomEmojiStickers,
GetFile, GetFile,
GetGameHighScores, GetGameHighScores,
GetMe, GetMe,
@ -152,6 +153,7 @@ from ..types import (
ReplyKeyboardRemove, ReplyKeyboardRemove,
SentWebAppMessage, SentWebAppMessage,
ShippingOption, ShippingOption,
Sticker,
StickerSet, StickerSet,
Update, Update,
User, User,
@ -290,7 +292,8 @@ class Bot(ContextInstanceMixin["Bot"]):
try: try:
if isinstance(destination, (str, pathlib.Path)): if isinstance(destination, (str, pathlib.Path)):
return await self.__download_file(destination=destination, stream=stream) await self.__download_file(destination=destination, stream=stream)
return None
else: else:
return await self.__download_file_binary_io( return await self.__download_file_binary_io(
destination=destination, seek=seek, stream=stream destination=destination, seek=seek, stream=stream
@ -383,7 +386,7 @@ class Bot(ContextInstanceMixin["Bot"]):
request_timeout: Optional[int] = None, request_timeout: Optional[int] = None,
) -> List[Update]: ) -> List[Update]:
""" """
Use this method to receive incoming updates using long polling (`wiki <https://en.wikipedia.org/wiki/Push_technology#Long_polling>`_). An Array of :class:`aiogram.types.update.Update` objects is returned. Use this method to receive incoming updates using long polling (`wiki <https://en.wikipedia.org/wiki/Push_technology#Long_polling>`_). Returns an Array of :class:`aiogram.types.update.Update` objects.
**Notes** **Notes**
@ -398,7 +401,7 @@ class Bot(ContextInstanceMixin["Bot"]):
:param timeout: Timeout in seconds for long polling. Defaults to 0, i.e. usual short polling. Should be positive, short polling should be used for testing purposes only. :param timeout: Timeout in seconds for long polling. Defaults to 0, i.e. usual short polling. Should be positive, short polling should be used for testing purposes only.
:param allowed_updates: A JSON-serialized list of the update types you want your bot to receive. For example, specify ['message', 'edited_channel_post', 'callback_query'] to only receive updates of these types. See :class:`aiogram.types.update.Update` for a complete list of available update types. Specify an empty list to receive all update types except *chat_member* (default). If not specified, the previous setting will be used. :param allowed_updates: A JSON-serialized list of the update types you want your bot to receive. For example, specify ['message', 'edited_channel_post', 'callback_query'] to only receive updates of these types. See :class:`aiogram.types.update.Update` for a complete list of available update types. Specify an empty list to receive all update types except *chat_member* (default). If not specified, the previous setting will be used.
:param request_timeout: Request timeout :param request_timeout: Request timeout
:return: An Array of Update objects is returned. :return: Returns an Array of Update objects.
""" """
call = GetUpdates( call = GetUpdates(
offset=offset, offset=offset,
@ -570,7 +573,7 @@ class Bot(ContextInstanceMixin["Bot"]):
:param disable_notification: Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound. :param disable_notification: Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound.
:param protect_content: Protects the contents of the sent message from forwarding and saving :param protect_content: Protects the contents of the sent message from forwarding and saving
:param reply_to_message_id: If the message is a reply, ID of the original message :param reply_to_message_id: If the message is a reply, ID of the original message
:param allow_sending_without_reply: Pass :code:`True`, if the message should be sent even if the specified replied-to message is not found :param allow_sending_without_reply: Pass :code:`True` if the message should be sent even if the specified replied-to message is not found
:param reply_markup: Additional interface options. A JSON-serialized object for an `inline keyboard <https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating>`_, `custom reply keyboard <https://core.telegram.org/bots#keyboards>`_, instructions to remove reply keyboard or to force a reply from the user. :param reply_markup: Additional interface options. A JSON-serialized object for an `inline keyboard <https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating>`_, `custom reply keyboard <https://core.telegram.org/bots#keyboards>`_, instructions to remove reply keyboard or to force a reply from the user.
:param request_timeout: Request timeout :param request_timeout: Request timeout
:return: On success, the sent Message is returned. :return: On success, the sent Message is returned.
@ -638,7 +641,7 @@ class Bot(ContextInstanceMixin["Bot"]):
request_timeout: Optional[int] = None, request_timeout: Optional[int] = None,
) -> MessageId: ) -> MessageId:
""" """
Use this method to copy messages of any kind. Service messages and invoice messages can't be copied. The method is analogous to the method :class:`aiogram.methods.forward_message.ForwardMessage`, but the copied message doesn't have a link to the original message. Returns the :class:`aiogram.types.message_id.MessageId` of the sent message on success. Use this method to copy messages of any kind. Service messages and invoice messages can't be copied. A quiz :class:`aiogram.methods.poll.Poll` can be copied only if the value of the field *correct_option_id* is known to the bot. The method is analogous to the method :class:`aiogram.methods.forward_message.ForwardMessage`, but the copied message doesn't have a link to the original message. Returns the :class:`aiogram.types.message_id.MessageId` of the sent message on success.
Source: https://core.telegram.org/bots/api#copymessage Source: https://core.telegram.org/bots/api#copymessage
@ -651,7 +654,7 @@ class Bot(ContextInstanceMixin["Bot"]):
:param disable_notification: Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound. :param disable_notification: Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound.
:param protect_content: Protects the contents of the sent message from forwarding and saving :param protect_content: Protects the contents of the sent message from forwarding and saving
:param reply_to_message_id: If the message is a reply, ID of the original message :param reply_to_message_id: If the message is a reply, ID of the original message
:param allow_sending_without_reply: Pass :code:`True`, if the message should be sent even if the specified replied-to message is not found :param allow_sending_without_reply: Pass :code:`True` if the message should be sent even if the specified replied-to message is not found
:param reply_markup: Additional interface options. A JSON-serialized object for an `inline keyboard <https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating>`_, `custom reply keyboard <https://core.telegram.org/bots#keyboards>`_, instructions to remove reply keyboard or to force a reply from the user. :param reply_markup: Additional interface options. A JSON-serialized object for an `inline keyboard <https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating>`_, `custom reply keyboard <https://core.telegram.org/bots#keyboards>`_, instructions to remove reply keyboard or to force a reply from the user.
:param request_timeout: Request timeout :param request_timeout: Request timeout
:return: Returns the MessageId of the sent message on success. :return: Returns the MessageId of the sent message on success.
@ -700,7 +703,7 @@ class Bot(ContextInstanceMixin["Bot"]):
:param disable_notification: Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound. :param disable_notification: Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound.
:param protect_content: Protects the contents of the sent message from forwarding and saving :param protect_content: Protects the contents of the sent message from forwarding and saving
:param reply_to_message_id: If the message is a reply, ID of the original message :param reply_to_message_id: If the message is a reply, ID of the original message
:param allow_sending_without_reply: Pass :code:`True`, if the message should be sent even if the specified replied-to message is not found :param allow_sending_without_reply: Pass :code:`True` if the message should be sent even if the specified replied-to message is not found
:param reply_markup: Additional interface options. A JSON-serialized object for an `inline keyboard <https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating>`_, `custom reply keyboard <https://core.telegram.org/bots#keyboards>`_, instructions to remove reply keyboard or to force a reply from the user. :param reply_markup: Additional interface options. A JSON-serialized object for an `inline keyboard <https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating>`_, `custom reply keyboard <https://core.telegram.org/bots#keyboards>`_, instructions to remove reply keyboard or to force a reply from the user.
:param request_timeout: Request timeout :param request_timeout: Request timeout
:return: On success, the sent Message is returned. :return: On success, the sent Message is returned.
@ -757,7 +760,7 @@ class Bot(ContextInstanceMixin["Bot"]):
:param disable_notification: Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound. :param disable_notification: Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound.
:param protect_content: Protects the contents of the sent message from forwarding and saving :param protect_content: Protects the contents of the sent message from forwarding and saving
:param reply_to_message_id: If the message is a reply, ID of the original message :param reply_to_message_id: If the message is a reply, ID of the original message
:param allow_sending_without_reply: Pass :code:`True`, if the message should be sent even if the specified replied-to message is not found :param allow_sending_without_reply: Pass :code:`True` if the message should be sent even if the specified replied-to message is not found
:param reply_markup: Additional interface options. A JSON-serialized object for an `inline keyboard <https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating>`_, `custom reply keyboard <https://core.telegram.org/bots#keyboards>`_, instructions to remove reply keyboard or to force a reply from the user. :param reply_markup: Additional interface options. A JSON-serialized object for an `inline keyboard <https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating>`_, `custom reply keyboard <https://core.telegram.org/bots#keyboards>`_, instructions to remove reply keyboard or to force a reply from the user.
:param request_timeout: Request timeout :param request_timeout: Request timeout
:return: On success, the sent Message is returned. :return: On success, the sent Message is returned.
@ -813,7 +816,7 @@ class Bot(ContextInstanceMixin["Bot"]):
:param disable_notification: Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound. :param disable_notification: Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound.
:param protect_content: Protects the contents of the sent message from forwarding and saving :param protect_content: Protects the contents of the sent message from forwarding and saving
:param reply_to_message_id: If the message is a reply, ID of the original message :param reply_to_message_id: If the message is a reply, ID of the original message
:param allow_sending_without_reply: Pass :code:`True`, if the message should be sent even if the specified replied-to message is not found :param allow_sending_without_reply: Pass :code:`True` if the message should be sent even if the specified replied-to message is not found
:param reply_markup: Additional interface options. A JSON-serialized object for an `inline keyboard <https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating>`_, `custom reply keyboard <https://core.telegram.org/bots#keyboards>`_, instructions to remove reply keyboard or to force a reply from the user. :param reply_markup: Additional interface options. A JSON-serialized object for an `inline keyboard <https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating>`_, `custom reply keyboard <https://core.telegram.org/bots#keyboards>`_, instructions to remove reply keyboard or to force a reply from the user.
:param request_timeout: Request timeout :param request_timeout: Request timeout
:return: On success, the sent Message is returned. :return: On success, the sent Message is returned.
@ -869,11 +872,11 @@ class Bot(ContextInstanceMixin["Bot"]):
:param caption: Video caption (may also be used when resending videos by *file_id*), 0-1024 characters after entities parsing :param caption: Video caption (may also be used when resending videos by *file_id*), 0-1024 characters after entities parsing
:param parse_mode: Mode for parsing entities in the video caption. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details. :param parse_mode: Mode for parsing entities in the video caption. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details.
:param caption_entities: A JSON-serialized list of special entities that appear in the caption, which can be specified instead of *parse_mode* :param caption_entities: A JSON-serialized list of special entities that appear in the caption, which can be specified instead of *parse_mode*
:param supports_streaming: Pass :code:`True`, if the uploaded video is suitable for streaming :param supports_streaming: Pass :code:`True` if the uploaded video is suitable for streaming
:param disable_notification: Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound. :param disable_notification: Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound.
:param protect_content: Protects the contents of the sent message from forwarding and saving :param protect_content: Protects the contents of the sent message from forwarding and saving
:param reply_to_message_id: If the message is a reply, ID of the original message :param reply_to_message_id: If the message is a reply, ID of the original message
:param allow_sending_without_reply: Pass :code:`True`, if the message should be sent even if the specified replied-to message is not found :param allow_sending_without_reply: Pass :code:`True` if the message should be sent even if the specified replied-to message is not found
:param reply_markup: Additional interface options. A JSON-serialized object for an `inline keyboard <https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating>`_, `custom reply keyboard <https://core.telegram.org/bots#keyboards>`_, instructions to remove reply keyboard or to force a reply from the user. :param reply_markup: Additional interface options. A JSON-serialized object for an `inline keyboard <https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating>`_, `custom reply keyboard <https://core.telegram.org/bots#keyboards>`_, instructions to remove reply keyboard or to force a reply from the user.
:param request_timeout: Request timeout :param request_timeout: Request timeout
:return: On success, the sent Message is returned. :return: On success, the sent Message is returned.
@ -934,7 +937,7 @@ class Bot(ContextInstanceMixin["Bot"]):
:param disable_notification: Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound. :param disable_notification: Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound.
:param protect_content: Protects the contents of the sent message from forwarding and saving :param protect_content: Protects the contents of the sent message from forwarding and saving
:param reply_to_message_id: If the message is a reply, ID of the original message :param reply_to_message_id: If the message is a reply, ID of the original message
:param allow_sending_without_reply: Pass :code:`True`, if the message should be sent even if the specified replied-to message is not found :param allow_sending_without_reply: Pass :code:`True` if the message should be sent even if the specified replied-to message is not found
:param reply_markup: Additional interface options. A JSON-serialized object for an `inline keyboard <https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating>`_, `custom reply keyboard <https://core.telegram.org/bots#keyboards>`_, instructions to remove reply keyboard or to force a reply from the user. :param reply_markup: Additional interface options. A JSON-serialized object for an `inline keyboard <https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating>`_, `custom reply keyboard <https://core.telegram.org/bots#keyboards>`_, instructions to remove reply keyboard or to force a reply from the user.
:param request_timeout: Request timeout :param request_timeout: Request timeout
:return: On success, the sent Message is returned. :return: On success, the sent Message is returned.
@ -988,7 +991,7 @@ class Bot(ContextInstanceMixin["Bot"]):
:param disable_notification: Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound. :param disable_notification: Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound.
:param protect_content: Protects the contents of the sent message from forwarding and saving :param protect_content: Protects the contents of the sent message from forwarding and saving
:param reply_to_message_id: If the message is a reply, ID of the original message :param reply_to_message_id: If the message is a reply, ID of the original message
:param allow_sending_without_reply: Pass :code:`True`, if the message should be sent even if the specified replied-to message is not found :param allow_sending_without_reply: Pass :code:`True` if the message should be sent even if the specified replied-to message is not found
:param reply_markup: Additional interface options. A JSON-serialized object for an `inline keyboard <https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating>`_, `custom reply keyboard <https://core.telegram.org/bots#keyboards>`_, instructions to remove reply keyboard or to force a reply from the user. :param reply_markup: Additional interface options. A JSON-serialized object for an `inline keyboard <https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating>`_, `custom reply keyboard <https://core.telegram.org/bots#keyboards>`_, instructions to remove reply keyboard or to force a reply from the user.
:param request_timeout: Request timeout :param request_timeout: Request timeout
:return: On success, the sent Message is returned. :return: On success, the sent Message is returned.
@ -1037,7 +1040,7 @@ class Bot(ContextInstanceMixin["Bot"]):
:param disable_notification: Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound. :param disable_notification: Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound.
:param protect_content: Protects the contents of the sent message from forwarding and saving :param protect_content: Protects the contents of the sent message from forwarding and saving
:param reply_to_message_id: If the message is a reply, ID of the original message :param reply_to_message_id: If the message is a reply, ID of the original message
:param allow_sending_without_reply: Pass :code:`True`, if the message should be sent even if the specified replied-to message is not found :param allow_sending_without_reply: Pass :code:`True` if the message should be sent even if the specified replied-to message is not found
:param reply_markup: Additional interface options. A JSON-serialized object for an `inline keyboard <https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating>`_, `custom reply keyboard <https://core.telegram.org/bots#keyboards>`_, instructions to remove reply keyboard or to force a reply from the user. :param reply_markup: Additional interface options. A JSON-serialized object for an `inline keyboard <https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating>`_, `custom reply keyboard <https://core.telegram.org/bots#keyboards>`_, instructions to remove reply keyboard or to force a reply from the user.
:param request_timeout: Request timeout :param request_timeout: Request timeout
:return: On success, the sent Message is returned. :return: On success, the sent Message is returned.
@ -1076,7 +1079,7 @@ class Bot(ContextInstanceMixin["Bot"]):
:param disable_notification: Sends messages `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound. :param disable_notification: Sends messages `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound.
:param protect_content: Protects the contents of the sent messages from forwarding and saving :param protect_content: Protects the contents of the sent messages from forwarding and saving
:param reply_to_message_id: If the messages are a reply, ID of the original message :param reply_to_message_id: If the messages are a reply, ID of the original message
:param allow_sending_without_reply: Pass :code:`True`, if the message should be sent even if the specified replied-to message is not found :param allow_sending_without_reply: Pass :code:`True` if the message should be sent even if the specified replied-to message is not found
:param request_timeout: Request timeout :param request_timeout: Request timeout
:return: On success, an array of Messages that were sent is returned. :return: On success, an array of Messages that were sent is returned.
""" """
@ -1123,7 +1126,7 @@ class Bot(ContextInstanceMixin["Bot"]):
:param disable_notification: Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound. :param disable_notification: Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound.
:param protect_content: Protects the contents of the sent message from forwarding and saving :param protect_content: Protects the contents of the sent message from forwarding and saving
:param reply_to_message_id: If the message is a reply, ID of the original message :param reply_to_message_id: If the message is a reply, ID of the original message
:param allow_sending_without_reply: Pass :code:`True`, if the message should be sent even if the specified replied-to message is not found :param allow_sending_without_reply: Pass :code:`True` if the message should be sent even if the specified replied-to message is not found
:param reply_markup: Additional interface options. A JSON-serialized object for an `inline keyboard <https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating>`_, `custom reply keyboard <https://core.telegram.org/bots#keyboards>`_, instructions to remove reply keyboard or to force a reply from the user. :param reply_markup: Additional interface options. A JSON-serialized object for an `inline keyboard <https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating>`_, `custom reply keyboard <https://core.telegram.org/bots#keyboards>`_, instructions to remove reply keyboard or to force a reply from the user.
:param request_timeout: Request timeout :param request_timeout: Request timeout
:return: On success, the sent Message is returned. :return: On success, the sent Message is returned.
@ -1254,7 +1257,7 @@ class Bot(ContextInstanceMixin["Bot"]):
:param disable_notification: Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound. :param disable_notification: Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound.
:param protect_content: Protects the contents of the sent message from forwarding and saving :param protect_content: Protects the contents of the sent message from forwarding and saving
:param reply_to_message_id: If the message is a reply, ID of the original message :param reply_to_message_id: If the message is a reply, ID of the original message
:param allow_sending_without_reply: Pass :code:`True`, if the message should be sent even if the specified replied-to message is not found :param allow_sending_without_reply: Pass :code:`True` if the message should be sent even if the specified replied-to message is not found
:param reply_markup: Additional interface options. A JSON-serialized object for an `inline keyboard <https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating>`_, `custom reply keyboard <https://core.telegram.org/bots#keyboards>`_, instructions to remove reply keyboard or to force a reply from the user. :param reply_markup: Additional interface options. A JSON-serialized object for an `inline keyboard <https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating>`_, `custom reply keyboard <https://core.telegram.org/bots#keyboards>`_, instructions to remove reply keyboard or to force a reply from the user.
:param request_timeout: Request timeout :param request_timeout: Request timeout
:return: On success, the sent Message is returned. :return: On success, the sent Message is returned.
@ -1306,7 +1309,7 @@ class Bot(ContextInstanceMixin["Bot"]):
:param disable_notification: Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound. :param disable_notification: Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound.
:param protect_content: Protects the contents of the sent message from forwarding and saving :param protect_content: Protects the contents of the sent message from forwarding and saving
:param reply_to_message_id: If the message is a reply, ID of the original message :param reply_to_message_id: If the message is a reply, ID of the original message
:param allow_sending_without_reply: Pass :code:`True`, if the message should be sent even if the specified replied-to message is not found :param allow_sending_without_reply: Pass :code:`True` if the message should be sent even if the specified replied-to message is not found
:param reply_markup: Additional interface options. A JSON-serialized object for an `inline keyboard <https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating>`_, `custom reply keyboard <https://core.telegram.org/bots#keyboards>`_, instructions to remove keyboard or to force a reply from the user. :param reply_markup: Additional interface options. A JSON-serialized object for an `inline keyboard <https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating>`_, `custom reply keyboard <https://core.telegram.org/bots#keyboards>`_, instructions to remove keyboard or to force a reply from the user.
:param request_timeout: Request timeout :param request_timeout: Request timeout
:return: On success, the sent Message is returned. :return: On success, the sent Message is returned.
@ -1366,11 +1369,11 @@ class Bot(ContextInstanceMixin["Bot"]):
:param explanation_entities: A JSON-serialized list of special entities that appear in the poll explanation, which can be specified instead of *parse_mode* :param explanation_entities: A JSON-serialized list of special entities that appear in the poll explanation, which can be specified instead of *parse_mode*
:param open_period: Amount of time in seconds the poll will be active after creation, 5-600. Can't be used together with *close_date*. :param open_period: Amount of time in seconds the poll will be active after creation, 5-600. Can't be used together with *close_date*.
:param close_date: Point in time (Unix timestamp) when the poll will be automatically closed. Must be at least 5 and no more than 600 seconds in the future. Can't be used together with *open_period*. :param close_date: Point in time (Unix timestamp) when the poll will be automatically closed. Must be at least 5 and no more than 600 seconds in the future. Can't be used together with *open_period*.
:param is_closed: Pass :code:`True`, if the poll needs to be immediately closed. This can be useful for poll preview. :param is_closed: Pass :code:`True` if the poll needs to be immediately closed. This can be useful for poll preview.
:param disable_notification: Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound. :param disable_notification: Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound.
:param protect_content: Protects the contents of the sent message from forwarding and saving :param protect_content: Protects the contents of the sent message from forwarding and saving
:param reply_to_message_id: If the message is a reply, ID of the original message :param reply_to_message_id: If the message is a reply, ID of the original message
:param allow_sending_without_reply: Pass :code:`True`, if the message should be sent even if the specified replied-to message is not found :param allow_sending_without_reply: Pass :code:`True` if the message should be sent even if the specified replied-to message is not found
:param reply_markup: Additional interface options. A JSON-serialized object for an `inline keyboard <https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating>`_, `custom reply keyboard <https://core.telegram.org/bots#keyboards>`_, instructions to remove reply keyboard or to force a reply from the user. :param reply_markup: Additional interface options. A JSON-serialized object for an `inline keyboard <https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating>`_, `custom reply keyboard <https://core.telegram.org/bots#keyboards>`_, instructions to remove reply keyboard or to force a reply from the user.
:param request_timeout: Request timeout :param request_timeout: Request timeout
:return: On success, the sent Message is returned. :return: On success, the sent Message is returned.
@ -1420,7 +1423,7 @@ class Bot(ContextInstanceMixin["Bot"]):
:param disable_notification: Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound. :param disable_notification: Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound.
:param protect_content: Protects the contents of the sent message from forwarding :param protect_content: Protects the contents of the sent message from forwarding
:param reply_to_message_id: If the message is a reply, ID of the original message :param reply_to_message_id: If the message is a reply, ID of the original message
:param allow_sending_without_reply: Pass :code:`True`, if the message should be sent even if the specified replied-to message is not found :param allow_sending_without_reply: Pass :code:`True` if the message should be sent even if the specified replied-to message is not found
:param reply_markup: Additional interface options. A JSON-serialized object for an `inline keyboard <https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating>`_, `custom reply keyboard <https://core.telegram.org/bots#keyboards>`_, instructions to remove reply keyboard or to force a reply from the user. :param reply_markup: Additional interface options. A JSON-serialized object for an `inline keyboard <https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating>`_, `custom reply keyboard <https://core.telegram.org/bots#keyboards>`_, instructions to remove reply keyboard or to force a reply from the user.
:param request_timeout: Request timeout :param request_timeout: Request timeout
:return: On success, the sent Message is returned. :return: On success, the sent Message is returned.
@ -1647,17 +1650,17 @@ class Bot(ContextInstanceMixin["Bot"]):
:param chat_id: Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`) :param chat_id: Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)
:param user_id: Unique identifier of the target user :param user_id: Unique identifier of the target user
:param is_anonymous: Pass :code:`True`, if the administrator's presence in the chat is hidden :param is_anonymous: Pass :code:`True` if the administrator's presence in the chat is hidden
:param can_manage_chat: Pass :code:`True`, if the administrator can access the chat event log, chat statistics, message statistics in channels, see channel members, see anonymous administrators in supergroups and ignore slow mode. Implied by any other administrator privilege :param can_manage_chat: Pass :code:`True` if the administrator can access the chat event log, chat statistics, message statistics in channels, see channel members, see anonymous administrators in supergroups and ignore slow mode. Implied by any other administrator privilege
:param can_post_messages: Pass :code:`True`, if the administrator can create channel posts, channels only :param can_post_messages: Pass :code:`True` if the administrator can create channel posts, channels only
:param can_edit_messages: Pass :code:`True`, if the administrator can edit messages of other users and can pin messages, channels only :param can_edit_messages: Pass :code:`True` if the administrator can edit messages of other users and can pin messages, channels only
:param can_delete_messages: Pass :code:`True`, if the administrator can delete messages of other users :param can_delete_messages: Pass :code:`True` if the administrator can delete messages of other users
:param can_manage_video_chats: Pass :code:`True`, if the administrator can manage video chats :param can_manage_video_chats: Pass :code:`True` if the administrator can manage video chats
:param can_restrict_members: Pass :code:`True`, if the administrator can restrict, ban or unban chat members :param can_restrict_members: Pass :code:`True` if the administrator can restrict, ban or unban chat members
:param can_promote_members: Pass :code:`True`, if the administrator can add new administrators with a subset of their own privileges or demote administrators that he has promoted, directly or indirectly (promoted by administrators that were appointed by him) :param can_promote_members: Pass :code:`True` if the administrator can add new administrators with a subset of their own privileges or demote administrators that he has promoted, directly or indirectly (promoted by administrators that were appointed by him)
:param can_change_info: Pass :code:`True`, if the administrator can change chat title, photo and other settings :param can_change_info: Pass :code:`True` if the administrator can change chat title, photo and other settings
:param can_invite_users: Pass :code:`True`, if the administrator can invite new users to the chat :param can_invite_users: Pass :code:`True` if the administrator can invite new users to the chat
:param can_pin_messages: Pass :code:`True`, if the administrator can pin messages, supergroups only :param can_pin_messages: Pass :code:`True` if the administrator can pin messages, supergroups only
:param request_timeout: Request timeout :param request_timeout: Request timeout
:return: Returns True on success. :return: Returns True on success.
""" """
@ -2020,7 +2023,7 @@ class Bot(ContextInstanceMixin["Bot"]):
:param chat_id: Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`) :param chat_id: Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)
:param message_id: Identifier of a message to pin :param message_id: Identifier of a message to pin
:param disable_notification: Pass :code:`True`, if it is not necessary to send a notification to all chat members about the new pinned message. Notifications are always disabled in channels and private chats. :param disable_notification: Pass :code:`True` if it is not necessary to send a notification to all chat members about the new pinned message. Notifications are always disabled in channels and private chats.
:param request_timeout: Request timeout :param request_timeout: Request timeout
:return: Returns True on success. :return: Returns True on success.
""" """
@ -2125,16 +2128,13 @@ class Bot(ContextInstanceMixin["Bot"]):
] ]
]: ]:
""" """
Use this method to get a list of administrators in a chat. On success, returns an Array of :class:`aiogram.types.chat_member.ChatMember` objects that contains information about all chat administrators except other bots. If the chat is a group or a supergroup and no administrators were appointed, only the creator will be returned. Use this method to get a list of administrators in a chat, which aren't bots. Returns an Array of :class:`aiogram.types.chat_member.ChatMember` objects.
Source: https://core.telegram.org/bots/api#getchatadministrators Source: https://core.telegram.org/bots/api#getchatadministrators
:param chat_id: Unique identifier for the target chat or username of the target supergroup or channel (in the format :code:`@channelusername`) :param chat_id: Unique identifier for the target chat or username of the target supergroup or channel (in the format :code:`@channelusername`)
:param request_timeout: Request timeout :param request_timeout: Request timeout
:return: On success, returns an Array of ChatMember objects that contains information :return: Returns an Array of ChatMember objects.
about all chat administrators except other bots. If the chat is a group or a
supergroup and no administrators were appointed, only the creator will be
returned.
""" """
call = GetChatAdministrators( call = GetChatAdministrators(
chat_id=chat_id, chat_id=chat_id,
@ -2342,14 +2342,14 @@ class Bot(ContextInstanceMixin["Bot"]):
request_timeout: Optional[int] = None, request_timeout: Optional[int] = None,
) -> List[BotCommand]: ) -> List[BotCommand]:
""" """
Use this method to get the current list of the bot's commands for the given scope and user language. Returns Array of :class:`aiogram.types.bot_command.BotCommand` on success. If commands aren't set, an empty list is returned. Use this method to get the current list of the bot's commands for the given scope and user language. Returns an Array of :class:`aiogram.types.bot_command.BotCommand` objects. If commands aren't set, an empty list is returned.
Source: https://core.telegram.org/bots/api#getmycommands Source: https://core.telegram.org/bots/api#getmycommands
:param scope: A JSON-serialized object, describing scope of users. Defaults to :class:`aiogram.types.bot_command_scope_default.BotCommandScopeDefault`. :param scope: A JSON-serialized object, describing scope of users. Defaults to :class:`aiogram.types.bot_command_scope_default.BotCommandScopeDefault`.
:param language_code: A two-letter ISO 639-1 language code or an empty string :param language_code: A two-letter ISO 639-1 language code or an empty string
:param request_timeout: Request timeout :param request_timeout: Request timeout
:return: Returns Array of BotCommand on success. If commands aren't set, an empty list is :return: Returns an Array of BotCommand objects. If commands aren't set, an empty list is
returned. returned.
""" """
call = GetMyCommands( call = GetMyCommands(
@ -2676,7 +2676,7 @@ class Bot(ContextInstanceMixin["Bot"]):
:param disable_notification: Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound. :param disable_notification: Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound.
:param protect_content: Protects the contents of the sent message from forwarding and saving :param protect_content: Protects the contents of the sent message from forwarding and saving
:param reply_to_message_id: If the message is a reply, ID of the original message :param reply_to_message_id: If the message is a reply, ID of the original message
:param allow_sending_without_reply: Pass :code:`True`, if the message should be sent even if the specified replied-to message is not found :param allow_sending_without_reply: Pass :code:`True` if the message should be sent even if the specified replied-to message is not found
:param reply_markup: Additional interface options. A JSON-serialized object for an `inline keyboard <https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating>`_, `custom reply keyboard <https://core.telegram.org/bots#keyboards>`_, instructions to remove reply keyboard or to force a reply from the user. :param reply_markup: Additional interface options. A JSON-serialized object for an `inline keyboard <https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating>`_, `custom reply keyboard <https://core.telegram.org/bots#keyboards>`_, instructions to remove reply keyboard or to force a reply from the user.
:param request_timeout: Request timeout :param request_timeout: Request timeout
:return: On success, the sent Message is returned. :return: On success, the sent Message is returned.
@ -2711,6 +2711,25 @@ class Bot(ContextInstanceMixin["Bot"]):
) )
return await self(call, request_timeout=request_timeout) return await self(call, request_timeout=request_timeout)
async def get_custom_emoji_stickers(
self,
custom_emoji_ids: List[str],
request_timeout: Optional[int] = None,
) -> List[Sticker]:
"""
Use this method to get information about custom emoji stickers by their identifiers. Returns an Array of :class:`aiogram.types.sticker.Sticker` objects.
Source: https://core.telegram.org/bots/api#getcustomemojistickers
:param custom_emoji_ids: List of custom emoji identifiers. At most 200 custom emoji identifiers can be specified.
:param request_timeout: Request timeout
:return: Returns an Array of Sticker objects.
"""
call = GetCustomEmojiStickers(
custom_emoji_ids=custom_emoji_ids,
)
return await self(call, request_timeout=request_timeout)
async def upload_sticker_file( async def upload_sticker_file(
self, self,
user_id: int, user_id: int,
@ -2742,7 +2761,7 @@ class Bot(ContextInstanceMixin["Bot"]):
png_sticker: Optional[Union[InputFile, str]] = None, png_sticker: Optional[Union[InputFile, str]] = None,
tgs_sticker: Optional[InputFile] = None, tgs_sticker: Optional[InputFile] = None,
webm_sticker: Optional[InputFile] = None, webm_sticker: Optional[InputFile] = None,
contains_masks: Optional[bool] = None, sticker_type: Optional[str] = None,
mask_position: Optional[MaskPosition] = None, mask_position: Optional[MaskPosition] = None,
request_timeout: Optional[int] = None, request_timeout: Optional[int] = None,
) -> bool: ) -> bool:
@ -2758,7 +2777,7 @@ class Bot(ContextInstanceMixin["Bot"]):
: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. :ref:`More information on Sending Files » <sending-files>` :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. :ref:`More information on Sending Files » <sending-files>`
:param tgs_sticker: **TGS** animation with the sticker, uploaded using multipart/form-data. See `https://core.telegram.org/stickers#animated-sticker-requirements <https://core.telegram.org/stickers#animated-sticker-requirements>`_`https://core.telegram.org/stickers#animated-sticker-requirements <https://core.telegram.org/stickers#animated-sticker-requirements>`_ for technical requirements :param tgs_sticker: **TGS** animation with the sticker, uploaded using multipart/form-data. See `https://core.telegram.org/stickers#animated-sticker-requirements <https://core.telegram.org/stickers#animated-sticker-requirements>`_`https://core.telegram.org/stickers#animated-sticker-requirements <https://core.telegram.org/stickers#animated-sticker-requirements>`_ for technical requirements
:param webm_sticker: **WEBM** video with the sticker, uploaded using multipart/form-data. See `https://core.telegram.org/stickers#video-sticker-requirements <https://core.telegram.org/stickers#video-sticker-requirements>`_`https://core.telegram.org/stickers#video-sticker-requirements <https://core.telegram.org/stickers#video-sticker-requirements>`_ for technical requirements :param webm_sticker: **WEBM** video with the sticker, uploaded using multipart/form-data. See `https://core.telegram.org/stickers#video-sticker-requirements <https://core.telegram.org/stickers#video-sticker-requirements>`_`https://core.telegram.org/stickers#video-sticker-requirements <https://core.telegram.org/stickers#video-sticker-requirements>`_ for technical requirements
:param contains_masks: Pass :code:`True`, if a set of mask stickers should be created :param sticker_type: Type of stickers in the set, pass 'regular' or 'mask'. Custom emoji sticker sets can't be created via the Bot API at the moment. By default, a regular sticker set is created.
:param mask_position: A JSON-serialized object for position where the mask should be placed on faces :param mask_position: A JSON-serialized object for position where the mask should be placed on faces
:param request_timeout: Request timeout :param request_timeout: Request timeout
:return: Returns True on success. :return: Returns True on success.
@ -2771,7 +2790,7 @@ class Bot(ContextInstanceMixin["Bot"]):
png_sticker=png_sticker, png_sticker=png_sticker,
tgs_sticker=tgs_sticker, tgs_sticker=tgs_sticker,
webm_sticker=webm_sticker, webm_sticker=webm_sticker,
contains_masks=contains_masks, sticker_type=sticker_type,
mask_position=mask_position, mask_position=mask_position,
) )
return await self(call, request_timeout=request_timeout) return await self(call, request_timeout=request_timeout)
@ -2905,7 +2924,7 @@ class Bot(ContextInstanceMixin["Bot"]):
:param inline_query_id: Unique identifier for the answered query :param inline_query_id: Unique identifier for the answered query
:param results: A JSON-serialized array of results for the inline query :param results: A JSON-serialized array of results for the inline query
:param cache_time: The maximum amount of time in seconds that the result of the inline query may be cached on the server. Defaults to 300. :param cache_time: The maximum amount of time in seconds that the result of the inline query may be cached on the server. Defaults to 300.
:param is_personal: Pass :code:`True`, if results may be cached on the server side only for the user that sent the query. By default, results may be returned to any user who sends the same query :param is_personal: Pass :code:`True` if results may be cached on the server side only for the user that sent the query. By default, results may be returned to any user who sends the same query
:param next_offset: Pass the offset that a client should send in the next query with the same text to receive more results. Pass an empty string if there are no more results or if you don't support pagination. Offset length can't exceed 64 bytes. :param next_offset: Pass the offset that a client should send in the next query with the same text to receive more results. Pass an empty string if there are no more results or if you don't support pagination. Offset length can't exceed 64 bytes.
:param switch_pm_text: If passed, clients will display a button with specified text that switches the user to a private chat with the bot and sends the bot a start message with the parameter *switch_pm_parameter* :param switch_pm_text: If passed, clients will display a button with specified text that switches the user to a private chat with the bot and sends the bot a start message with the parameter *switch_pm_parameter*
:param switch_pm_parameter: `Deep-linking <https://core.telegram.org/bots#deep-linking>`_ parameter for the /start message sent to the bot when user presses the switch button. 1-64 characters, only :code:`A-Z`, :code:`a-z`, :code:`0-9`, :code:`_` and :code:`-` are allowed. :param switch_pm_parameter: `Deep-linking <https://core.telegram.org/bots#deep-linking>`_ parameter for the /start message sent to the bot when user presses the switch button. 1-64 characters, only :code:`A-Z`, :code:`a-z`, :code:`0-9`, :code:`_` and :code:`-` are allowed.
@ -3001,17 +3020,17 @@ class Bot(ContextInstanceMixin["Bot"]):
:param photo_size: Photo size in bytes :param photo_size: Photo size in bytes
:param photo_width: Photo width :param photo_width: Photo width
:param photo_height: Photo height :param photo_height: Photo height
:param need_name: Pass :code:`True`, if you require the user's full name to complete the order :param need_name: Pass :code:`True` if you require the user's full name to complete the order
:param need_phone_number: Pass :code:`True`, if you require the user's phone number to complete the order :param need_phone_number: Pass :code:`True` if you require the user's phone number to complete the order
:param need_email: Pass :code:`True`, if you require the user's email address to complete the order :param need_email: Pass :code:`True` if you require the user's email address to complete the order
:param need_shipping_address: Pass :code:`True`, if you require the user's shipping address to complete the order :param need_shipping_address: Pass :code:`True` if you require the user's shipping address to complete the order
:param send_phone_number_to_provider: Pass :code:`True`, if the user's phone number should be sent to provider :param send_phone_number_to_provider: Pass :code:`True` if the user's phone number should be sent to provider
:param send_email_to_provider: Pass :code:`True`, if the user's email address should be sent to provider :param send_email_to_provider: Pass :code:`True` if the user's email address should be sent to provider
:param is_flexible: Pass :code:`True`, if the final price depends on the shipping method :param is_flexible: Pass :code:`True` if the final price depends on the shipping method
:param disable_notification: Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound. :param disable_notification: Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound.
:param protect_content: Protects the contents of the sent message from forwarding and saving :param protect_content: Protects the contents of the sent message from forwarding and saving
:param reply_to_message_id: If the message is a reply, ID of the original message :param reply_to_message_id: If the message is a reply, ID of the original message
:param allow_sending_without_reply: Pass :code:`True`, if the message should be sent even if the specified replied-to message is not found :param allow_sending_without_reply: Pass :code:`True` if the message should be sent even if the specified replied-to message is not found
:param reply_markup: A JSON-serialized object for an `inline keyboard <https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating>`_. If empty, one 'Pay :code:`total price`' button will be shown. If not empty, the first button must be a Pay button. :param reply_markup: A JSON-serialized object for an `inline keyboard <https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating>`_. If empty, one 'Pay :code:`total price`' button will be shown. If not empty, the first button must be a Pay button.
:param request_timeout: Request timeout :param request_timeout: Request timeout
:return: On success, the sent Message is returned. :return: On success, the sent Message is returned.
@ -3089,13 +3108,13 @@ class Bot(ContextInstanceMixin["Bot"]):
:param photo_size: Photo size in bytes :param photo_size: Photo size in bytes
:param photo_width: Photo width :param photo_width: Photo width
:param photo_height: Photo height :param photo_height: Photo height
:param need_name: Pass :code:`True`, if you require the user's full name to complete the order :param need_name: Pass :code:`True` if you require the user's full name to complete the order
:param need_phone_number: Pass :code:`True`, if you require the user's phone number to complete the order :param need_phone_number: Pass :code:`True` if you require the user's phone number to complete the order
:param need_email: Pass :code:`True`, if you require the user's email address to complete the order :param need_email: Pass :code:`True` if you require the user's email address to complete the order
:param need_shipping_address: Pass :code:`True`, if you require the user's shipping address to complete the order :param need_shipping_address: Pass :code:`True` if you require the user's shipping address to complete the order
:param send_phone_number_to_provider: Pass :code:`True`, if the user's phone number should be sent to the provider :param send_phone_number_to_provider: Pass :code:`True` if the user's phone number should be sent to the provider
:param send_email_to_provider: Pass :code:`True`, if the user's email address should be sent to the provider :param send_email_to_provider: Pass :code:`True` if the user's email address should be sent to the provider
:param is_flexible: Pass :code:`True`, if the final price depends on the shipping method :param is_flexible: Pass :code:`True` if the final price depends on the shipping method
:param request_timeout: Request timeout :param request_timeout: Request timeout
:return: Returns the created invoice link as String on success. :return: Returns the created invoice link as String on success.
""" """
@ -3137,9 +3156,9 @@ class Bot(ContextInstanceMixin["Bot"]):
Source: https://core.telegram.org/bots/api#answershippingquery Source: https://core.telegram.org/bots/api#answershippingquery
:param shipping_query_id: Unique identifier for the query to be answered :param shipping_query_id: Unique identifier for the query to be answered
:param ok: Specify :code:`True` if delivery to the specified address is possible and False if there are any problems (for example, if delivery to the specified address is not possible) :param ok: Pass :code:`True` if delivery to the specified address is possible and :code:`False` if there are any problems (for example, if delivery to the specified address is not possible)
:param shipping_options: Required if *ok* is :code:`True`. A JSON-serialized array of available shipping options. :param shipping_options: Required if *ok* is :code:`True`. A JSON-serialized array of available shipping options.
:param error_message: Required if *ok* is False. Error message in human readable form that explains why it is impossible to complete the order (e.g. "Sorry, delivery to your desired address is unavailable'). Telegram will display this message to the user. :param error_message: Required if *ok* is :code:`False`. Error message in human readable form that explains why it is impossible to complete the order (e.g. "Sorry, delivery to your desired address is unavailable'). Telegram will display this message to the user.
:param request_timeout: Request timeout :param request_timeout: Request timeout
:return: On success, True is returned. :return: On success, True is returned.
""" """
@ -3232,7 +3251,7 @@ class Bot(ContextInstanceMixin["Bot"]):
:param disable_notification: Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound. :param disable_notification: Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound.
:param protect_content: Protects the contents of the sent message from forwarding and saving :param protect_content: Protects the contents of the sent message from forwarding and saving
:param reply_to_message_id: If the message is a reply, ID of the original message :param reply_to_message_id: If the message is a reply, ID of the original message
:param allow_sending_without_reply: Pass :code:`True`, if the message should be sent even if the specified replied-to message is not found :param allow_sending_without_reply: Pass :code:`True` if the message should be sent even if the specified replied-to message is not found
:param reply_markup: A JSON-serialized object for an `inline keyboard <https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating>`_. If empty, one 'Play game_title' button will be shown. If not empty, the first button must launch the game. :param reply_markup: A JSON-serialized object for an `inline keyboard <https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating>`_. If empty, one 'Play game_title' button will be shown. If not empty, the first button must launch the game.
:param request_timeout: Request timeout :param request_timeout: Request timeout
:return: On success, the sent Message is returned. :return: On success, the sent Message is returned.
@ -3266,8 +3285,8 @@ class Bot(ContextInstanceMixin["Bot"]):
:param user_id: User identifier :param user_id: User identifier
:param score: New score, must be non-negative :param score: New score, must be non-negative
:param force: Pass :code:`True`, if the high score is allowed to decrease. This can be useful when fixing mistakes or banning cheaters :param force: Pass :code:`True` if the high score is allowed to decrease. This can be useful when fixing mistakes or banning cheaters
:param disable_edit_message: Pass :code:`True`, if the game message should not be automatically edited to include the current scoreboard :param disable_edit_message: Pass :code:`True` if the game message should not be automatically edited to include the current scoreboard
:param chat_id: Required if *inline_message_id* is not specified. Unique identifier for the target chat :param chat_id: Required if *inline_message_id* is not specified. Unique identifier for the target chat
:param message_id: Required if *inline_message_id* is not specified. Identifier of the sent message :param message_id: Required if *inline_message_id* is not specified. Identifier of the sent message
:param inline_message_id: Required if *chat_id* and *message_id* are not specified. Identifier of the inline message :param inline_message_id: Required if *chat_id* and *message_id* are not specified. Identifier of the inline message
@ -3296,7 +3315,7 @@ class Bot(ContextInstanceMixin["Bot"]):
request_timeout: Optional[int] = None, request_timeout: Optional[int] = None,
) -> List[GameHighScore]: ) -> List[GameHighScore]:
""" """
Use this method to get data for high score tables. Will return the score of the specified user and several of their neighbors in a game. On success, returns an *Array* of :class:`aiogram.types.game_high_score.GameHighScore` objects. Use this method to get data for high score tables. Will return the score of the specified user and several of their neighbors in a game. Returns an Array of :class:`aiogram.types.game_high_score.GameHighScore` objects.
This method will currently return scores for the target user, plus two of their closest neighbors on each side. Will also return the top three users if the user and their neighbors are not among them. Please note that this behavior is subject to change. This method will currently return scores for the target user, plus two of their closest neighbors on each side. Will also return the top three users if the user and their neighbors are not among them. Please note that this behavior is subject to change.
@ -3308,10 +3327,10 @@ class Bot(ContextInstanceMixin["Bot"]):
:param inline_message_id: Required if *chat_id* and *message_id* are not specified. Identifier of the inline message :param inline_message_id: Required if *chat_id* and *message_id* are not specified. Identifier of the inline message
:param request_timeout: Request timeout :param request_timeout: Request timeout
:return: Will return the score of the specified user and several of their neighbors in a :return: Will return the score of the specified user and several of their neighbors in a
game. On success, returns an Array of GameHighScore objects. This method will game. Returns an Array of GameHighScore objects. This method will currently
currently return scores for the target user, plus two of their closest neighbors return scores for the target user, plus two of their closest neighbors on each
on each side. Will also return the top three users if the user and their side. Will also return the top three users if the user and their neighbors are
neighbors are not among them. not among them.
""" """
call = GetGameHighScores( call = GetGameHighScores(
user_id=user_id, user_id=user_id,

View file

@ -34,6 +34,7 @@ from .get_chat_member import GetChatMember
from .get_chat_member_count import GetChatMemberCount from .get_chat_member_count import GetChatMemberCount
from .get_chat_members_count import GetChatMembersCount from .get_chat_members_count import GetChatMembersCount
from .get_chat_menu_button import GetChatMenuButton from .get_chat_menu_button import GetChatMenuButton
from .get_custom_emoji_stickers import GetCustomEmojiStickers
from .get_file import GetFile from .get_file import GetFile
from .get_game_high_scores import GetGameHighScores from .get_game_high_scores import GetGameHighScores
from .get_me import GetMe from .get_me import GetMe
@ -168,6 +169,7 @@ __all__ = (
"DeleteMessage", "DeleteMessage",
"SendSticker", "SendSticker",
"GetStickerSet", "GetStickerSet",
"GetCustomEmojiStickers",
"UploadStickerFile", "UploadStickerFile",
"CreateNewStickerSet", "CreateNewStickerSet",
"AddStickerToSet", "AddStickerToSet",

View file

@ -27,7 +27,7 @@ class AnswerInlineQuery(TelegramMethod[bool]):
cache_time: Optional[int] = None cache_time: Optional[int] = None
"""The maximum amount of time in seconds that the result of the inline query may be cached on the server. Defaults to 300.""" """The maximum amount of time in seconds that the result of the inline query may be cached on the server. Defaults to 300."""
is_personal: Optional[bool] = None is_personal: Optional[bool] = None
"""Pass :code:`True`, if results may be cached on the server side only for the user that sent the query. By default, results may be returned to any user who sends the same query""" """Pass :code:`True` if results may be cached on the server side only for the user that sent the query. By default, results may be returned to any user who sends the same query"""
next_offset: Optional[str] = None next_offset: Optional[str] = None
"""Pass the offset that a client should send in the next query with the same text to receive more results. Pass an empty string if there are no more results or if you don't support pagination. Offset length can't exceed 64 bytes.""" """Pass the offset that a client should send in the next query with the same text to receive more results. Pass an empty string if there are no more results or if you don't support pagination. Offset length can't exceed 64 bytes."""
switch_pm_text: Optional[str] = None switch_pm_text: Optional[str] = None

View file

@ -21,11 +21,11 @@ class AnswerShippingQuery(TelegramMethod[bool]):
shipping_query_id: str shipping_query_id: str
"""Unique identifier for the query to be answered""" """Unique identifier for the query to be answered"""
ok: bool ok: bool
"""Specify :code:`True` if delivery to the specified address is possible and False if there are any problems (for example, if delivery to the specified address is not possible)""" """Pass :code:`True` if delivery to the specified address is possible and :code:`False` if there are any problems (for example, if delivery to the specified address is not possible)"""
shipping_options: Optional[List[ShippingOption]] = None shipping_options: Optional[List[ShippingOption]] = None
"""Required if *ok* is :code:`True`. A JSON-serialized array of available shipping options.""" """Required if *ok* is :code:`True`. A JSON-serialized array of available shipping options."""
error_message: Optional[str] = None error_message: Optional[str] = None
"""Required if *ok* is False. Error message in human readable form that explains why it is impossible to complete the order (e.g. "Sorry, delivery to your desired address is unavailable'). Telegram will display this message to the user.""" """Required if *ok* is :code:`False`. Error message in human readable form that explains why it is impossible to complete the order (e.g. "Sorry, delivery to your desired address is unavailable'). Telegram will display this message to the user."""
def build_request(self, bot: Bot) -> Request: def build_request(self, bot: Bot) -> Request:
data: Dict[str, Any] = self.dict() data: Dict[str, Any] = self.dict()

View file

@ -19,7 +19,7 @@ if TYPE_CHECKING:
class CopyMessage(TelegramMethod[MessageId]): class CopyMessage(TelegramMethod[MessageId]):
""" """
Use this method to copy messages of any kind. Service messages and invoice messages can't be copied. The method is analogous to the method :class:`aiogram.methods.forward_message.ForwardMessage`, but the copied message doesn't have a link to the original message. Returns the :class:`aiogram.types.message_id.MessageId` of the sent message on success. Use this method to copy messages of any kind. Service messages and invoice messages can't be copied. A quiz :class:`aiogram.methods.poll.Poll` can be copied only if the value of the field *correct_option_id* is known to the bot. The method is analogous to the method :class:`aiogram.methods.forward_message.ForwardMessage`, but the copied message doesn't have a link to the original message. Returns the :class:`aiogram.types.message_id.MessageId` of the sent message on success.
Source: https://core.telegram.org/bots/api#copymessage Source: https://core.telegram.org/bots/api#copymessage
""" """
@ -45,7 +45,7 @@ class CopyMessage(TelegramMethod[MessageId]):
reply_to_message_id: Optional[int] = None reply_to_message_id: Optional[int] = None
"""If the message is a reply, ID of the original message""" """If the message is a reply, ID of the original message"""
allow_sending_without_reply: Optional[bool] = None allow_sending_without_reply: Optional[bool] = None
"""Pass :code:`True`, if the message should be sent even if the specified replied-to message is not found""" """Pass :code:`True` if the message should be sent even if the specified replied-to message is not found"""
reply_markup: Optional[ reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply] Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
] = None ] = None

View file

@ -45,19 +45,19 @@ class CreateInvoiceLink(TelegramMethod[str]):
photo_height: Optional[int] = None photo_height: Optional[int] = None
"""Photo height""" """Photo height"""
need_name: Optional[bool] = None need_name: Optional[bool] = None
"""Pass :code:`True`, if you require the user's full name to complete the order""" """Pass :code:`True` if you require the user's full name to complete the order"""
need_phone_number: Optional[bool] = None need_phone_number: Optional[bool] = None
"""Pass :code:`True`, if you require the user's phone number to complete the order""" """Pass :code:`True` if you require the user's phone number to complete the order"""
need_email: Optional[bool] = None need_email: Optional[bool] = None
"""Pass :code:`True`, if you require the user's email address to complete the order""" """Pass :code:`True` if you require the user's email address to complete the order"""
need_shipping_address: Optional[bool] = None need_shipping_address: Optional[bool] = None
"""Pass :code:`True`, if you require the user's shipping address to complete the order""" """Pass :code:`True` if you require the user's shipping address to complete the order"""
send_phone_number_to_provider: Optional[bool] = None send_phone_number_to_provider: Optional[bool] = None
"""Pass :code:`True`, if the user's phone number should be sent to the provider""" """Pass :code:`True` if the user's phone number should be sent to the provider"""
send_email_to_provider: Optional[bool] = None send_email_to_provider: Optional[bool] = None
"""Pass :code:`True`, if the user's email address should be sent to the provider""" """Pass :code:`True` if the user's email address should be sent to the provider"""
is_flexible: Optional[bool] = None is_flexible: Optional[bool] = None
"""Pass :code:`True`, if the final price depends on the shipping method""" """Pass :code:`True` if the final price depends on the shipping method"""
def build_request(self, bot: Bot) -> Request: def build_request(self, bot: Bot) -> Request:
data: Dict[str, Any] = self.dict() data: Dict[str, Any] = self.dict()

View file

@ -32,8 +32,8 @@ class CreateNewStickerSet(TelegramMethod[bool]):
"""**TGS** animation with the sticker, uploaded using multipart/form-data. See `https://core.telegram.org/stickers#animated-sticker-requirements <https://core.telegram.org/stickers#animated-sticker-requirements>`_`https://core.telegram.org/stickers#animated-sticker-requirements <https://core.telegram.org/stickers#animated-sticker-requirements>`_ for technical requirements""" """**TGS** animation with the sticker, uploaded using multipart/form-data. See `https://core.telegram.org/stickers#animated-sticker-requirements <https://core.telegram.org/stickers#animated-sticker-requirements>`_`https://core.telegram.org/stickers#animated-sticker-requirements <https://core.telegram.org/stickers#animated-sticker-requirements>`_ for technical requirements"""
webm_sticker: Optional[InputFile] = None webm_sticker: Optional[InputFile] = None
"""**WEBM** video with the sticker, uploaded using multipart/form-data. See `https://core.telegram.org/stickers#video-sticker-requirements <https://core.telegram.org/stickers#video-sticker-requirements>`_`https://core.telegram.org/stickers#video-sticker-requirements <https://core.telegram.org/stickers#video-sticker-requirements>`_ for technical requirements""" """**WEBM** video with the sticker, uploaded using multipart/form-data. See `https://core.telegram.org/stickers#video-sticker-requirements <https://core.telegram.org/stickers#video-sticker-requirements>`_`https://core.telegram.org/stickers#video-sticker-requirements <https://core.telegram.org/stickers#video-sticker-requirements>`_ for technical requirements"""
contains_masks: Optional[bool] = None sticker_type: Optional[str] = None
"""Pass :code:`True`, if a set of mask stickers should be created""" """Type of stickers in the set, pass 'regular' or 'mask'. Custom emoji sticker sets can't be created via the Bot API at the moment. By default, a regular sticker set is created."""
mask_position: Optional[MaskPosition] = None mask_position: Optional[MaskPosition] = None
"""A JSON-serialized object for position where the mask should be placed on faces""" """A JSON-serialized object for position where the mask should be placed on faces"""

View file

@ -31,7 +31,7 @@ class GetChatAdministrators(
] ]
): ):
""" """
Use this method to get a list of administrators in a chat. On success, returns an Array of :class:`aiogram.types.chat_member.ChatMember` objects that contains information about all chat administrators except other bots. If the chat is a group or a supergroup and no administrators were appointed, only the creator will be returned. Use this method to get a list of administrators in a chat, which aren't bots. Returns an Array of :class:`aiogram.types.chat_member.ChatMember` objects.
Source: https://core.telegram.org/bots/api#getchatadministrators Source: https://core.telegram.org/bots/api#getchatadministrators
""" """

View file

@ -0,0 +1,27 @@
from __future__ import annotations
from typing import TYPE_CHECKING, Any, Dict, List
from ..types import Sticker
from .base import Request, TelegramMethod
if TYPE_CHECKING:
from ..client.bot import Bot
class GetCustomEmojiStickers(TelegramMethod[List[Sticker]]):
"""
Use this method to get information about custom emoji stickers by their identifiers. Returns an Array of :class:`aiogram.types.sticker.Sticker` objects.
Source: https://core.telegram.org/bots/api#getcustomemojistickers
"""
__returning__ = List[Sticker]
custom_emoji_ids: List[str]
"""List of custom emoji identifiers. At most 200 custom emoji identifiers can be specified."""
def build_request(self, bot: Bot) -> Request:
data: Dict[str, Any] = self.dict()
return Request(method="getCustomEmojiStickers", data=data)

View file

@ -11,7 +11,7 @@ if TYPE_CHECKING:
class GetGameHighScores(TelegramMethod[List[GameHighScore]]): class GetGameHighScores(TelegramMethod[List[GameHighScore]]):
""" """
Use this method to get data for high score tables. Will return the score of the specified user and several of their neighbors in a game. On success, returns an *Array* of :class:`aiogram.types.game_high_score.GameHighScore` objects. Use this method to get data for high score tables. Will return the score of the specified user and several of their neighbors in a game. Returns an Array of :class:`aiogram.types.game_high_score.GameHighScore` objects.
This method will currently return scores for the target user, plus two of their closest neighbors on each side. Will also return the top three users if the user and their neighbors are not among them. Please note that this behavior is subject to change. This method will currently return scores for the target user, plus two of their closest neighbors on each side. Will also return the top three users if the user and their neighbors are not among them. Please note that this behavior is subject to change.

View file

@ -11,7 +11,7 @@ if TYPE_CHECKING:
class GetMyCommands(TelegramMethod[List[BotCommand]]): class GetMyCommands(TelegramMethod[List[BotCommand]]):
""" """
Use this method to get the current list of the bot's commands for the given scope and user language. Returns Array of :class:`aiogram.types.bot_command.BotCommand` on success. If commands aren't set, an empty list is returned. Use this method to get the current list of the bot's commands for the given scope and user language. Returns an Array of :class:`aiogram.types.bot_command.BotCommand` objects. If commands aren't set, an empty list is returned.
Source: https://core.telegram.org/bots/api#getmycommands Source: https://core.telegram.org/bots/api#getmycommands
""" """

View file

@ -11,7 +11,7 @@ if TYPE_CHECKING:
class GetUpdates(TelegramMethod[List[Update]]): class GetUpdates(TelegramMethod[List[Update]]):
""" """
Use this method to receive incoming updates using long polling (`wiki <https://en.wikipedia.org/wiki/Push_technology#Long_polling>`_). An Array of :class:`aiogram.types.update.Update` objects is returned. Use this method to receive incoming updates using long polling (`wiki <https://en.wikipedia.org/wiki/Push_technology#Long_polling>`_). Returns an Array of :class:`aiogram.types.update.Update` objects.
**Notes** **Notes**

View file

@ -22,7 +22,7 @@ class PinChatMessage(TelegramMethod[bool]):
message_id: int message_id: int
"""Identifier of a message to pin""" """Identifier of a message to pin"""
disable_notification: Optional[bool] = None disable_notification: Optional[bool] = None
"""Pass :code:`True`, if it is not necessary to send a notification to all chat members about the new pinned message. Notifications are always disabled in channels and private chats.""" """Pass :code:`True` if it is not necessary to send a notification to all chat members about the new pinned message. Notifications are always disabled in channels and private chats."""
def build_request(self, bot: Bot) -> Request: def build_request(self, bot: Bot) -> Request:
data: Dict[str, Any] = self.dict() data: Dict[str, Any] = self.dict()

View file

@ -22,27 +22,27 @@ class PromoteChatMember(TelegramMethod[bool]):
user_id: int user_id: int
"""Unique identifier of the target user""" """Unique identifier of the target user"""
is_anonymous: Optional[bool] = None is_anonymous: Optional[bool] = None
"""Pass :code:`True`, if the administrator's presence in the chat is hidden""" """Pass :code:`True` if the administrator's presence in the chat is hidden"""
can_manage_chat: Optional[bool] = None can_manage_chat: Optional[bool] = None
"""Pass :code:`True`, if the administrator can access the chat event log, chat statistics, message statistics in channels, see channel members, see anonymous administrators in supergroups and ignore slow mode. Implied by any other administrator privilege""" """Pass :code:`True` if the administrator can access the chat event log, chat statistics, message statistics in channels, see channel members, see anonymous administrators in supergroups and ignore slow mode. Implied by any other administrator privilege"""
can_post_messages: Optional[bool] = None can_post_messages: Optional[bool] = None
"""Pass :code:`True`, if the administrator can create channel posts, channels only""" """Pass :code:`True` if the administrator can create channel posts, channels only"""
can_edit_messages: Optional[bool] = None can_edit_messages: Optional[bool] = None
"""Pass :code:`True`, if the administrator can edit messages of other users and can pin messages, channels only""" """Pass :code:`True` if the administrator can edit messages of other users and can pin messages, channels only"""
can_delete_messages: Optional[bool] = None can_delete_messages: Optional[bool] = None
"""Pass :code:`True`, if the administrator can delete messages of other users""" """Pass :code:`True` if the administrator can delete messages of other users"""
can_manage_video_chats: Optional[bool] = None can_manage_video_chats: Optional[bool] = None
"""Pass :code:`True`, if the administrator can manage video chats""" """Pass :code:`True` if the administrator can manage video chats"""
can_restrict_members: Optional[bool] = None can_restrict_members: Optional[bool] = None
"""Pass :code:`True`, if the administrator can restrict, ban or unban chat members""" """Pass :code:`True` if the administrator can restrict, ban or unban chat members"""
can_promote_members: Optional[bool] = None can_promote_members: Optional[bool] = None
"""Pass :code:`True`, if the administrator can add new administrators with a subset of their own privileges or demote administrators that he has promoted, directly or indirectly (promoted by administrators that were appointed by him)""" """Pass :code:`True` if the administrator can add new administrators with a subset of their own privileges or demote administrators that he has promoted, directly or indirectly (promoted by administrators that were appointed by him)"""
can_change_info: Optional[bool] = None can_change_info: Optional[bool] = None
"""Pass :code:`True`, if the administrator can change chat title, photo and other settings""" """Pass :code:`True` if the administrator can change chat title, photo and other settings"""
can_invite_users: Optional[bool] = None can_invite_users: Optional[bool] = None
"""Pass :code:`True`, if the administrator can invite new users to the chat""" """Pass :code:`True` if the administrator can invite new users to the chat"""
can_pin_messages: Optional[bool] = None can_pin_messages: Optional[bool] = None
"""Pass :code:`True`, if the administrator can pin messages, supergroups only""" """Pass :code:`True` if the administrator can pin messages, supergroups only"""
def build_request(self, bot: Bot) -> Request: def build_request(self, bot: Bot) -> Request:
data: Dict[str, Any] = self.dict() data: Dict[str, Any] = self.dict()

View file

@ -52,7 +52,7 @@ class SendAnimation(TelegramMethod[Message]):
reply_to_message_id: Optional[int] = None reply_to_message_id: Optional[int] = None
"""If the message is a reply, ID of the original message""" """If the message is a reply, ID of the original message"""
allow_sending_without_reply: Optional[bool] = None allow_sending_without_reply: Optional[bool] = None
"""Pass :code:`True`, if the message should be sent even if the specified replied-to message is not found""" """Pass :code:`True` if the message should be sent even if the specified replied-to message is not found"""
reply_markup: Optional[ reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply] Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
] = None ] = None

View file

@ -53,7 +53,7 @@ class SendAudio(TelegramMethod[Message]):
reply_to_message_id: Optional[int] = None reply_to_message_id: Optional[int] = None
"""If the message is a reply, ID of the original message""" """If the message is a reply, ID of the original message"""
allow_sending_without_reply: Optional[bool] = None allow_sending_without_reply: Optional[bool] = None
"""Pass :code:`True`, if the message should be sent even if the specified replied-to message is not found""" """Pass :code:`True` if the message should be sent even if the specified replied-to message is not found"""
reply_markup: Optional[ reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply] Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
] = None ] = None

View file

@ -41,7 +41,7 @@ class SendContact(TelegramMethod[Message]):
reply_to_message_id: Optional[int] = None reply_to_message_id: Optional[int] = None
"""If the message is a reply, ID of the original message""" """If the message is a reply, ID of the original message"""
allow_sending_without_reply: Optional[bool] = None allow_sending_without_reply: Optional[bool] = None
"""Pass :code:`True`, if the message should be sent even if the specified replied-to message is not found""" """Pass :code:`True` if the message should be sent even if the specified replied-to message is not found"""
reply_markup: Optional[ reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply] Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
] = None ] = None

View file

@ -35,7 +35,7 @@ class SendDice(TelegramMethod[Message]):
reply_to_message_id: Optional[int] = None reply_to_message_id: Optional[int] = None
"""If the message is a reply, ID of the original message""" """If the message is a reply, ID of the original message"""
allow_sending_without_reply: Optional[bool] = None allow_sending_without_reply: Optional[bool] = None
"""Pass :code:`True`, if the message should be sent even if the specified replied-to message is not found""" """Pass :code:`True` if the message should be sent even if the specified replied-to message is not found"""
reply_markup: Optional[ reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply] Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
] = None ] = None

View file

@ -48,7 +48,7 @@ class SendDocument(TelegramMethod[Message]):
reply_to_message_id: Optional[int] = None reply_to_message_id: Optional[int] = None
"""If the message is a reply, ID of the original message""" """If the message is a reply, ID of the original message"""
allow_sending_without_reply: Optional[bool] = None allow_sending_without_reply: Optional[bool] = None
"""Pass :code:`True`, if the message should be sent even if the specified replied-to message is not found""" """Pass :code:`True` if the message should be sent even if the specified replied-to message is not found"""
reply_markup: Optional[ reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply] Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
] = None ] = None

View file

@ -29,7 +29,7 @@ class SendGame(TelegramMethod[Message]):
reply_to_message_id: Optional[int] = None reply_to_message_id: Optional[int] = None
"""If the message is a reply, ID of the original message""" """If the message is a reply, ID of the original message"""
allow_sending_without_reply: Optional[bool] = None allow_sending_without_reply: Optional[bool] = None
"""Pass :code:`True`, if the message should be sent even if the specified replied-to message is not found""" """Pass :code:`True` if the message should be sent even if the specified replied-to message is not found"""
reply_markup: Optional[InlineKeyboardMarkup] = None reply_markup: Optional[InlineKeyboardMarkup] = None
"""A JSON-serialized object for an `inline keyboard <https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating>`_. If empty, one 'Play game_title' button will be shown. If not empty, the first button must launch the game.""" """A JSON-serialized object for an `inline keyboard <https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating>`_. If empty, one 'Play game_title' button will be shown. If not empty, the first button must launch the game."""

View file

@ -49,19 +49,19 @@ class SendInvoice(TelegramMethod[Message]):
photo_height: Optional[int] = None photo_height: Optional[int] = None
"""Photo height""" """Photo height"""
need_name: Optional[bool] = None need_name: Optional[bool] = None
"""Pass :code:`True`, if you require the user's full name to complete the order""" """Pass :code:`True` if you require the user's full name to complete the order"""
need_phone_number: Optional[bool] = None need_phone_number: Optional[bool] = None
"""Pass :code:`True`, if you require the user's phone number to complete the order""" """Pass :code:`True` if you require the user's phone number to complete the order"""
need_email: Optional[bool] = None need_email: Optional[bool] = None
"""Pass :code:`True`, if you require the user's email address to complete the order""" """Pass :code:`True` if you require the user's email address to complete the order"""
need_shipping_address: Optional[bool] = None need_shipping_address: Optional[bool] = None
"""Pass :code:`True`, if you require the user's shipping address to complete the order""" """Pass :code:`True` if you require the user's shipping address to complete the order"""
send_phone_number_to_provider: Optional[bool] = None send_phone_number_to_provider: Optional[bool] = None
"""Pass :code:`True`, if the user's phone number should be sent to provider""" """Pass :code:`True` if the user's phone number should be sent to provider"""
send_email_to_provider: Optional[bool] = None send_email_to_provider: Optional[bool] = None
"""Pass :code:`True`, if the user's email address should be sent to provider""" """Pass :code:`True` if the user's email address should be sent to provider"""
is_flexible: Optional[bool] = None is_flexible: Optional[bool] = None
"""Pass :code:`True`, if the final price depends on the shipping method""" """Pass :code:`True` if the final price depends on the shipping method"""
disable_notification: Optional[bool] = None disable_notification: Optional[bool] = None
"""Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound.""" """Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound."""
protect_content: Optional[bool] = None protect_content: Optional[bool] = None
@ -69,7 +69,7 @@ class SendInvoice(TelegramMethod[Message]):
reply_to_message_id: Optional[int] = None reply_to_message_id: Optional[int] = None
"""If the message is a reply, ID of the original message""" """If the message is a reply, ID of the original message"""
allow_sending_without_reply: Optional[bool] = None allow_sending_without_reply: Optional[bool] = None
"""Pass :code:`True`, if the message should be sent even if the specified replied-to message is not found""" """Pass :code:`True` if the message should be sent even if the specified replied-to message is not found"""
reply_markup: Optional[InlineKeyboardMarkup] = None reply_markup: Optional[InlineKeyboardMarkup] = None
"""A JSON-serialized object for an `inline keyboard <https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating>`_. If empty, one 'Pay :code:`total price`' button will be shown. If not empty, the first button must be a Pay button.""" """A JSON-serialized object for an `inline keyboard <https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating>`_. If empty, one 'Pay :code:`total price`' button will be shown. If not empty, the first button must be a Pay button."""

View file

@ -45,7 +45,7 @@ class SendLocation(TelegramMethod[Message]):
reply_to_message_id: Optional[int] = None reply_to_message_id: Optional[int] = None
"""If the message is a reply, ID of the original message""" """If the message is a reply, ID of the original message"""
allow_sending_without_reply: Optional[bool] = None allow_sending_without_reply: Optional[bool] = None
"""Pass :code:`True`, if the message should be sent even if the specified replied-to message is not found""" """Pass :code:`True` if the message should be sent even if the specified replied-to message is not found"""
reply_markup: Optional[ reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply] Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
] = None ] = None

View file

@ -36,7 +36,7 @@ class SendMediaGroup(TelegramMethod[List[Message]]):
reply_to_message_id: Optional[int] = None reply_to_message_id: Optional[int] = None
"""If the messages are a reply, ID of the original message""" """If the messages are a reply, ID of the original message"""
allow_sending_without_reply: Optional[bool] = None allow_sending_without_reply: Optional[bool] = None
"""Pass :code:`True`, if the message should be sent even if the specified replied-to message is not found""" """Pass :code:`True` if the message should be sent even if the specified replied-to message is not found"""
def build_request(self, bot: Bot) -> Request: def build_request(self, bot: Bot) -> Request:
data: Dict[str, Any] = self.dict() data: Dict[str, Any] = self.dict()

View file

@ -43,7 +43,7 @@ class SendMessage(TelegramMethod[Message]):
reply_to_message_id: Optional[int] = None reply_to_message_id: Optional[int] = None
"""If the message is a reply, ID of the original message""" """If the message is a reply, ID of the original message"""
allow_sending_without_reply: Optional[bool] = None allow_sending_without_reply: Optional[bool] = None
"""Pass :code:`True`, if the message should be sent even if the specified replied-to message is not found""" """Pass :code:`True` if the message should be sent even if the specified replied-to message is not found"""
reply_markup: Optional[ reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply] Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
] = None ] = None

View file

@ -44,7 +44,7 @@ class SendPhoto(TelegramMethod[Message]):
reply_to_message_id: Optional[int] = None reply_to_message_id: Optional[int] = None
"""If the message is a reply, ID of the original message""" """If the message is a reply, ID of the original message"""
allow_sending_without_reply: Optional[bool] = None allow_sending_without_reply: Optional[bool] = None
"""Pass :code:`True`, if the message should be sent even if the specified replied-to message is not found""" """Pass :code:`True` if the message should be sent even if the specified replied-to message is not found"""
reply_markup: Optional[ reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply] Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
] = None ] = None

View file

@ -52,7 +52,7 @@ class SendPoll(TelegramMethod[Message]):
close_date: Optional[Union[datetime.datetime, datetime.timedelta, int]] = None close_date: Optional[Union[datetime.datetime, datetime.timedelta, int]] = None
"""Point in time (Unix timestamp) when the poll will be automatically closed. Must be at least 5 and no more than 600 seconds in the future. Can't be used together with *open_period*.""" """Point in time (Unix timestamp) when the poll will be automatically closed. Must be at least 5 and no more than 600 seconds in the future. Can't be used together with *open_period*."""
is_closed: Optional[bool] = None is_closed: Optional[bool] = None
"""Pass :code:`True`, if the poll needs to be immediately closed. This can be useful for poll preview.""" """Pass :code:`True` if the poll needs to be immediately closed. This can be useful for poll preview."""
disable_notification: Optional[bool] = None disable_notification: Optional[bool] = None
"""Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound.""" """Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound."""
protect_content: Optional[bool] = None protect_content: Optional[bool] = None
@ -60,7 +60,7 @@ class SendPoll(TelegramMethod[Message]):
reply_to_message_id: Optional[int] = None reply_to_message_id: Optional[int] = None
"""If the message is a reply, ID of the original message""" """If the message is a reply, ID of the original message"""
allow_sending_without_reply: Optional[bool] = None allow_sending_without_reply: Optional[bool] = None
"""Pass :code:`True`, if the message should be sent even if the specified replied-to message is not found""" """Pass :code:`True` if the message should be sent even if the specified replied-to message is not found"""
reply_markup: Optional[ reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply] Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
] = None ] = None

View file

@ -36,7 +36,7 @@ class SendSticker(TelegramMethod[Message]):
reply_to_message_id: Optional[int] = None reply_to_message_id: Optional[int] = None
"""If the message is a reply, ID of the original message""" """If the message is a reply, ID of the original message"""
allow_sending_without_reply: Optional[bool] = None allow_sending_without_reply: Optional[bool] = None
"""Pass :code:`True`, if the message should be sent even if the specified replied-to message is not found""" """Pass :code:`True` if the message should be sent even if the specified replied-to message is not found"""
reply_markup: Optional[ reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply] Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
] = None ] = None

View file

@ -49,7 +49,7 @@ class SendVenue(TelegramMethod[Message]):
reply_to_message_id: Optional[int] = None reply_to_message_id: Optional[int] = None
"""If the message is a reply, ID of the original message""" """If the message is a reply, ID of the original message"""
allow_sending_without_reply: Optional[bool] = None allow_sending_without_reply: Optional[bool] = None
"""Pass :code:`True`, if the message should be sent even if the specified replied-to message is not found""" """Pass :code:`True` if the message should be sent even if the specified replied-to message is not found"""
reply_markup: Optional[ reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply] Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
] = None ] = None

View file

@ -46,7 +46,7 @@ class SendVideo(TelegramMethod[Message]):
caption_entities: Optional[List[MessageEntity]] = None caption_entities: Optional[List[MessageEntity]] = None
"""A JSON-serialized list of special entities that appear in the caption, which can be specified instead of *parse_mode*""" """A JSON-serialized list of special entities that appear in the caption, which can be specified instead of *parse_mode*"""
supports_streaming: Optional[bool] = None supports_streaming: Optional[bool] = None
"""Pass :code:`True`, if the uploaded video is suitable for streaming""" """Pass :code:`True` if the uploaded video is suitable for streaming"""
disable_notification: Optional[bool] = None disable_notification: Optional[bool] = None
"""Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound.""" """Sends the message `silently <https://telegram.org/blog/channels-2-0#silent-messages>`_. Users will receive a notification with no sound."""
protect_content: Optional[bool] = None protect_content: Optional[bool] = None
@ -54,7 +54,7 @@ class SendVideo(TelegramMethod[Message]):
reply_to_message_id: Optional[int] = None reply_to_message_id: Optional[int] = None
"""If the message is a reply, ID of the original message""" """If the message is a reply, ID of the original message"""
allow_sending_without_reply: Optional[bool] = None allow_sending_without_reply: Optional[bool] = None
"""Pass :code:`True`, if the message should be sent even if the specified replied-to message is not found""" """Pass :code:`True` if the message should be sent even if the specified replied-to message is not found"""
reply_markup: Optional[ reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply] Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
] = None ] = None

View file

@ -42,7 +42,7 @@ class SendVideoNote(TelegramMethod[Message]):
reply_to_message_id: Optional[int] = None reply_to_message_id: Optional[int] = None
"""If the message is a reply, ID of the original message""" """If the message is a reply, ID of the original message"""
allow_sending_without_reply: Optional[bool] = None allow_sending_without_reply: Optional[bool] = None
"""Pass :code:`True`, if the message should be sent even if the specified replied-to message is not found""" """Pass :code:`True` if the message should be sent even if the specified replied-to message is not found"""
reply_markup: Optional[ reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply] Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
] = None ] = None

View file

@ -46,7 +46,7 @@ class SendVoice(TelegramMethod[Message]):
reply_to_message_id: Optional[int] = None reply_to_message_id: Optional[int] = None
"""If the message is a reply, ID of the original message""" """If the message is a reply, ID of the original message"""
allow_sending_without_reply: Optional[bool] = None allow_sending_without_reply: Optional[bool] = None
"""Pass :code:`True`, if the message should be sent even if the specified replied-to message is not found""" """Pass :code:`True` if the message should be sent even if the specified replied-to message is not found"""
reply_markup: Optional[ reply_markup: Optional[
Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply] Union[InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply]
] = None ] = None

View file

@ -23,9 +23,9 @@ class SetGameScore(TelegramMethod[Union[Message, bool]]):
score: int score: int
"""New score, must be non-negative""" """New score, must be non-negative"""
force: Optional[bool] = None force: Optional[bool] = None
"""Pass :code:`True`, if the high score is allowed to decrease. This can be useful when fixing mistakes or banning cheaters""" """Pass :code:`True` if the high score is allowed to decrease. This can be useful when fixing mistakes or banning cheaters"""
disable_edit_message: Optional[bool] = None disable_edit_message: Optional[bool] = None
"""Pass :code:`True`, if the game message should not be automatically edited to include the current scoreboard""" """Pass :code:`True` if the game message should not be automatically edited to include the current scoreboard"""
chat_id: Optional[int] = None chat_id: Optional[int] = None
"""Required if *inline_message_id* is not specified. Unique identifier for the target chat""" """Required if *inline_message_id* is not specified. Unique identifier for the target chat"""
message_id: Optional[int] = None message_id: Optional[int] = None

View file

@ -1,3 +1,5 @@
from typing import Optional
from .animation import Animation from .animation import Animation
from .audio import Audio from .audio import Audio
from .base import UNSET, TelegramObject from .base import UNSET, TelegramObject
@ -284,7 +286,10 @@ for _entity_name in __all__:
_entity = globals()[_entity_name] _entity = globals()[_entity_name]
if not hasattr(_entity, "update_forward_refs"): if not hasattr(_entity, "update_forward_refs"):
continue continue
_entity.update_forward_refs(**globals()) _entity.update_forward_refs(
**{k: v for k, v in globals().items() if k in __all__},
**{"Optional": Optional},
)
del _entity del _entity
del _entity_name del _entity_name

View file

@ -37,6 +37,8 @@ class Chat(TelegramObject):
"""*Optional*. Bio of the other party in a private chat. Returned only in :class:`aiogram.methods.get_chat.GetChat`.""" """*Optional*. Bio of the other party in a private chat. Returned only in :class:`aiogram.methods.get_chat.GetChat`."""
has_private_forwards: Optional[bool] = None has_private_forwards: Optional[bool] = None
"""*Optional*. :code:`True`, if privacy settings of the other party in the private chat allows to use :code:`tg://user?id=<user_id>` links only in chats with the user. Returned only in :class:`aiogram.methods.get_chat.GetChat`.""" """*Optional*. :code:`True`, if privacy settings of the other party in the private chat allows to use :code:`tg://user?id=<user_id>` links only in chats with the user. Returned only in :class:`aiogram.methods.get_chat.GetChat`."""
has_restricted_voice_and_video_messages: Optional[bool] = None
"""*Optional*. :code:`True`, if the privacy settings of the other party restrict sending voice and video note messages in the private chat. Returned only in :class:`aiogram.methods.get_chat.GetChat`."""
join_to_send_messages: Optional[bool] = None join_to_send_messages: Optional[bool] = None
"""*Optional*. :code:`True`, if users need to join the supergroup before they can send messages. Returned only in :class:`aiogram.methods.get_chat.GetChat`.""" """*Optional*. :code:`True`, if users need to join the supergroup before they can send messages. Returned only in :class:`aiogram.methods.get_chat.GetChat`."""
join_by_request: Optional[bool] = None join_by_request: Optional[bool] = None

View file

@ -31,7 +31,7 @@ class InlineQueryResultArticle(InlineQueryResult):
url: Optional[str] = None url: Optional[str] = None
"""*Optional*. URL of the result""" """*Optional*. URL of the result"""
hide_url: Optional[bool] = None hide_url: Optional[bool] = None
"""*Optional*. Pass :code:`True`, if you don't want the URL to be shown in the message""" """*Optional*. Pass :code:`True` if you don't want the URL to be shown in the message"""
description: Optional[str] = None description: Optional[str] = None
"""*Optional*. Short description of the result""" """*Optional*. Short description of the result"""
thumb_url: Optional[str] = None thumb_url: Optional[str] = None

View file

@ -42,16 +42,16 @@ class InputInvoiceMessageContent(InputMessageContent):
photo_height: Optional[int] = None photo_height: Optional[int] = None
"""*Optional*. Photo height""" """*Optional*. Photo height"""
need_name: Optional[bool] = None need_name: Optional[bool] = None
"""*Optional*. Pass :code:`True`, if you require the user's full name to complete the order""" """*Optional*. Pass :code:`True` if you require the user's full name to complete the order"""
need_phone_number: Optional[bool] = None need_phone_number: Optional[bool] = None
"""*Optional*. Pass :code:`True`, if you require the user's phone number to complete the order""" """*Optional*. Pass :code:`True` if you require the user's phone number to complete the order"""
need_email: Optional[bool] = None need_email: Optional[bool] = None
"""*Optional*. Pass :code:`True`, if you require the user's email address to complete the order""" """*Optional*. Pass :code:`True` if you require the user's email address to complete the order"""
need_shipping_address: Optional[bool] = None need_shipping_address: Optional[bool] = None
"""*Optional*. Pass :code:`True`, if you require the user's shipping address to complete the order""" """*Optional*. Pass :code:`True` if you require the user's shipping address to complete the order"""
send_phone_number_to_provider: Optional[bool] = None send_phone_number_to_provider: Optional[bool] = None
"""*Optional*. Pass :code:`True`, if the user's phone number should be sent to provider""" """*Optional*. Pass :code:`True` if the user's phone number should be sent to provider"""
send_email_to_provider: Optional[bool] = None send_email_to_provider: Optional[bool] = None
"""*Optional*. Pass :code:`True`, if the user's email address should be sent to provider""" """*Optional*. Pass :code:`True` if the user's email address should be sent to provider"""
is_flexible: Optional[bool] = None is_flexible: Optional[bool] = None
"""*Optional*. Pass :code:`True`, if the final price depends on the shipping method""" """*Optional*. Pass :code:`True` if the final price depends on the shipping method"""

View file

@ -38,4 +38,4 @@ class InputMediaVideo(InputMedia):
duration: Optional[int] = None duration: Optional[int] = None
"""*Optional*. Video duration in seconds""" """*Optional*. Video duration in seconds"""
supports_streaming: Optional[bool] = None supports_streaming: Optional[bool] = None
"""*Optional*. Pass :code:`True`, if the uploaded video is suitable for streaming""" """*Optional*. Pass :code:`True` if the uploaded video is suitable for streaming"""

View file

@ -9,10 +9,6 @@ if TYPE_CHECKING:
from .web_app_info import WebAppInfo from .web_app_info import WebAppInfo
class WebApp(MutableTelegramObject):
url: str
class KeyboardButton(MutableTelegramObject): class KeyboardButton(MutableTelegramObject):
""" """
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 *web_app*, *request_contact*, *request_location*, and *request_poll* are mutually exclusive. 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 *web_app*, *request_contact*, *request_location*, and *request_poll* are mutually exclusive.

View file

@ -16,7 +16,7 @@ class LoginUrl(TelegramObject):
""" """
url: str url: str
"""An HTTP URL to be opened with user authorization data added to the query string when the button is pressed. If the user refuses to provide authorization data, the original URL without information about the user will be opened. The data added is the same as described in `Receiving authorization data <https://core.telegram.org/widgets/login#receiving-authorization-data>`_.""" """An HTTPS URL to be opened with user authorization data added to the query string when the button is pressed. If the user refuses to provide authorization data, the original URL without information about the user will be opened. The data added is the same as described in `Receiving authorization data <https://core.telegram.org/widgets/login#receiving-authorization-data>`_."""
forward_text: Optional[str] = None forward_text: Optional[str] = None
"""*Optional*. New text of the button in forwarded messages.""" """*Optional*. New text of the button in forwarded messages."""
bot_username: Optional[str] = None bot_username: Optional[str] = None

View file

@ -1,11 +1,11 @@
from __future__ import annotations from __future__ import annotations
from typing import TYPE_CHECKING from typing import TYPE_CHECKING, Optional
from .base import TelegramObject from .base import TelegramObject
if TYPE_CHECKING: if TYPE_CHECKING:
pass from .web_app_info import WebAppInfo
class MenuButton(TelegramObject): class MenuButton(TelegramObject):
@ -20,3 +20,10 @@ class MenuButton(TelegramObject):
Source: https://core.telegram.org/bots/api#menubutton Source: https://core.telegram.org/bots/api#menubutton
""" """
type: str
"""..."""
text: Optional[str] = None
"""*Optional*. Text on the button"""
web_app: Optional[WebAppInfo] = None
"""*Optional*. Description of the Web App that will be launched when the user presses the button. The Web App will be able to send an arbitrary message on behalf of the user using the method :class:`aiogram.methods.answer_web_app_query.AnswerWebAppQuery`."""

View file

@ -18,7 +18,7 @@ class MessageEntity(MutableTelegramObject):
""" """
type: str type: str
"""Type of the entity. Currently, can be 'mention' (:code:`@username`), 'hashtag' (:code:`#hashtag`), 'cashtag' (:code:`$USD`), 'bot_command' (:code:`/start@jobs_bot`), 'url' (:code:`https://telegram.org`), 'email' (:code:`do-not-reply@telegram.org`), 'phone_number' (:code:`+1-212-555-0123`), 'bold' (**bold text**), 'italic' (*italic text*), 'underline' (underlined text), 'strikethrough' (strikethrough text), 'spoiler' (spoiler message), 'code' (monowidth string), 'pre' (monowidth block), 'text_link' (for clickable text URLs), 'text_mention' (for users `without usernames <https://telegram.org/blog/edit#new-mentions>`_)""" """Type of the entity. Currently, can be 'mention' (:code:`@username`), 'hashtag' (:code:`#hashtag`), 'cashtag' (:code:`$USD`), 'bot_command' (:code:`/start@jobs_bot`), 'url' (:code:`https://telegram.org`), 'email' (:code:`do-not-reply@telegram.org`), 'phone_number' (:code:`+1-212-555-0123`), 'bold' (**bold text**), 'italic' (*italic text*), 'underline' (underlined text), 'strikethrough' (strikethrough text), 'spoiler' (spoiler message), 'code' (monowidth string), 'pre' (monowidth block), 'text_link' (for clickable text URLs), 'text_mention' (for users `without usernames <https://telegram.org/blog/edit#new-mentions>`_), 'custom_emoji' (for inline custom emoji stickers)"""
offset: int offset: int
"""Offset in UTF-16 code units to the start of the entity""" """Offset in UTF-16 code units to the start of the entity"""
length: int length: int
@ -29,6 +29,8 @@ class MessageEntity(MutableTelegramObject):
"""*Optional*. For 'text_mention' only, the mentioned user""" """*Optional*. For 'text_mention' only, the mentioned user"""
language: Optional[str] = None language: Optional[str] = None
"""*Optional*. For 'pre' only, the programming language of the entity text""" """*Optional*. For 'pre' only, the programming language of the entity text"""
custom_emoji_id: Optional[str] = None
"""*Optional*. For 'custom_emoji' only, unique identifier of the custom emoji. Use :class:`aiogram.methods.get_custom_emoji_stickers.GetCustomEmojiStickers` to get full information about the sticker"""
def extract_from(self, text: str) -> str: def extract_from(self, text: str) -> str:
return remove_surrogates( return remove_surrogates(

View file

@ -21,6 +21,8 @@ class Sticker(TelegramObject):
"""Identifier for this file, which can be used to download or reuse the file""" """Identifier for this file, which can be used to download or reuse the file"""
file_unique_id: str file_unique_id: str
"""Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file.""" """Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file."""
type: str
"""Type of the sticker, currently one of 'regular', 'mask', 'custom_emoji'. The type of the sticker is independent from its format, which is determined by the fields *is_animated* and *is_video*."""
width: int width: int
"""Sticker width""" """Sticker width"""
height: int height: int
@ -36,8 +38,10 @@ class Sticker(TelegramObject):
set_name: Optional[str] = None set_name: Optional[str] = None
"""*Optional*. Name of the sticker set to which the sticker belongs""" """*Optional*. Name of the sticker set to which the sticker belongs"""
premium_animation: Optional[File] = None premium_animation: Optional[File] = None
"""*Optional*. Premium animation for the sticker, if the sticker is premium""" """*Optional*. For premium regular stickers, premium animation for the sticker"""
mask_position: Optional[MaskPosition] = None mask_position: Optional[MaskPosition] = None
"""*Optional*. For mask stickers, the position where the mask should be placed""" """*Optional*. For mask stickers, the position where the mask should be placed"""
custom_emoji_id: Optional[str] = None
"""*Optional*. For custom emoji stickers, unique identifier of the custom emoji"""
file_size: Optional[int] = None file_size: Optional[int] = None
"""*Optional*. File size in bytes""" """*Optional*. File size in bytes"""

View file

@ -20,12 +20,12 @@ class StickerSet(TelegramObject):
"""Sticker set name""" """Sticker set name"""
title: str title: str
"""Sticker set title""" """Sticker set title"""
sticker_type: str
"""Type of stickers in the set, currently one of 'regular', 'mask', 'custom_emoji'"""
is_animated: bool is_animated: bool
""":code:`True`, if the sticker set contains `animated stickers <https://telegram.org/blog/animated-stickers>`_""" """:code:`True`, if the sticker set contains `animated stickers <https://telegram.org/blog/animated-stickers>`_"""
is_video: bool is_video: bool
""":code:`True`, if the sticker set contains `video stickers <https://telegram.org/blog/video-stickers-better-reactions>`_""" """:code:`True`, if the sticker set contains `video stickers <https://telegram.org/blog/video-stickers-better-reactions>`_"""
contains_masks: bool
""":code:`True`, if the sticker set contains masks"""
stickers: List[Sticker] stickers: List[Sticker]
"""List of all set stickers""" """List of all set stickers"""
thumb: Optional[PhotoSize] = None thumb: Optional[PhotoSize] = None

View file

@ -54,6 +54,8 @@ class TextDecoration(ABC):
return self.link(value=text, link=f"tg://user?id={user.id}") return self.link(value=text, link=f"tg://user?id={user.id}")
if entity.type == "text_link": if entity.type == "text_link":
return self.link(value=text, link=cast(str, entity.url)) return self.link(value=text, link=cast(str, entity.url))
if entity.type == "custom_emoji":
return self.custom_emoji(value=text, custom_emoji_id=cast(str, entity.custom_emoji_id))
return self.quote(text) return self.quote(text)
@ -140,7 +142,11 @@ class TextDecoration(ABC):
pass pass
@abstractmethod @abstractmethod
def quote(self, value: str) -> str: # pragma: no cover def quote(self, value: str) -> str:
pass
@abstractmethod
def custom_emoji(self, value: str, custom_emoji_id: str) -> str:
pass pass
@ -149,7 +155,8 @@ class HtmlDecoration(TextDecoration):
ITALIC_TAG = "i" ITALIC_TAG = "i"
UNDERLINE_TAG = "u" UNDERLINE_TAG = "u"
STRIKETHROUGH_TAG = "s" STRIKETHROUGH_TAG = "s"
SPOILER_TAG = ('span class="tg-spoiler"', "span") SPOILER_TAG = "tg-spoiler"
EMOJI_TAG = "tg-emoji"
def link(self, value: str, link: str) -> str: def link(self, value: str, link: str) -> str:
return f'<a href="{link}">{value}</a>' return f'<a href="{link}">{value}</a>'
@ -176,11 +183,14 @@ class HtmlDecoration(TextDecoration):
return f"<{self.STRIKETHROUGH_TAG}>{value}</{self.STRIKETHROUGH_TAG}>" return f"<{self.STRIKETHROUGH_TAG}>{value}</{self.STRIKETHROUGH_TAG}>"
def spoiler(self, value: str) -> str: def spoiler(self, value: str) -> str:
return f"<{self.SPOILER_TAG[0]}>{value}</{self.SPOILER_TAG[1]}>" return f"<{self.SPOILER_TAG}>{value}</{self.SPOILER_TAG}>"
def quote(self, value: str) -> str: def quote(self, value: str) -> str:
return html.escape(value, quote=False) return html.escape(value, quote=False)
def custom_emoji(self, value: str, custom_emoji_id: str) -> str:
return f'<{self.EMOJI_TAG} emoji-id="{custom_emoji_id}">{value}</tg-emoji>'
class MarkdownDecoration(TextDecoration): class MarkdownDecoration(TextDecoration):
MARKDOWN_QUOTE_PATTERN: Pattern[str] = re.compile(r"([_*\[\]()~`>#+\-=|{}.!\\])") MARKDOWN_QUOTE_PATTERN: Pattern[str] = re.compile(r"([_*\[\]()~`>#+\-=|{}.!\\])")
@ -215,6 +225,9 @@ class MarkdownDecoration(TextDecoration):
def quote(self, value: str) -> str: def quote(self, value: str) -> str:
return re.sub(pattern=self.MARKDOWN_QUOTE_PATTERN, repl=r"\\\1", string=value) return re.sub(pattern=self.MARKDOWN_QUOTE_PATTERN, repl=r"\\\1", string=value)
def custom_emoji(self, value: str, custom_emoji_id: str) -> str:
return self.link(value=value, link=f"tg://emoji?id={custom_emoji_id}")
html_decoration = HtmlDecoration() html_decoration = HtmlDecoration()
markdown_decoration = MarkdownDecoration() markdown_decoration = MarkdownDecoration()

View file

@ -0,0 +1,37 @@
######################
getCustomEmojiStickers
######################
Returns: :obj:`List[Sticker]`
.. automodule:: aiogram.methods.get_custom_emoji_stickers
:members:
:member-order: bysource
:undoc-members: True
Usage
=====
As bot method
-------------
.. code-block::
result: List[Sticker] = await bot.get_custom_emoji_stickers(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods.get_custom_emoji_stickers import GetCustomEmojiStickers`
- alias: :code:`from aiogram.methods import GetCustomEmojiStickers`
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block:: python
result: List[Sticker] = await bot(GetCustomEmojiStickers(...))

View file

@ -108,6 +108,7 @@ Stickers
send_sticker send_sticker
get_sticker_set get_sticker_set
get_custom_emoji_stickers
upload_sticker_file upload_sticker_file
create_new_sticker_set create_new_sticker_set
add_sticker_to_set add_sticker_to_set

View file

@ -29,13 +29,6 @@ Imports:
- :code:`from aiogram.methods.send_chat_action import SendChatAction` - :code:`from aiogram.methods.send_chat_action import SendChatAction`
- alias: :code:`from aiogram.methods import SendChatAction` - alias: :code:`from aiogram.methods import SendChatAction`
In handlers with current bot
----------------------------
.. code-block:: python
result: bool = await SendChatAction(...)
With specific bot With specific bot
~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~

View file

@ -29,13 +29,6 @@ Imports:
- :code:`from aiogram.methods.set_chat_sticker_set import SetChatStickerSet` - :code:`from aiogram.methods.set_chat_sticker_set import SetChatStickerSet`
- alias: :code:`from aiogram.methods import SetChatStickerSet` - alias: :code:`from aiogram.methods import SetChatStickerSet`
In handlers with current bot
----------------------------
.. code-block:: python
result: bool = await SetChatStickerSet(...)
With specific bot With specific bot
~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~

View file

@ -29,13 +29,6 @@ Imports:
- :code:`from aiogram.methods.set_chat_title import SetChatTitle` - :code:`from aiogram.methods.set_chat_title import SetChatTitle`
- alias: :code:`from aiogram.methods import SetChatTitle` - alias: :code:`from aiogram.methods import SetChatTitle`
In handlers with current bot
----------------------------
.. code-block:: python
result: bool = await SetChatTitle(...)
With specific bot With specific bot
~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~

View file

@ -29,13 +29,6 @@ Imports:
- :code:`from aiogram.methods.set_game_score import SetGameScore` - :code:`from aiogram.methods.set_game_score import SetGameScore`
- alias: :code:`from aiogram.methods import SetGameScore` - alias: :code:`from aiogram.methods import SetGameScore`
In handlers with current bot
----------------------------
.. code-block:: python
result: Union[Message, bool] = await SetGameScore(...)
With specific bot With specific bot
~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~

View file

@ -29,13 +29,6 @@ Imports:
- :code:`from aiogram.methods.set_my_commands import SetMyCommands` - :code:`from aiogram.methods.set_my_commands import SetMyCommands`
- alias: :code:`from aiogram.methods import SetMyCommands` - alias: :code:`from aiogram.methods import SetMyCommands`
In handlers with current bot
----------------------------
.. code-block:: python
result: bool = await SetMyCommands(...)
With specific bot With specific bot
~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~

View file

@ -29,13 +29,6 @@ Imports:
- :code:`from aiogram.methods.set_my_default_administrator_rights import SetMyDefaultAdministratorRights` - :code:`from aiogram.methods.set_my_default_administrator_rights import SetMyDefaultAdministratorRights`
- alias: :code:`from aiogram.methods import SetMyDefaultAdministratorRights` - alias: :code:`from aiogram.methods import SetMyDefaultAdministratorRights`
In handlers with current bot
----------------------------
.. code-block:: python
result: bool = await SetMyDefaultAdministratorRights(...)
With specific bot With specific bot
~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~

View file

@ -29,13 +29,6 @@ Imports:
- :code:`from aiogram.methods.set_passport_data_errors import SetPassportDataErrors` - :code:`from aiogram.methods.set_passport_data_errors import SetPassportDataErrors`
- alias: :code:`from aiogram.methods import SetPassportDataErrors` - alias: :code:`from aiogram.methods import SetPassportDataErrors`
In handlers with current bot
----------------------------
.. code-block:: python
result: bool = await SetPassportDataErrors(...)
With specific bot With specific bot
~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~

View file

@ -29,13 +29,6 @@ Imports:
- :code:`from aiogram.methods.set_sticker_position_in_set import SetStickerPositionInSet` - :code:`from aiogram.methods.set_sticker_position_in_set import SetStickerPositionInSet`
- alias: :code:`from aiogram.methods import SetStickerPositionInSet` - alias: :code:`from aiogram.methods import SetStickerPositionInSet`
In handlers with current bot
----------------------------
.. code-block:: python
result: bool = await SetStickerPositionInSet(...)
With specific bot With specific bot
~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~

View file

@ -29,13 +29,6 @@ Imports:
- :code:`from aiogram.methods.set_sticker_set_thumb import SetStickerSetThumb` - :code:`from aiogram.methods.set_sticker_set_thumb import SetStickerSetThumb`
- alias: :code:`from aiogram.methods import SetStickerSetThumb` - alias: :code:`from aiogram.methods import SetStickerSetThumb`
In handlers with current bot
----------------------------
.. code-block:: python
result: bool = await SetStickerSetThumb(...)
With specific bot With specific bot
~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~

View file

@ -29,13 +29,6 @@ Imports:
- :code:`from aiogram.methods.set_webhook import SetWebhook` - :code:`from aiogram.methods.set_webhook import SetWebhook`
- alias: :code:`from aiogram.methods import SetWebhook` - alias: :code:`from aiogram.methods import SetWebhook`
In handlers with current bot
----------------------------
.. code-block:: python
result: bool = await SetWebhook(...)
With specific bot With specific bot
~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~

View file

@ -29,13 +29,6 @@ Imports:
- :code:`from aiogram.methods.stop_message_live_location import StopMessageLiveLocation` - :code:`from aiogram.methods.stop_message_live_location import StopMessageLiveLocation`
- alias: :code:`from aiogram.methods import StopMessageLiveLocation` - alias: :code:`from aiogram.methods import StopMessageLiveLocation`
In handlers with current bot
----------------------------
.. code-block:: python
result: Union[Message, bool] = await StopMessageLiveLocation(...)
With specific bot With specific bot
~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~

View file

@ -29,13 +29,6 @@ Imports:
- :code:`from aiogram.methods.stop_poll import StopPoll` - :code:`from aiogram.methods.stop_poll import StopPoll`
- alias: :code:`from aiogram.methods import StopPoll` - alias: :code:`from aiogram.methods import StopPoll`
In handlers with current bot
----------------------------
.. code-block:: python
result: Poll = await StopPoll(...)
With specific bot With specific bot
~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~

View file

@ -29,13 +29,6 @@ Imports:
- :code:`from aiogram.methods.unban_chat_member import UnbanChatMember` - :code:`from aiogram.methods.unban_chat_member import UnbanChatMember`
- alias: :code:`from aiogram.methods import UnbanChatMember` - alias: :code:`from aiogram.methods import UnbanChatMember`
In handlers with current bot
----------------------------
.. code-block:: python
result: bool = await UnbanChatMember(...)
With specific bot With specific bot
~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~

View file

@ -29,13 +29,6 @@ Imports:
- :code:`from aiogram.methods.unban_chat_sender_chat import UnbanChatSenderChat` - :code:`from aiogram.methods.unban_chat_sender_chat import UnbanChatSenderChat`
- alias: :code:`from aiogram.methods import UnbanChatSenderChat` - alias: :code:`from aiogram.methods import UnbanChatSenderChat`
In handlers with current bot
----------------------------
.. code-block:: python
result: bool = await UnbanChatSenderChat(...)
With specific bot With specific bot
~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~

View file

@ -29,13 +29,6 @@ Imports:
- :code:`from aiogram.methods.unpin_all_chat_messages import UnpinAllChatMessages` - :code:`from aiogram.methods.unpin_all_chat_messages import UnpinAllChatMessages`
- alias: :code:`from aiogram.methods import UnpinAllChatMessages` - alias: :code:`from aiogram.methods import UnpinAllChatMessages`
In handlers with current bot
----------------------------
.. code-block:: python
result: bool = await UnpinAllChatMessages(...)
With specific bot With specific bot
~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~

View file

@ -29,13 +29,6 @@ Imports:
- :code:`from aiogram.methods.unpin_chat_message import UnpinChatMessage` - :code:`from aiogram.methods.unpin_chat_message import UnpinChatMessage`
- alias: :code:`from aiogram.methods import UnpinChatMessage` - alias: :code:`from aiogram.methods import UnpinChatMessage`
In handlers with current bot
----------------------------
.. code-block:: python
result: bool = await UnpinChatMessage(...)
With specific bot With specific bot
~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~

View file

@ -29,13 +29,6 @@ Imports:
- :code:`from aiogram.methods.upload_sticker_file import UploadStickerFile` - :code:`from aiogram.methods.upload_sticker_file import UploadStickerFile`
- alias: :code:`from aiogram.methods import UploadStickerFile` - alias: :code:`from aiogram.methods import UploadStickerFile`
In handlers with current bot
----------------------------
.. code-block:: python
result: File = await UploadStickerFile(...)
With specific bot With specific bot
~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~

621
poetry.lock generated

File diff suppressed because it is too large Load diff

View file

@ -37,9 +37,9 @@ classifiers = [
[tool.poetry.dependencies] [tool.poetry.dependencies]
python = "^3.8" python = "^3.8"
magic-filter = "^1.0.7" magic-filter = "^1.0.8"
aiohttp = "^3.8.1" aiohttp = "^3.8.1"
pydantic = "^1.9.1" pydantic = "^1.9.2"
aiofiles = "^0.8.0" aiofiles = "^0.8.0"
# Fast # Fast
uvloop = { version = "^0.16.0", markers = "sys_platform == 'darwin' or sys_platform == 'linux'", optional = true } uvloop = { version = "^0.16.0", markers = "sys_platform == 'darwin' or sys_platform == 'linux'", optional = true }
@ -48,7 +48,7 @@ Babel = { version = "^2.9.1", optional = true }
# Proxy # Proxy
aiohttp-socks = { version = "^0.7.1", optional = true } aiohttp-socks = { version = "^0.7.1", optional = true }
# Redis # Redis
redis = {version = "^4.3.3", optional = true} redis = { version = "^4.3.4", optional = true }
# Docs # Docs
Sphinx = { version = "^4.2.0", optional = true } Sphinx = { version = "^4.2.0", optional = true }
sphinx-intl = { version = "^2.0.1", optional = true } sphinx-intl = { version = "^2.0.1", optional = true }
@ -60,29 +60,29 @@ Sphinx-Substitution-Extensions = { version = "^2020.9.30", optional = true }
towncrier = { version = "^21.9.0", optional = true } towncrier = { version = "^21.9.0", optional = true }
pygments = { version = "^2.4", optional = true } pygments = { version = "^2.4", optional = true }
pymdown-extensions = { version = "^9.5", optional = true } pymdown-extensions = { version = "^9.5", optional = true }
markdown-include = { version = "^0.6", optional = true } markdown-include = { version = "^0.7.0", optional = true }
Pygments = { version = "^2.12.0", optional = true } Pygments = { version = "^2.12.0", optional = true }
[tool.poetry.dev-dependencies] [tool.poetry.dev-dependencies]
black = "^22.1.0" black = "^22.6.0"
isort = "^5.10.1" isort = "^5.10.1"
flake8 = "^4.0.1" flake8 = "^5.0.4"
mypy = "^0.961" mypy = "^0.971"
pytest = "^7.1.2" pytest = "^7.1.2"
pytest-html = "^3.1.1" pytest-html = "^3.1.1"
pytest-asyncio = "^0.18.1" pytest-asyncio = "^0.19.0"
pytest-lazy-fixture = "^0.6.3" pytest-lazy-fixture = "^0.6.3"
pytest-mock = "^3.8.1" pytest-mock = "^3.8.2"
pytest-mypy = "^0.9.1" pytest-mypy = "^0.9.1"
pytest-cov = "^3.0.0" pytest-cov = "^3.0.0"
pytest-aiohttp = "^1.0.4" pytest-aiohttp = "^1.0.4"
aresponses = "^2.1.5" aresponses = "^2.1.6"
asynctest = "^0.13.0" asynctest = "^0.13.0"
toml = "^0.10.2" toml = "^0.10.2"
pre-commit = "^2.19.0" pre-commit = "^2.20.0"
packaging = "^21.3" packaging = "^21.3"
typing-extensions = "^4.2.0" typing-extensions = "^4.3.0"
[tool.poetry.extras] [tool.poetry.extras]

4
pytest.ini Normal file
View file

@ -0,0 +1,4 @@
[pytest]
asyncio_mode = auto
testpaths =
tests

View file

@ -0,0 +1,63 @@
from typing import List
import pytest
from aiogram.methods import GetCustomEmojiStickers, Request
from aiogram.types import Sticker
from tests.mocked_bot import MockedBot
class TestGetCustomEmojiStickers:
@pytest.mark.asyncio
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(
GetCustomEmojiStickers,
ok=True,
result=[
Sticker(
file_id="file id",
width=42,
height=42,
is_animated=False,
is_video=False,
file_unique_id="file id",
custom_emoji_id="1",
type="custom_emoji",
)
],
)
response: List[Sticker] = await GetCustomEmojiStickers(
custom_emoji_ids=["1"],
)
request: Request = bot.get_request()
assert request.method == "getCustomEmojiStickers"
# 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(
GetCustomEmojiStickers,
ok=True,
result=[
Sticker(
file_id="file id",
width=42,
height=42,
is_animated=False,
is_video=False,
file_unique_id="file id",
custom_emoji_id="1",
type="custom_emoji",
)
],
)
response: List[Sticker] = await bot.get_custom_emoji_stickers(
custom_emoji_ids=["1", "2"],
)
request: Request = bot.get_request()
assert request.method == "getCustomEmojiStickers"
# assert request.data == {}
assert response == prepare_result.result

View file

@ -17,7 +17,6 @@ class TestGetStickerSet:
title="test", title="test",
is_animated=False, is_animated=False,
is_video=False, is_video=False,
contains_masks=False,
stickers=[ stickers=[
Sticker( Sticker(
file_id="file if", file_id="file if",
@ -26,8 +25,10 @@ class TestGetStickerSet:
is_animated=False, is_animated=False,
is_video=False, is_video=False,
file_unique_id="file id", file_unique_id="file id",
type="regular",
) )
], ],
sticker_type="regular",
), ),
) )
@ -45,7 +46,6 @@ class TestGetStickerSet:
title="test", title="test",
is_animated=False, is_animated=False,
is_video=False, is_video=False,
contains_masks=False,
stickers=[ stickers=[
Sticker( Sticker(
file_id="file if", file_id="file if",
@ -54,8 +54,10 @@ class TestGetStickerSet:
is_animated=False, is_animated=False,
is_video=False, is_video=False,
file_unique_id="file id", file_unique_id="file id",
type="regular",
) )
], ],
sticker_type="regular",
), ),
) )

View file

@ -24,6 +24,7 @@ class TestSendSticker:
is_animated=False, is_animated=False,
is_video=False, is_video=False,
file_unique_id="file id", file_unique_id="file id",
type="regular",
), ),
chat=Chat(id=42, type="private"), chat=Chat(id=42, type="private"),
), ),
@ -48,6 +49,7 @@ class TestSendSticker:
is_animated=False, is_animated=False,
is_video=False, is_video=False,
file_unique_id="file id", file_unique_id="file id",
type="regular",
), ),
chat=Chat(id=42, type="private"), chat=Chat(id=42, type="private"),
), ),

View file

@ -126,6 +126,7 @@ TEST_MESSAGE_STICKER = Message(
height=42, height=42,
is_animated=False, is_animated=False,
is_video=False, is_video=False,
type="regular",
), ),
chat=Chat(id=42, type="private"), chat=Chat(id=42, type="private"),
from_user=User(id=42, is_bot=False, first_name="Test"), from_user=User(id=42, is_bot=False, first_name="Test"),

View file

@ -50,7 +50,12 @@ class TestTextDecoration:
[ [
html_decoration, html_decoration,
MessageEntity(type="spoiler", offset=0, length=5), MessageEntity(type="spoiler", offset=0, length=5),
'<span class="tg-spoiler">test</span>', "<tg-spoiler>test</tg-spoiler>",
],
[
html_decoration,
MessageEntity(type="custom_emoji", offset=0, length=5, custom_emoji_id="42"),
'<tg-emoji emoji-id="42">test</tg-emoji>',
], ],
[ [
html_decoration, html_decoration,
@ -82,6 +87,11 @@ class TestTextDecoration:
[markdown_decoration, MessageEntity(type="email", offset=0, length=5), "test"], [markdown_decoration, MessageEntity(type="email", offset=0, length=5), "test"],
[markdown_decoration, MessageEntity(type="phone_number", offset=0, length=5), "test"], [markdown_decoration, MessageEntity(type="phone_number", offset=0, length=5), "test"],
[markdown_decoration, MessageEntity(type="spoiler", offset=0, length=5), "|test|"], [markdown_decoration, MessageEntity(type="spoiler", offset=0, length=5), "|test|"],
[
markdown_decoration,
MessageEntity(type="custom_emoji", offset=0, length=5, custom_emoji_id="42"),
"[test](tg://emoji?id=42)",
],
[ [
markdown_decoration, markdown_decoration,
MessageEntity( MessageEntity(