Dev 3.x api 5.4 (#744)

* Re-generate API

* Added new modules

* Added handling new event type and approve/decline aliases for ChatJoinRequest

* Fixed code-coverage

* Bump API version

* Added patch-notes
This commit is contained in:
Alex Root Junior 2021-11-08 02:37:37 +02:00 committed by GitHub
parent 3ad16be507
commit 9b43a33b7f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
99 changed files with 631 additions and 199 deletions

View file

@ -1 +1 @@
5.3 5.4

2
CHANGES/744.misc Normal file
View file

@ -0,0 +1,2 @@
Added full support of Bot API 5.4
https://core.telegram.org/bots/api-changelog#november-5-2021

View file

@ -13,7 +13,7 @@ aiogram
: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-5.3-blue.svg?logo=telegram .. image:: https://img.shields.io/badge/Telegram%20Bot%20API-5.4-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

@ -38,4 +38,4 @@ __all__ = (
) )
__version__ = "3.0.0a18" __version__ = "3.0.0a18"
__api_version__ = "5.3" __api_version__ = "5.4"

View file

@ -27,11 +27,13 @@ from ..methods import (
AnswerInlineQuery, AnswerInlineQuery,
AnswerPreCheckoutQuery, AnswerPreCheckoutQuery,
AnswerShippingQuery, AnswerShippingQuery,
ApproveChatJoinRequest,
BanChatMember, BanChatMember,
Close, Close,
CopyMessage, CopyMessage,
CreateChatInviteLink, CreateChatInviteLink,
CreateNewStickerSet, CreateNewStickerSet,
DeclineChatJoinRequest,
DeleteChatPhoto, DeleteChatPhoto,
DeleteChatStickerSet, DeleteChatStickerSet,
DeleteMessage, DeleteMessage,
@ -480,7 +482,7 @@ class Bot(ContextInstanceMixin["Bot"]):
request_timeout: Optional[int] = None, request_timeout: Optional[int] = None,
) -> User: ) -> User:
""" """
A simple method for testing your bot's auth token. Requires no parameters. Returns basic information about the bot in form of a :class:`aiogram.types.user.User` object. A simple method for testing your bot's authentication token. Requires no parameters. Returns basic information about the bot in form of a :class:`aiogram.types.user.User` object.
Source: https://core.telegram.org/bots/api#getme Source: https://core.telegram.org/bots/api#getme
@ -544,7 +546,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 text: Text of the message to be sent, 1-4096 characters after entities parsing :param text: Text of the message to be sent, 1-4096 characters after entities parsing
:param parse_mode: Mode for parsing entities in the message text. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details. :param parse_mode: Mode for parsing entities in the message text. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details.
:param entities: List of special entities that appear in message text, which can be specified instead of *parse_mode* :param entities: A JSON-serialized list of special entities that appear in message text, which can be specified instead of *parse_mode*
:param disable_web_page_preview: Disables link previews for links in this message :param disable_web_page_preview: Disables link previews for links in this message
: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 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
@ -620,7 +622,7 @@ class Bot(ContextInstanceMixin["Bot"]):
:param message_id: Message identifier in the chat specified in *from_chat_id* :param message_id: Message identifier in the chat specified in *from_chat_id*
:param caption: New caption for media, 0-1024 characters after entities parsing. If not specified, the original caption is kept :param caption: New caption for media, 0-1024 characters after entities parsing. If not specified, the original caption is kept
:param parse_mode: Mode for parsing entities in the new caption. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details. :param parse_mode: Mode for parsing entities in the new caption. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details.
:param caption_entities: List of special entities that appear in the new caption, which can be specified instead of *parse_mode* :param caption_entities: A JSON-serialized list of special entities that appear in the new caption, which can be specified instead of *parse_mode*
: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 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
@ -666,7 +668,7 @@ class Bot(ContextInstanceMixin["Bot"]):
:param photo: Photo to send. Pass a file_id as String to send a photo that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a photo from the Internet, or upload a new photo using multipart/form-data. The photo must be at most 10 MB in size. The photo's width and height must not exceed 10000 in total. Width and height ratio must be at most 20. :ref:`More info on Sending Files » <sending-files>` :param photo: Photo to send. Pass a file_id as String to send a photo that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a photo from the Internet, or upload a new photo using multipart/form-data. The photo must be at most 10 MB in size. The photo's width and height must not exceed 10000 in total. Width and height ratio must be at most 20. :ref:`More info on Sending Files » <sending-files>`
:param caption: Photo caption (may also be used when resending photos by *file_id*), 0-1024 characters after entities parsing :param caption: Photo caption (may also be used when resending photos by *file_id*), 0-1024 characters after entities parsing
:param parse_mode: Mode for parsing entities in the photo caption. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details. :param parse_mode: Mode for parsing entities in the photo caption. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details.
:param caption_entities: 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 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 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
@ -716,7 +718,7 @@ class Bot(ContextInstanceMixin["Bot"]):
:param audio: Audio file to send. Pass a file_id as String to send an audio file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get an audio file from the Internet, or upload a new one using multipart/form-data. :ref:`More info on Sending Files » <sending-files>` :param audio: Audio file to send. Pass a file_id as String to send an audio file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get an audio file from the Internet, or upload a new one using multipart/form-data. :ref:`More info on Sending Files » <sending-files>`
:param caption: Audio caption, 0-1024 characters after entities parsing :param caption: Audio caption, 0-1024 characters after entities parsing
:param parse_mode: Mode for parsing entities in the audio caption. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details. :param parse_mode: Mode for parsing entities in the audio caption. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details.
:param caption_entities: 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 duration: Duration of the audio in seconds :param duration: Duration of the audio in seconds
:param performer: Performer :param performer: Performer
:param title: Track name :param title: Track name
@ -772,7 +774,7 @@ class Bot(ContextInstanceMixin["Bot"]):
:param thumb: Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass 'attach://<file_attach_name>' if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. :ref:`More info on Sending Files » <sending-files>` :param thumb: Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass 'attach://<file_attach_name>' if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. :ref:`More info on Sending Files » <sending-files>`
:param caption: Document caption (may also be used when resending documents by *file_id*), 0-1024 characters after entities parsing :param caption: Document caption (may also be used when resending documents by *file_id*), 0-1024 characters after entities parsing
:param parse_mode: Mode for parsing entities in the document caption. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details. :param parse_mode: Mode for parsing entities in the document caption. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details.
:param caption_entities: 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 disable_content_type_detection: Disables automatic server-side content type detection for files uploaded using multipart/form-data :param disable_content_type_detection: Disables automatic server-side content type detection for files uploaded using multipart/form-data
: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 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
@ -829,7 +831,7 @@ class Bot(ContextInstanceMixin["Bot"]):
:param thumb: Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass 'attach://<file_attach_name>' if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. :ref:`More info on Sending Files » <sending-files>` :param thumb: Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass 'attach://<file_attach_name>' if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. :ref:`More info on Sending Files » <sending-files>`
: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: 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 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
@ -888,7 +890,7 @@ class Bot(ContextInstanceMixin["Bot"]):
:param thumb: Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass 'attach://<file_attach_name>' if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. :ref:`More info on Sending Files » <sending-files>` :param thumb: Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail's width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be only uploaded as a new file, so you can pass 'attach://<file_attach_name>' if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. :ref:`More info on Sending Files » <sending-files>`
:param caption: Animation caption (may also be used when resending animation by *file_id*), 0-1024 characters after entities parsing :param caption: Animation caption (may also be used when resending animation by *file_id*), 0-1024 characters after entities parsing
:param parse_mode: Mode for parsing entities in the animation caption. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details. :param parse_mode: Mode for parsing entities in the animation caption. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details.
:param caption_entities: 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 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 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
@ -938,7 +940,7 @@ class Bot(ContextInstanceMixin["Bot"]):
:param voice: Audio file to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. :ref:`More info on Sending Files » <sending-files>` :param voice: Audio file to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. :ref:`More info on Sending Files » <sending-files>`
:param caption: Voice message caption, 0-1024 characters after entities parsing :param caption: Voice message caption, 0-1024 characters after entities parsing
:param parse_mode: Mode for parsing entities in the voice message caption. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details. :param parse_mode: Mode for parsing entities in the voice message caption. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details.
:param caption_entities: 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 duration: Duration of the voice message in seconds :param duration: Duration of the voice message in seconds
: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 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
@ -1141,7 +1143,7 @@ class Bot(ContextInstanceMixin["Bot"]):
request_timeout: Optional[int] = None, request_timeout: Optional[int] = None,
) -> Union[Message, bool]: ) -> Union[Message, bool]:
""" """
Use this method to stop updating a live location message before *live_period* expires. On success, if the message was sent by the bot, the sent :class:`aiogram.types.message.Message` is returned, otherwise :code:`True` is returned. Use this method to stop updating a live location message before *live_period* expires. On success, if the message is not an inline message, the edited :class:`aiogram.types.message.Message` is returned, otherwise :code:`True` is returned.
Source: https://core.telegram.org/bots/api#stopmessagelivelocation Source: https://core.telegram.org/bots/api#stopmessagelivelocation
@ -1150,8 +1152,8 @@ 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 reply_markup: A JSON-serialized object for a new `inline keyboard <https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating>`_. :param reply_markup: A JSON-serialized object for a new `inline keyboard <https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating>`_.
:param request_timeout: Request timeout :param request_timeout: Request timeout
:return: On success, if the message was sent by the bot, the sent Message is returned, :return: On success, if the message is not an inline message, the edited Message is
otherwise True is returned. returned, otherwise True is returned.
""" """
call = StopMessageLiveLocation( call = StopMessageLiveLocation(
chat_id=chat_id, chat_id=chat_id,
@ -1294,13 +1296,13 @@ 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 question: Poll question, 1-300 characters :param question: Poll question, 1-300 characters
:param options: A JSON-serialized list of answer options, 2-10 strings 1-100 characters each :param options: A JSON-serialized list of answer options, 2-10 strings 1-100 characters each
:param is_anonymous: True, if the poll needs to be anonymous, defaults to :code:`True` :param is_anonymous: :code:`True`, if the poll needs to be anonymous, defaults to :code:`True`
:param type: Poll type, 'quiz' or 'regular', defaults to 'regular' :param type: Poll type, 'quiz' or 'regular', defaults to 'regular'
:param allows_multiple_answers: True, if the poll allows multiple answers, ignored for polls in quiz mode, defaults to :code:`False` :param allows_multiple_answers: :code:`True`, if the poll allows multiple answers, ignored for polls in quiz mode, defaults to :code:`False`
:param correct_option_id: 0-based identifier of the correct answer option, required for polls in quiz mode :param correct_option_id: 0-based identifier of the correct answer option, required for polls in quiz mode
:param explanation: Text that is shown when a user chooses an incorrect answer or taps on the lamp icon in a quiz-style poll, 0-200 characters with at most 2 line feeds after entities parsing :param explanation: Text that is shown when a user chooses an incorrect answer or taps on the lamp icon in a quiz-style poll, 0-200 characters with at most 2 line feeds after entities parsing
:param explanation_parse_mode: Mode for parsing entities in the explanation. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details. :param explanation_parse_mode: Mode for parsing entities in the explanation. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details.
:param explanation_entities: 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.
@ -1384,7 +1386,7 @@ class Bot(ContextInstanceMixin["Bot"]):
Source: https://core.telegram.org/bots/api#sendchataction Source: https://core.telegram.org/bots/api#sendchataction
: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 action: Type of action to broadcast. Choose one, depending on what the user is about to receive: *typing* for `text messages <https://core.telegram.org/bots/api#sendmessage>`_, *upload_photo* for `photos <https://core.telegram.org/bots/api#sendphoto>`_, *record_video* or *upload_video* for `videos <https://core.telegram.org/bots/api#sendvideo>`_, *record_voice* or *upload_voice* for `voice notes <https://core.telegram.org/bots/api#sendvoice>`_, *upload_document* for `general files <https://core.telegram.org/bots/api#senddocument>`_, *find_location* for `location data <https://core.telegram.org/bots/api#sendlocation>`_, *record_video_note* or *upload_video_note* for `video notes <https://core.telegram.org/bots/api#sendvideonote>`_. :param action: Type of action to broadcast. Choose one, depending on what the user is about to receive: *typing* for `text messages <https://core.telegram.org/bots/api#sendmessage>`_, *upload_photo* for `photos <https://core.telegram.org/bots/api#sendphoto>`_, *record_video* or *upload_video* for `videos <https://core.telegram.org/bots/api#sendvideo>`_, *record_voice* or *upload_voice* for `voice notes <https://core.telegram.org/bots/api#sendvoice>`_, *upload_document* for `general files <https://core.telegram.org/bots/api#senddocument>`_, *choose_sticker* for `stickers <https://core.telegram.org/bots/api#sendsticker>`_, *find_location* for `location data <https://core.telegram.org/bots/api#sendlocation>`_, *record_video_note* or *upload_video_note* for `video notes <https://core.telegram.org/bots/api#sendvideonote>`_.
:param request_timeout: Request timeout :param request_timeout: Request timeout
:return: Returns True on success. :return: Returns True on success.
""" """
@ -1448,7 +1450,7 @@ class Bot(ContextInstanceMixin["Bot"]):
request_timeout: Optional[int] = None, request_timeout: Optional[int] = None,
) -> bool: ) -> bool:
""" """
Use this method to ban a user in a group, a supergroup or a channel. In the case of supergroups and channels, the user will not be able to return to the chat on their own using invite links, etc., unless `unbanned <https://core.telegram.org/bots/api#unbanchatmember>`_ first. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns :code:`True` on success. Use this method to ban a user in a group, a supergroup or a channel. In the case of supergroups and channels, the user will not be able to return to the chat on their own using invite links, etc., unless `unbanned <https://core.telegram.org/bots/api#unbanchatmember>`_ first. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns :code:`True` on success.
Source: https://core.telegram.org/bots/api#banchatmember Source: https://core.telegram.org/bots/api#banchatmember
@ -1481,7 +1483,7 @@ class Bot(ContextInstanceMixin["Bot"]):
Renamed from :code:`kickChatMember` in 5.3 bot API version and can be removed in near future Renamed from :code:`kickChatMember` in 5.3 bot API version and can be removed in near future
Use this method to ban a user in a group, a supergroup or a channel. In the case of supergroups and channels, the user will not be able to return to the chat on their own using invite links, etc., unless `unbanned <https://core.telegram.org/bots/api#unbanchatmember>`_ first. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns :code:`True` on success. Use this method to ban a user in a group, a supergroup or a channel. In the case of supergroups and channels, the user will not be able to return to the chat on their own using invite links, etc., unless `unbanned <https://core.telegram.org/bots/api#unbanchatmember>`_ first. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns :code:`True` on success.
Source: https://core.telegram.org/bots/api#banchatmember Source: https://core.telegram.org/bots/api#banchatmember
@ -1536,7 +1538,7 @@ class Bot(ContextInstanceMixin["Bot"]):
request_timeout: Optional[int] = None, request_timeout: Optional[int] = None,
) -> bool: ) -> bool:
""" """
Use this method to restrict a user in a supergroup. The bot must be an administrator in the supergroup for this to work and must have the appropriate admin rights. Pass :code:`True` for all permissions to lift restrictions from a user. Returns :code:`True` on success. Use this method to restrict a user in a supergroup. The bot must be an administrator in the supergroup for this to work and must have the appropriate administrator rights. Pass :code:`True` for all permissions to lift restrictions from a user. Returns :code:`True` on success.
Source: https://core.telegram.org/bots/api#restrictchatmember Source: https://core.telegram.org/bots/api#restrictchatmember
@ -1573,23 +1575,23 @@ class Bot(ContextInstanceMixin["Bot"]):
request_timeout: Optional[int] = None, request_timeout: Optional[int] = None,
) -> bool: ) -> bool:
""" """
Use this method to promote or demote a user in a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Pass :code:`False` for all boolean parameters to demote a user. Returns :code:`True` on success. Use this method to promote or demote a user in a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Pass :code:`False` for all boolean parameters to demote a user. Returns :code:`True` on success.
Source: https://core.telegram.org/bots/api#promotechatmember Source: https://core.telegram.org/bots/api#promotechatmember
: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 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 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 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 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_voice_chats: Pass True, if the administrator can manage voice chats :param can_manage_voice_chats: Pass :code:`True`, if the administrator can manage voice chats
:param can_restrict_members: Pass 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 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 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 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 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.
""" """
@ -1642,12 +1644,12 @@ class Bot(ContextInstanceMixin["Bot"]):
request_timeout: Optional[int] = None, request_timeout: Optional[int] = None,
) -> bool: ) -> bool:
""" """
Use this method to set default chat permissions for all members. The bot must be an administrator in the group or a supergroup for this to work and must have the *can_restrict_members* admin rights. Returns :code:`True` on success. Use this method to set default chat permissions for all members. The bot must be an administrator in the group or a supergroup for this to work and must have the *can_restrict_members* administrator rights. Returns :code:`True` on success.
Source: https://core.telegram.org/bots/api#setchatpermissions Source: https://core.telegram.org/bots/api#setchatpermissions
:param chat_id: Unique identifier for the target chat or username of the target supergroup (in the format :code:`@supergroupusername`) :param chat_id: Unique identifier for the target chat or username of the target supergroup (in the format :code:`@supergroupusername`)
:param permissions: New default chat permissions :param permissions: A JSON-serialized object for new default chat permissions
:param request_timeout: Request timeout :param request_timeout: Request timeout
:return: Returns True on success. :return: Returns True on success.
""" """
@ -1663,7 +1665,7 @@ class Bot(ContextInstanceMixin["Bot"]):
request_timeout: Optional[int] = None, request_timeout: Optional[int] = None,
) -> str: ) -> str:
""" """
Use this method to generate a new primary invite link for a chat; any previously generated primary link is revoked. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns the new invite link as *String* on success. Use this method to generate a new primary invite link for a chat; any previously generated primary link is revoked. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the new invite link as *String* on success.
Note: Each administrator in a chat generates their own invite links. Bots can't use invite links generated by other administrators. If you want your bot to work with invite links, it will need to generate its own link using :class:`aiogram.methods.export_chat_invite_link.ExportChatInviteLink` or by calling the :class:`aiogram.methods.get_chat.GetChat` method. If your bot needs to generate a new primary invite link replacing its previous one, use :class:`aiogram.methods.export_chat_invite_link.ExportChatInviteLink` again. Note: Each administrator in a chat generates their own invite links. Bots can't use invite links generated by other administrators. If you want your bot to work with invite links, it will need to generate its own link using :class:`aiogram.methods.export_chat_invite_link.ExportChatInviteLink` or by calling the :class:`aiogram.methods.get_chat.GetChat` method. If your bot needs to generate a new primary invite link replacing its previous one, use :class:`aiogram.methods.export_chat_invite_link.ExportChatInviteLink` again.
@ -1681,25 +1683,31 @@ class Bot(ContextInstanceMixin["Bot"]):
async def create_chat_invite_link( async def create_chat_invite_link(
self, self,
chat_id: Union[int, str], chat_id: Union[int, str],
name: Optional[str] = None,
expire_date: Optional[int] = None, expire_date: Optional[int] = None,
member_limit: Optional[int] = None, member_limit: Optional[int] = None,
creates_join_request: Optional[bool] = None,
request_timeout: Optional[int] = None, request_timeout: Optional[int] = None,
) -> ChatInviteLink: ) -> ChatInviteLink:
""" """
Use this method to create an additional invite link for a chat. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. The link can be revoked using the method :class:`aiogram.methods.revoke_chat_invite_link.RevokeChatInviteLink`. Returns the new invite link as :class:`aiogram.types.chat_invite_link.ChatInviteLink` object. Use this method to create an additional invite link for a chat. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. The link can be revoked using the method :class:`aiogram.methods.revoke_chat_invite_link.RevokeChatInviteLink`. Returns the new invite link as :class:`aiogram.types.chat_invite_link.ChatInviteLink` object.
Source: https://core.telegram.org/bots/api#createchatinvitelink Source: https://core.telegram.org/bots/api#createchatinvitelink
: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 name: Invite link name; 0-32 characters
:param expire_date: Point in time (Unix timestamp) when the link will expire :param expire_date: Point in time (Unix timestamp) when the link will expire
:param member_limit: Maximum number of users that can be members of the chat simultaneously after joining the chat via this invite link; 1-99999 :param member_limit: Maximum number of users that can be members of the chat simultaneously after joining the chat via this invite link; 1-99999
:param creates_join_request: :code:`True`, if users joining the chat via the link need to be approved by chat administrators. If :code:`True`, *member_limit* can't be specified
:param request_timeout: Request timeout :param request_timeout: Request timeout
:return: Returns the new invite link as ChatInviteLink object. :return: Returns the new invite link as ChatInviteLink object.
""" """
call = CreateChatInviteLink( call = CreateChatInviteLink(
chat_id=chat_id, chat_id=chat_id,
name=name,
expire_date=expire_date, expire_date=expire_date,
member_limit=member_limit, member_limit=member_limit,
creates_join_request=creates_join_request,
) )
return await self(call, request_timeout=request_timeout) return await self(call, request_timeout=request_timeout)
@ -1707,27 +1715,33 @@ class Bot(ContextInstanceMixin["Bot"]):
self, self,
chat_id: Union[int, str], chat_id: Union[int, str],
invite_link: str, invite_link: str,
name: Optional[str] = None,
expire_date: Optional[int] = None, expire_date: Optional[int] = None,
member_limit: Optional[int] = None, member_limit: Optional[int] = None,
creates_join_request: Optional[bool] = None,
request_timeout: Optional[int] = None, request_timeout: Optional[int] = None,
) -> ChatInviteLink: ) -> ChatInviteLink:
""" """
Use this method to edit a non-primary invite link created by the bot. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns the edited invite link as a :class:`aiogram.types.chat_invite_link.ChatInviteLink` object. Use this method to edit a non-primary invite link created by the bot. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the edited invite link as a :class:`aiogram.types.chat_invite_link.ChatInviteLink` object.
Source: https://core.telegram.org/bots/api#editchatinvitelink Source: https://core.telegram.org/bots/api#editchatinvitelink
: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 invite_link: The invite link to edit :param invite_link: The invite link to edit
:param name: Invite link name; 0-32 characters
:param expire_date: Point in time (Unix timestamp) when the link will expire :param expire_date: Point in time (Unix timestamp) when the link will expire
:param member_limit: Maximum number of users that can be members of the chat simultaneously after joining the chat via this invite link; 1-99999 :param member_limit: Maximum number of users that can be members of the chat simultaneously after joining the chat via this invite link; 1-99999
:param creates_join_request: :code:`True`, if users joining the chat via the link need to be approved by chat administrators. If :code:`True`, *member_limit* can't be specified
:param request_timeout: Request timeout :param request_timeout: Request timeout
:return: Returns the edited invite link as a ChatInviteLink object. :return: Returns the edited invite link as a ChatInviteLink object.
""" """
call = EditChatInviteLink( call = EditChatInviteLink(
chat_id=chat_id, chat_id=chat_id,
invite_link=invite_link, invite_link=invite_link,
name=name,
expire_date=expire_date, expire_date=expire_date,
member_limit=member_limit, member_limit=member_limit,
creates_join_request=creates_join_request,
) )
return await self(call, request_timeout=request_timeout) return await self(call, request_timeout=request_timeout)
@ -1738,7 +1752,7 @@ class Bot(ContextInstanceMixin["Bot"]):
request_timeout: Optional[int] = None, request_timeout: Optional[int] = None,
) -> ChatInviteLink: ) -> ChatInviteLink:
""" """
Use this method to revoke an invite link created by the bot. If the primary link is revoked, a new link is automatically generated. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns the revoked invite link as :class:`aiogram.types.chat_invite_link.ChatInviteLink` object. Use this method to revoke an invite link created by the bot. If the primary link is revoked, a new link is automatically generated. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the revoked invite link as :class:`aiogram.types.chat_invite_link.ChatInviteLink` object.
Source: https://core.telegram.org/bots/api#revokechatinvitelink Source: https://core.telegram.org/bots/api#revokechatinvitelink
@ -1753,6 +1767,50 @@ class Bot(ContextInstanceMixin["Bot"]):
) )
return await self(call, request_timeout=request_timeout) return await self(call, request_timeout=request_timeout)
async def approve_chat_join_request(
self,
chat_id: Union[int, str],
user_id: int,
request_timeout: Optional[int] = None,
) -> bool:
"""
Use this method to approve a chat join request. The bot must be an administrator in the chat for this to work and must have the *can_invite_users* administrator right. Returns :code:`True` on success.
Source: https://core.telegram.org/bots/api#approvechatjoinrequest
: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 request_timeout: Request timeout
:return: Returns True on success.
"""
call = ApproveChatJoinRequest(
chat_id=chat_id,
user_id=user_id,
)
return await self(call, request_timeout=request_timeout)
async def decline_chat_join_request(
self,
chat_id: Union[int, str],
user_id: int,
request_timeout: Optional[int] = None,
) -> bool:
"""
Use this method to decline a chat join request. The bot must be an administrator in the chat for this to work and must have the *can_invite_users* administrator right. Returns :code:`True` on success.
Source: https://core.telegram.org/bots/api#declinechatjoinrequest
: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 request_timeout: Request timeout
:return: Returns True on success.
"""
call = DeclineChatJoinRequest(
chat_id=chat_id,
user_id=user_id,
)
return await self(call, request_timeout=request_timeout)
async def set_chat_photo( async def set_chat_photo(
self, self,
chat_id: Union[int, str], chat_id: Union[int, str],
@ -1760,7 +1818,7 @@ class Bot(ContextInstanceMixin["Bot"]):
request_timeout: Optional[int] = None, request_timeout: Optional[int] = None,
) -> bool: ) -> bool:
""" """
Use this method to set a new profile photo for the chat. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns :code:`True` on success. Use this method to set a new profile photo for the chat. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns :code:`True` on success.
Source: https://core.telegram.org/bots/api#setchatphoto Source: https://core.telegram.org/bots/api#setchatphoto
@ -1781,7 +1839,7 @@ class Bot(ContextInstanceMixin["Bot"]):
request_timeout: Optional[int] = None, request_timeout: Optional[int] = None,
) -> bool: ) -> bool:
""" """
Use this method to delete a chat photo. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns :code:`True` on success. Use this method to delete a chat photo. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns :code:`True` on success.
Source: https://core.telegram.org/bots/api#deletechatphoto Source: https://core.telegram.org/bots/api#deletechatphoto
@ -1801,7 +1859,7 @@ class Bot(ContextInstanceMixin["Bot"]):
request_timeout: Optional[int] = None, request_timeout: Optional[int] = None,
) -> bool: ) -> bool:
""" """
Use this method to change the title of a chat. Titles can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns :code:`True` on success. Use this method to change the title of a chat. Titles can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns :code:`True` on success.
Source: https://core.telegram.org/bots/api#setchattitle Source: https://core.telegram.org/bots/api#setchattitle
@ -1823,7 +1881,7 @@ class Bot(ContextInstanceMixin["Bot"]):
request_timeout: Optional[int] = None, request_timeout: Optional[int] = None,
) -> bool: ) -> bool:
""" """
Use this method to change the description of a group, a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns :code:`True` on success. Use this method to change the description of a group, a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns :code:`True` on success.
Source: https://core.telegram.org/bots/api#setchatdescription Source: https://core.telegram.org/bots/api#setchatdescription
@ -1846,7 +1904,7 @@ class Bot(ContextInstanceMixin["Bot"]):
request_timeout: Optional[int] = None, request_timeout: Optional[int] = None,
) -> bool: ) -> bool:
""" """
Use this method to add a message to the list of pinned messages in a chat. If the chat is not a private chat, the bot must be an administrator in the chat for this to work and must have the 'can_pin_messages' admin right in a supergroup or 'can_edit_messages' admin right in a channel. Returns :code:`True` on success. Use this method to add a message to the list of pinned messages in a chat. If the chat is not a private chat, the bot must be an administrator in the chat for this to work and must have the 'can_pin_messages' administrator right in a supergroup or 'can_edit_messages' administrator right in a channel. Returns :code:`True` on success.
Source: https://core.telegram.org/bots/api#pinchatmessage Source: https://core.telegram.org/bots/api#pinchatmessage
@ -1870,7 +1928,7 @@ class Bot(ContextInstanceMixin["Bot"]):
request_timeout: Optional[int] = None, request_timeout: Optional[int] = None,
) -> bool: ) -> bool:
""" """
Use this method to remove a message from the list of pinned messages in a chat. If the chat is not a private chat, the bot must be an administrator in the chat for this to work and must have the 'can_pin_messages' admin right in a supergroup or 'can_edit_messages' admin right in a channel. Returns :code:`True` on success. Use this method to remove a message from the list of pinned messages in a chat. If the chat is not a private chat, the bot must be an administrator in the chat for this to work and must have the 'can_pin_messages' administrator right in a supergroup or 'can_edit_messages' administrator right in a channel. Returns :code:`True` on success.
Source: https://core.telegram.org/bots/api#unpinchatmessage Source: https://core.telegram.org/bots/api#unpinchatmessage
@ -1891,7 +1949,7 @@ class Bot(ContextInstanceMixin["Bot"]):
request_timeout: Optional[int] = None, request_timeout: Optional[int] = None,
) -> bool: ) -> bool:
""" """
Use this method to clear the list of pinned messages in a chat. If the chat is not a private chat, the bot must be an administrator in the chat for this to work and must have the 'can_pin_messages' admin right in a supergroup or 'can_edit_messages' admin right in a channel. Returns :code:`True` on success. Use this method to clear the list of pinned messages in a chat. If the chat is not a private chat, the bot must be an administrator in the chat for this to work and must have the 'can_pin_messages' administrator right in a supergroup or 'can_edit_messages' administrator right in a channel. Returns :code:`True` on success.
Source: https://core.telegram.org/bots/api#unpinallchatmessages Source: https://core.telegram.org/bots/api#unpinallchatmessages
@ -2051,7 +2109,7 @@ class Bot(ContextInstanceMixin["Bot"]):
request_timeout: Optional[int] = None, request_timeout: Optional[int] = None,
) -> bool: ) -> bool:
""" """
Use this method to set a new group sticker set for a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Use the field *can_set_sticker_set* optionally returned in :class:`aiogram.methods.get_chat.GetChat` requests to check if the bot can use this method. Returns :code:`True` on success. Use this method to set a new group sticker set for a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Use the field *can_set_sticker_set* optionally returned in :class:`aiogram.methods.get_chat.GetChat` requests to check if the bot can use this method. Returns :code:`True` on success.
Source: https://core.telegram.org/bots/api#setchatstickerset Source: https://core.telegram.org/bots/api#setchatstickerset
@ -2073,7 +2131,7 @@ class Bot(ContextInstanceMixin["Bot"]):
request_timeout: Optional[int] = None, request_timeout: Optional[int] = None,
) -> bool: ) -> bool:
""" """
Use this method to delete a group sticker set from a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Use the field *can_set_sticker_set* optionally returned in :class:`aiogram.methods.get_chat.GetChat` requests to check if the bot can use this method. Returns :code:`True` on success. Use this method to delete a group sticker set from a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Use the field *can_set_sticker_set* optionally returned in :class:`aiogram.methods.get_chat.GetChat` requests to check if the bot can use this method. Returns :code:`True` on success.
Source: https://core.telegram.org/bots/api#deletechatstickerset Source: https://core.telegram.org/bots/api#deletechatstickerset
@ -2105,7 +2163,7 @@ class Bot(ContextInstanceMixin["Bot"]):
:param callback_query_id: Unique identifier for the query to be answered :param callback_query_id: Unique identifier for the query to be answered
:param text: Text of the notification. If not specified, nothing will be shown to the user, 0-200 characters :param text: Text of the notification. If not specified, nothing will be shown to the user, 0-200 characters
:param show_alert: If *true*, an alert will be shown by the client instead of a notification at the top of the chat screen. Defaults to *false*. :param show_alert: If :code:`True`, an alert will be shown by the client instead of a notification at the top of the chat screen. Defaults to *false*.
:param url: URL that will be opened by the user's client. If you have created a :class:`aiogram.types.game.Game` and accepted the conditions via `@Botfather <https://t.me/botfather>`_, specify the URL that opens your game — note that this will only work if the query comes from a `https://core.telegram.org/bots/api#inlinekeyboardbutton <https://core.telegram.org/bots/api#inlinekeyboardbutton>`_ *callback_game* button. :param url: URL that will be opened by the user's client. If you have created a :class:`aiogram.types.game.Game` and accepted the conditions via `@Botfather <https://t.me/botfather>`_, specify the URL that opens your game — note that this will only work if the query comes from a `https://core.telegram.org/bots/api#inlinekeyboardbutton <https://core.telegram.org/bots/api#inlinekeyboardbutton>`_ *callback_game* button.
:param cache_time: The maximum amount of time in seconds that the result of the callback query may be cached client-side. Telegram apps will support caching starting in version 3.14. Defaults to 0. :param cache_time: The maximum amount of time in seconds that the result of the callback query may be cached client-side. Telegram apps will support caching starting in version 3.14. Defaults to 0.
:param request_timeout: Request timeout :param request_timeout: Request timeout
@ -2217,7 +2275,7 @@ class Bot(ContextInstanceMixin["Bot"]):
:param message_id: Required if *inline_message_id* is not specified. Identifier of the message to edit :param message_id: Required if *inline_message_id* is not specified. Identifier of the message to edit
: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 parse_mode: Mode for parsing entities in the message text. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details. :param parse_mode: Mode for parsing entities in the message text. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details.
:param entities: List of special entities that appear in message text, which can be specified instead of *parse_mode* :param entities: A JSON-serialized list of special entities that appear in message text, which can be specified instead of *parse_mode*
:param disable_web_page_preview: Disables link previews for links in this message :param disable_web_page_preview: Disables link previews for links in this message
:param reply_markup: A JSON-serialized object for an `inline keyboard <https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating>`_. :param reply_markup: A JSON-serialized object for an `inline keyboard <https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating>`_.
:param request_timeout: Request timeout :param request_timeout: Request timeout
@ -2257,7 +2315,7 @@ 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 caption: New caption of the message, 0-1024 characters after entities parsing :param caption: New caption of the message, 0-1024 characters after entities parsing
:param parse_mode: Mode for parsing entities in the message caption. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details. :param parse_mode: Mode for parsing entities in the message caption. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details.
:param caption_entities: 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 reply_markup: A JSON-serialized object for an `inline keyboard <https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating>`_. :param reply_markup: A JSON-serialized object for an `inline keyboard <https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating>`_.
:param request_timeout: Request timeout :param request_timeout: Request timeout
:return: On success, if the edited message is not an inline message, the edited Message is :return: On success, if the edited message is not an inline message, the edited Message is
@ -2284,7 +2342,7 @@ class Bot(ContextInstanceMixin["Bot"]):
request_timeout: Optional[int] = None, request_timeout: Optional[int] = None,
) -> Union[Message, bool]: ) -> Union[Message, bool]:
""" """
Use this method to edit animation, audio, document, photo, or video messages. If a message is part of a message album, then it can be edited only to an audio for audio albums, only to a document for document albums and to a photo or a video otherwise. When an inline message is edited, a new file can't be uploaded. Use a previously uploaded file via its file_id or specify a URL. On success, if the edited message was sent by the bot, the edited :class:`aiogram.types.message.Message` is returned, otherwise :code:`True` is returned. Use this method to edit animation, audio, document, photo, or video messages. If a message is part of a message album, then it can be edited only to an audio for audio albums, only to a document for document albums and to a photo or a video otherwise. When an inline message is edited, a new file can't be uploaded; use a previously uploaded file via its file_id or specify a URL. On success, if the edited message is not an inline message, the edited :class:`aiogram.types.message.Message` is returned, otherwise :code:`True` is returned.
Source: https://core.telegram.org/bots/api#editmessagemedia Source: https://core.telegram.org/bots/api#editmessagemedia
@ -2294,7 +2352,7 @@ 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 reply_markup: A JSON-serialized object for a new `inline keyboard <https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating>`_. :param reply_markup: A JSON-serialized object for a new `inline keyboard <https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating>`_.
:param request_timeout: Request timeout :param request_timeout: Request timeout
:return: On success, if the edited message was sent by the bot, the edited Message is :return: On success, if the edited message is not an inline message, the edited Message is
returned, otherwise True is returned. returned, otherwise True is returned.
""" """
call = EditMessageMedia( call = EditMessageMedia(
@ -2343,7 +2401,7 @@ class Bot(ContextInstanceMixin["Bot"]):
request_timeout: Optional[int] = None, request_timeout: Optional[int] = None,
) -> Poll: ) -> Poll:
""" """
Use this method to stop a poll which was sent by the bot. On success, the stopped :class:`aiogram.types.poll.Poll` with the final results is returned. Use this method to stop a poll which was sent by the bot. On success, the stopped :class:`aiogram.types.poll.Poll` is returned.
Source: https://core.telegram.org/bots/api#stoppoll Source: https://core.telegram.org/bots/api#stoppoll
@ -2351,7 +2409,7 @@ class Bot(ContextInstanceMixin["Bot"]):
:param message_id: Identifier of the original message with the poll :param message_id: Identifier of the original message with the poll
:param reply_markup: A JSON-serialized object for a new message `inline keyboard <https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating>`_. :param reply_markup: A JSON-serialized object for a new message `inline keyboard <https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating>`_.
:param request_timeout: Request timeout :param request_timeout: Request timeout
:return: On success, the stopped Poll with the final results is returned. :return: On success, the stopped Poll is returned.
""" """
call = StopPoll( call = StopPoll(
chat_id=chat_id, chat_id=chat_id,
@ -2772,13 +2830,13 @@ class Bot(ContextInstanceMixin["Bot"]):
request_timeout: Optional[int] = None, request_timeout: Optional[int] = None,
) -> bool: ) -> bool:
""" """
If you sent an invoice requesting a shipping address and the parameter *is_flexible* was specified, the Bot API will send an :class:`aiogram.types.update.Update` with a *shipping_query* field to the bot. Use this method to reply to shipping queries. On success, True is returned. If you sent an invoice requesting a shipping address and the parameter *is_flexible* was specified, the Bot API will send an :class:`aiogram.types.update.Update` with a *shipping_query* field to the bot. Use this method to reply to shipping queries. On success, :code:`True` is returned.
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 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: 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 shipping_options: Required if *ok* is 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 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.
@ -2799,7 +2857,7 @@ class Bot(ContextInstanceMixin["Bot"]):
request_timeout: Optional[int] = None, request_timeout: Optional[int] = None,
) -> bool: ) -> bool:
""" """
Once the user has confirmed their payment and shipping details, the Bot API sends the final confirmation in the form of an :class:`aiogram.types.update.Update` with the field *pre_checkout_query*. Use this method to respond to such pre-checkout queries. On success, True is returned. **Note:** The Bot API must receive an answer within 10 seconds after the pre-checkout query was sent. Once the user has confirmed their payment and shipping details, the Bot API sends the final confirmation in the form of an :class:`aiogram.types.update.Update` with the field *pre_checkout_query*. Use this method to respond to such pre-checkout queries. On success, :code:`True` is returned. **Note:** The Bot API must receive an answer within 10 seconds after the pre-checkout query was sent.
Source: https://core.telegram.org/bots/api#answerprecheckoutquery Source: https://core.telegram.org/bots/api#answerprecheckoutquery
@ -2897,21 +2955,21 @@ class Bot(ContextInstanceMixin["Bot"]):
request_timeout: Optional[int] = None, request_timeout: Optional[int] = None,
) -> Union[Message, bool]: ) -> Union[Message, bool]:
""" """
Use this method to set the score of the specified user in a game. On success, if the message was sent by the bot, returns the edited :class:`aiogram.types.message.Message`, otherwise returns :code:`True`. Returns an error, if the new score is not greater than the user's current score in the chat and *force* is :code:`False`. Use this method to set the score of the specified user in a game message. On success, if the message is not an inline message, the :class:`aiogram.types.message.Message` is returned, otherwise :code:`True` is returned. Returns an error, if the new score is not greater than the user's current score in the chat and *force* is :code:`False`.
Source: https://core.telegram.org/bots/api#setgamescore Source: https://core.telegram.org/bots/api#setgamescore
: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 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 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
:param request_timeout: Request timeout :param request_timeout: Request timeout
:return: On success, if the message was sent by the bot, returns the edited Message, :return: On success, if the message is not an inline message, the Message is returned,
otherwise returns True. Returns an error, if the new score is not greater than otherwise True is returned. Returns an error, if the new score is not greater
the user's current score in the chat and force is False. than the user's current score in the chat and force is False.
""" """
call = SetGameScore( call = SetGameScore(
user_id=user_id, user_id=user_id,

View file

@ -89,6 +89,10 @@ BUILTIN_FILTERS: Dict[str, Tuple[Type[BaseFilter], ...]] = {
*_ALL_EVENTS_FILTERS, *_ALL_EVENTS_FILTERS,
*_TELEGRAM_EVENTS_FILTERS, *_TELEGRAM_EVENTS_FILTERS,
), ),
"chat_join_request": (
*_ALL_EVENTS_FILTERS,
*_TELEGRAM_EVENTS_FILTERS,
),
"error": ( "error": (
ExceptionMessageFilter, ExceptionMessageFilter,
ExceptionTypeFilter, ExceptionTypeFilter,

View file

@ -69,4 +69,6 @@ class UserContextMiddleware(BaseMiddleware):
return event.my_chat_member.chat, event.my_chat_member.from_user return event.my_chat_member.chat, event.my_chat_member.from_user
if event.chat_member: if event.chat_member:
return event.chat_member.chat, event.chat_member.from_user return event.chat_member.chat, event.chat_member.from_user
if event.chat_join_request:
return event.chat_join_request.chat, event.chat_join_request.from_user
return None, None return None, None

View file

@ -58,6 +58,7 @@ class Router:
self.poll_answer = TelegramEventObserver(router=self, event_name="poll_answer") self.poll_answer = TelegramEventObserver(router=self, event_name="poll_answer")
self.my_chat_member = TelegramEventObserver(router=self, event_name="my_chat_member") self.my_chat_member = TelegramEventObserver(router=self, event_name="my_chat_member")
self.chat_member = TelegramEventObserver(router=self, event_name="chat_member") self.chat_member = TelegramEventObserver(router=self, event_name="chat_member")
self.chat_join_request = TelegramEventObserver(router=self, event_name="chat_join_request")
self.errors = TelegramEventObserver(router=self, event_name="error") self.errors = TelegramEventObserver(router=self, event_name="error")
@ -78,6 +79,7 @@ class Router:
"poll_answer": self.poll_answer, "poll_answer": self.poll_answer,
"my_chat_member": self.my_chat_member, "my_chat_member": self.my_chat_member,
"chat_member": self.chat_member, "chat_member": self.chat_member,
"chat_join_request": self.chat_join_request,
"error": self.errors, "error": self.errors,
} }

View file

@ -3,12 +3,14 @@ from .answer_callback_query import AnswerCallbackQuery
from .answer_inline_query import AnswerInlineQuery from .answer_inline_query import AnswerInlineQuery
from .answer_pre_checkout_query import AnswerPreCheckoutQuery from .answer_pre_checkout_query import AnswerPreCheckoutQuery
from .answer_shipping_query import AnswerShippingQuery from .answer_shipping_query import AnswerShippingQuery
from .approve_chat_join_request import ApproveChatJoinRequest
from .ban_chat_member import BanChatMember from .ban_chat_member import BanChatMember
from .base import Request, Response, TelegramMethod from .base import Request, Response, TelegramMethod
from .close import Close from .close import Close
from .copy_message import CopyMessage from .copy_message import CopyMessage
from .create_chat_invite_link import CreateChatInviteLink from .create_chat_invite_link import CreateChatInviteLink
from .create_new_sticker_set import CreateNewStickerSet from .create_new_sticker_set import CreateNewStickerSet
from .decline_chat_join_request import DeclineChatJoinRequest
from .delete_chat_photo import DeleteChatPhoto from .delete_chat_photo import DeleteChatPhoto
from .delete_chat_sticker_set import DeleteChatStickerSet from .delete_chat_sticker_set import DeleteChatStickerSet
from .delete_message import DeleteMessage from .delete_message import DeleteMessage
@ -123,6 +125,8 @@ __all__ = (
"CreateChatInviteLink", "CreateChatInviteLink",
"EditChatInviteLink", "EditChatInviteLink",
"RevokeChatInviteLink", "RevokeChatInviteLink",
"ApproveChatJoinRequest",
"DeclineChatJoinRequest",
"SetChatPhoto", "SetChatPhoto",
"DeleteChatPhoto", "DeleteChatPhoto",
"SetChatTitle", "SetChatTitle",

View file

@ -24,7 +24,7 @@ class AnswerCallbackQuery(TelegramMethod[bool]):
text: Optional[str] = None text: Optional[str] = None
"""Text of the notification. If not specified, nothing will be shown to the user, 0-200 characters""" """Text of the notification. If not specified, nothing will be shown to the user, 0-200 characters"""
show_alert: Optional[bool] = None show_alert: Optional[bool] = None
"""If *true*, an alert will be shown by the client instead of a notification at the top of the chat screen. Defaults to *false*.""" """If :code:`True`, an alert will be shown by the client instead of a notification at the top of the chat screen. Defaults to *false*."""
url: Optional[str] = None url: Optional[str] = None
"""URL that will be opened by the user's client. If you have created a :class:`aiogram.types.game.Game` and accepted the conditions via `@Botfather <https://t.me/botfather>`_, specify the URL that opens your game — note that this will only work if the query comes from a `https://core.telegram.org/bots/api#inlinekeyboardbutton <https://core.telegram.org/bots/api#inlinekeyboardbutton>`_ *callback_game* button.""" """URL that will be opened by the user's client. If you have created a :class:`aiogram.types.game.Game` and accepted the conditions via `@Botfather <https://t.me/botfather>`_, specify the URL that opens your game — note that this will only work if the query comes from a `https://core.telegram.org/bots/api#inlinekeyboardbutton <https://core.telegram.org/bots/api#inlinekeyboardbutton>`_ *callback_game* button."""
cache_time: Optional[int] = None cache_time: Optional[int] = None

View file

@ -10,7 +10,7 @@ if TYPE_CHECKING:
class AnswerPreCheckoutQuery(TelegramMethod[bool]): class AnswerPreCheckoutQuery(TelegramMethod[bool]):
""" """
Once the user has confirmed their payment and shipping details, the Bot API sends the final confirmation in the form of an :class:`aiogram.types.update.Update` with the field *pre_checkout_query*. Use this method to respond to such pre-checkout queries. On success, True is returned. **Note:** The Bot API must receive an answer within 10 seconds after the pre-checkout query was sent. Once the user has confirmed their payment and shipping details, the Bot API sends the final confirmation in the form of an :class:`aiogram.types.update.Update` with the field *pre_checkout_query*. Use this method to respond to such pre-checkout queries. On success, :code:`True` is returned. **Note:** The Bot API must receive an answer within 10 seconds after the pre-checkout query was sent.
Source: https://core.telegram.org/bots/api#answerprecheckoutquery Source: https://core.telegram.org/bots/api#answerprecheckoutquery
""" """

View file

@ -11,7 +11,7 @@ if TYPE_CHECKING:
class AnswerShippingQuery(TelegramMethod[bool]): class AnswerShippingQuery(TelegramMethod[bool]):
""" """
If you sent an invoice requesting a shipping address and the parameter *is_flexible* was specified, the Bot API will send an :class:`aiogram.types.update.Update` with a *shipping_query* field to the bot. Use this method to reply to shipping queries. On success, True is returned. If you sent an invoice requesting a shipping address and the parameter *is_flexible* was specified, the Bot API will send an :class:`aiogram.types.update.Update` with a *shipping_query* field to the bot. Use this method to reply to shipping queries. On success, :code:`True` is returned.
Source: https://core.telegram.org/bots/api#answershippingquery Source: https://core.telegram.org/bots/api#answershippingquery
""" """
@ -21,9 +21,9 @@ 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 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)""" """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)"""
shipping_options: Optional[List[ShippingOption]] = None shipping_options: Optional[List[ShippingOption]] = None
"""Required if *ok* is 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 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."""

View file

@ -0,0 +1,28 @@
from __future__ import annotations
from typing import TYPE_CHECKING, Any, Dict, Union
from .base import Request, TelegramMethod
if TYPE_CHECKING:
from ..client.bot import Bot
class ApproveChatJoinRequest(TelegramMethod[bool]):
"""
Use this method to approve a chat join request. The bot must be an administrator in the chat for this to work and must have the *can_invite_users* administrator right. Returns :code:`True` on success.
Source: https://core.telegram.org/bots/api#approvechatjoinrequest
"""
__returning__ = bool
chat_id: Union[int, str]
"""Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)"""
user_id: int
"""Unique identifier of the target user"""
def build_request(self, bot: Bot) -> Request:
data: Dict[str, Any] = self.dict()
return Request(method="approveChatJoinRequest", data=data)

View file

@ -11,7 +11,7 @@ if TYPE_CHECKING:
class BanChatMember(TelegramMethod[bool]): class BanChatMember(TelegramMethod[bool]):
""" """
Use this method to ban a user in a group, a supergroup or a channel. In the case of supergroups and channels, the user will not be able to return to the chat on their own using invite links, etc., unless `unbanned <https://core.telegram.org/bots/api#unbanchatmember>`_ first. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns :code:`True` on success. Use this method to ban a user in a group, a supergroup or a channel. In the case of supergroups and channels, the user will not be able to return to the chat on their own using invite links, etc., unless `unbanned <https://core.telegram.org/bots/api#unbanchatmember>`_ first. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns :code:`True` on success.
Source: https://core.telegram.org/bots/api#banchatmember Source: https://core.telegram.org/bots/api#banchatmember
""" """

View file

@ -37,7 +37,7 @@ class CopyMessage(TelegramMethod[MessageId]):
parse_mode: Optional[str] = UNSET parse_mode: Optional[str] = UNSET
"""Mode for parsing entities in the new caption. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details.""" """Mode for parsing entities in the new caption. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details."""
caption_entities: Optional[List[MessageEntity]] = None caption_entities: Optional[List[MessageEntity]] = None
"""List of special entities that appear in the new caption, which can be specified instead of *parse_mode*""" """A JSON-serialized list of special entities that appear in the new caption, which can be specified instead of *parse_mode*"""
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."""
reply_to_message_id: Optional[int] = None reply_to_message_id: Optional[int] = None

View file

@ -11,7 +11,7 @@ if TYPE_CHECKING:
class CreateChatInviteLink(TelegramMethod[ChatInviteLink]): class CreateChatInviteLink(TelegramMethod[ChatInviteLink]):
""" """
Use this method to create an additional invite link for a chat. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. The link can be revoked using the method :class:`aiogram.methods.revoke_chat_invite_link.RevokeChatInviteLink`. Returns the new invite link as :class:`aiogram.types.chat_invite_link.ChatInviteLink` object. Use this method to create an additional invite link for a chat. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. The link can be revoked using the method :class:`aiogram.methods.revoke_chat_invite_link.RevokeChatInviteLink`. Returns the new invite link as :class:`aiogram.types.chat_invite_link.ChatInviteLink` object.
Source: https://core.telegram.org/bots/api#createchatinvitelink Source: https://core.telegram.org/bots/api#createchatinvitelink
""" """
@ -20,10 +20,14 @@ class CreateChatInviteLink(TelegramMethod[ChatInviteLink]):
chat_id: Union[int, str] chat_id: Union[int, str]
"""Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)""" """Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)"""
name: Optional[str] = None
"""Invite link name; 0-32 characters"""
expire_date: Optional[int] = None expire_date: Optional[int] = None
"""Point in time (Unix timestamp) when the link will expire""" """Point in time (Unix timestamp) when the link will expire"""
member_limit: Optional[int] = None member_limit: Optional[int] = None
"""Maximum number of users that can be members of the chat simultaneously after joining the chat via this invite link; 1-99999""" """Maximum number of users that can be members of the chat simultaneously after joining the chat via this invite link; 1-99999"""
creates_join_request: Optional[bool] = None
""":code:`True`, if users joining the chat via the link need to be approved by chat administrators. If :code:`True`, *member_limit* can't be specified"""
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

@ -0,0 +1,28 @@
from __future__ import annotations
from typing import TYPE_CHECKING, Any, Dict, Union
from .base import Request, TelegramMethod
if TYPE_CHECKING:
from ..client.bot import Bot
class DeclineChatJoinRequest(TelegramMethod[bool]):
"""
Use this method to decline a chat join request. The bot must be an administrator in the chat for this to work and must have the *can_invite_users* administrator right. Returns :code:`True` on success.
Source: https://core.telegram.org/bots/api#declinechatjoinrequest
"""
__returning__ = bool
chat_id: Union[int, str]
"""Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)"""
user_id: int
"""Unique identifier of the target user"""
def build_request(self, bot: Bot) -> Request:
data: Dict[str, Any] = self.dict()
return Request(method="declineChatJoinRequest", data=data)

View file

@ -10,7 +10,7 @@ if TYPE_CHECKING:
class DeleteChatPhoto(TelegramMethod[bool]): class DeleteChatPhoto(TelegramMethod[bool]):
""" """
Use this method to delete a chat photo. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns :code:`True` on success. Use this method to delete a chat photo. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns :code:`True` on success.
Source: https://core.telegram.org/bots/api#deletechatphoto Source: https://core.telegram.org/bots/api#deletechatphoto
""" """

View file

@ -10,7 +10,7 @@ if TYPE_CHECKING:
class DeleteChatStickerSet(TelegramMethod[bool]): class DeleteChatStickerSet(TelegramMethod[bool]):
""" """
Use this method to delete a group sticker set from a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Use the field *can_set_sticker_set* optionally returned in :class:`aiogram.methods.get_chat.GetChat` requests to check if the bot can use this method. Returns :code:`True` on success. Use this method to delete a group sticker set from a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Use the field *can_set_sticker_set* optionally returned in :class:`aiogram.methods.get_chat.GetChat` requests to check if the bot can use this method. Returns :code:`True` on success.
Source: https://core.telegram.org/bots/api#deletechatstickerset Source: https://core.telegram.org/bots/api#deletechatstickerset
""" """

View file

@ -11,7 +11,7 @@ if TYPE_CHECKING:
class EditChatInviteLink(TelegramMethod[ChatInviteLink]): class EditChatInviteLink(TelegramMethod[ChatInviteLink]):
""" """
Use this method to edit a non-primary invite link created by the bot. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns the edited invite link as a :class:`aiogram.types.chat_invite_link.ChatInviteLink` object. Use this method to edit a non-primary invite link created by the bot. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the edited invite link as a :class:`aiogram.types.chat_invite_link.ChatInviteLink` object.
Source: https://core.telegram.org/bots/api#editchatinvitelink Source: https://core.telegram.org/bots/api#editchatinvitelink
""" """
@ -22,10 +22,14 @@ class EditChatInviteLink(TelegramMethod[ChatInviteLink]):
"""Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)""" """Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)"""
invite_link: str invite_link: str
"""The invite link to edit""" """The invite link to edit"""
name: Optional[str] = None
"""Invite link name; 0-32 characters"""
expire_date: Optional[int] = None expire_date: Optional[int] = None
"""Point in time (Unix timestamp) when the link will expire""" """Point in time (Unix timestamp) when the link will expire"""
member_limit: Optional[int] = None member_limit: Optional[int] = None
"""Maximum number of users that can be members of the chat simultaneously after joining the chat via this invite link; 1-99999""" """Maximum number of users that can be members of the chat simultaneously after joining the chat via this invite link; 1-99999"""
creates_join_request: Optional[bool] = None
""":code:`True`, if users joining the chat via the link need to be approved by chat administrators. If :code:`True`, *member_limit* can't be specified"""
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

@ -29,7 +29,7 @@ class EditMessageCaption(TelegramMethod[Union[Message, bool]]):
parse_mode: Optional[str] = UNSET parse_mode: Optional[str] = UNSET
"""Mode for parsing entities in the message caption. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details.""" """Mode for parsing entities in the message caption. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details."""
caption_entities: Optional[List[MessageEntity]] = None caption_entities: Optional[List[MessageEntity]] = None
"""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*"""
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>`_.""" """A JSON-serialized object for an `inline keyboard <https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating>`_."""

View file

@ -11,7 +11,7 @@ if TYPE_CHECKING:
class EditMessageMedia(TelegramMethod[Union[Message, bool]]): class EditMessageMedia(TelegramMethod[Union[Message, bool]]):
""" """
Use this method to edit animation, audio, document, photo, or video messages. If a message is part of a message album, then it can be edited only to an audio for audio albums, only to a document for document albums and to a photo or a video otherwise. When an inline message is edited, a new file can't be uploaded. Use a previously uploaded file via its file_id or specify a URL. On success, if the edited message was sent by the bot, the edited :class:`aiogram.types.message.Message` is returned, otherwise :code:`True` is returned. Use this method to edit animation, audio, document, photo, or video messages. If a message is part of a message album, then it can be edited only to an audio for audio albums, only to a document for document albums and to a photo or a video otherwise. When an inline message is edited, a new file can't be uploaded; use a previously uploaded file via its file_id or specify a URL. On success, if the edited message is not an inline message, the edited :class:`aiogram.types.message.Message` is returned, otherwise :code:`True` is returned.
Source: https://core.telegram.org/bots/api#editmessagemedia Source: https://core.telegram.org/bots/api#editmessagemedia
""" """

View file

@ -29,7 +29,7 @@ class EditMessageText(TelegramMethod[Union[Message, bool]]):
parse_mode: Optional[str] = UNSET parse_mode: Optional[str] = UNSET
"""Mode for parsing entities in the message text. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details.""" """Mode for parsing entities in the message text. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details."""
entities: Optional[List[MessageEntity]] = None entities: Optional[List[MessageEntity]] = None
"""List of special entities that appear in message text, which can be specified instead of *parse_mode*""" """A JSON-serialized list of special entities that appear in message text, which can be specified instead of *parse_mode*"""
disable_web_page_preview: Optional[bool] = None disable_web_page_preview: Optional[bool] = None
"""Disables link previews for links in this message""" """Disables link previews for links in this message"""
reply_markup: Optional[InlineKeyboardMarkup] = None reply_markup: Optional[InlineKeyboardMarkup] = None

View file

@ -10,7 +10,7 @@ if TYPE_CHECKING:
class ExportChatInviteLink(TelegramMethod[str]): class ExportChatInviteLink(TelegramMethod[str]):
""" """
Use this method to generate a new primary invite link for a chat; any previously generated primary link is revoked. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns the new invite link as *String* on success. Use this method to generate a new primary invite link for a chat; any previously generated primary link is revoked. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the new invite link as *String* on success.
Note: Each administrator in a chat generates their own invite links. Bots can't use invite links generated by other administrators. If you want your bot to work with invite links, it will need to generate its own link using :class:`aiogram.methods.export_chat_invite_link.ExportChatInviteLink` or by calling the :class:`aiogram.methods.get_chat.GetChat` method. If your bot needs to generate a new primary invite link replacing its previous one, use :class:`aiogram.methods.export_chat_invite_link.ExportChatInviteLink` again. Note: Each administrator in a chat generates their own invite links. Bots can't use invite links generated by other administrators. If you want your bot to work with invite links, it will need to generate its own link using :class:`aiogram.methods.export_chat_invite_link.ExportChatInviteLink` or by calling the :class:`aiogram.methods.get_chat.GetChat` method. If your bot needs to generate a new primary invite link replacing its previous one, use :class:`aiogram.methods.export_chat_invite_link.ExportChatInviteLink` again.

View file

@ -11,7 +11,7 @@ if TYPE_CHECKING:
class GetMe(TelegramMethod[User]): class GetMe(TelegramMethod[User]):
""" """
A simple method for testing your bot's auth token. Requires no parameters. Returns basic information about the bot in form of a :class:`aiogram.types.user.User` object. A simple method for testing your bot's authentication token. Requires no parameters. Returns basic information about the bot in form of a :class:`aiogram.types.user.User` object.
Source: https://core.telegram.org/bots/api#getme Source: https://core.telegram.org/bots/api#getme
""" """

View file

@ -15,7 +15,7 @@ class KickChatMember(TelegramMethod[bool]):
Renamed from :code:`kickChatMember` in 5.3 bot API version and can be removed in near future Renamed from :code:`kickChatMember` in 5.3 bot API version and can be removed in near future
Use this method to ban a user in a group, a supergroup or a channel. In the case of supergroups and channels, the user will not be able to return to the chat on their own using invite links, etc., unless `unbanned <https://core.telegram.org/bots/api#unbanchatmember>`_ first. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns :code:`True` on success. Use this method to ban a user in a group, a supergroup or a channel. In the case of supergroups and channels, the user will not be able to return to the chat on their own using invite links, etc., unless `unbanned <https://core.telegram.org/bots/api#unbanchatmember>`_ first. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns :code:`True` on success.
Source: https://core.telegram.org/bots/api#banchatmember Source: https://core.telegram.org/bots/api#banchatmember
""" """

View file

@ -10,7 +10,7 @@ if TYPE_CHECKING:
class PinChatMessage(TelegramMethod[bool]): class PinChatMessage(TelegramMethod[bool]):
""" """
Use this method to add a message to the list of pinned messages in a chat. If the chat is not a private chat, the bot must be an administrator in the chat for this to work and must have the 'can_pin_messages' admin right in a supergroup or 'can_edit_messages' admin right in a channel. Returns :code:`True` on success. Use this method to add a message to the list of pinned messages in a chat. If the chat is not a private chat, the bot must be an administrator in the chat for this to work and must have the 'can_pin_messages' administrator right in a supergroup or 'can_edit_messages' administrator right in a channel. Returns :code:`True` on success.
Source: https://core.telegram.org/bots/api#pinchatmessage Source: https://core.telegram.org/bots/api#pinchatmessage
""" """

View file

@ -10,7 +10,7 @@ if TYPE_CHECKING:
class PromoteChatMember(TelegramMethod[bool]): class PromoteChatMember(TelegramMethod[bool]):
""" """
Use this method to promote or demote a user in a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Pass :code:`False` for all boolean parameters to demote a user. Returns :code:`True` on success. Use this method to promote or demote a user in a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Pass :code:`False` for all boolean parameters to demote a user. Returns :code:`True` on success.
Source: https://core.telegram.org/bots/api#promotechatmember Source: https://core.telegram.org/bots/api#promotechatmember
""" """
@ -24,25 +24,25 @@ class PromoteChatMember(TelegramMethod[bool]):
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 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 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 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 True, if the administrator can delete messages of other users""" """Pass :code:`True`, if the administrator can delete messages of other users"""
can_manage_voice_chats: Optional[bool] = None can_manage_voice_chats: Optional[bool] = None
"""Pass True, if the administrator can manage voice chats""" """Pass :code:`True`, if the administrator can manage voice chats"""
can_restrict_members: Optional[bool] = None can_restrict_members: Optional[bool] = None
"""Pass 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 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 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 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 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

@ -12,7 +12,7 @@ if TYPE_CHECKING:
class RestrictChatMember(TelegramMethod[bool]): class RestrictChatMember(TelegramMethod[bool]):
""" """
Use this method to restrict a user in a supergroup. The bot must be an administrator in the supergroup for this to work and must have the appropriate admin rights. Pass :code:`True` for all permissions to lift restrictions from a user. Returns :code:`True` on success. Use this method to restrict a user in a supergroup. The bot must be an administrator in the supergroup for this to work and must have the appropriate administrator rights. Pass :code:`True` for all permissions to lift restrictions from a user. Returns :code:`True` on success.
Source: https://core.telegram.org/bots/api#restrictchatmember Source: https://core.telegram.org/bots/api#restrictchatmember
""" """

View file

@ -11,7 +11,7 @@ if TYPE_CHECKING:
class RevokeChatInviteLink(TelegramMethod[ChatInviteLink]): class RevokeChatInviteLink(TelegramMethod[ChatInviteLink]):
""" """
Use this method to revoke an invite link created by the bot. If the primary link is revoked, a new link is automatically generated. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns the revoked invite link as :class:`aiogram.types.chat_invite_link.ChatInviteLink` object. Use this method to revoke an invite link created by the bot. If the primary link is revoked, a new link is automatically generated. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns the revoked invite link as :class:`aiogram.types.chat_invite_link.ChatInviteLink` object.
Source: https://core.telegram.org/bots/api#revokechatinvitelink Source: https://core.telegram.org/bots/api#revokechatinvitelink
""" """

View file

@ -44,7 +44,7 @@ class SendAnimation(TelegramMethod[Message]):
parse_mode: Optional[str] = UNSET parse_mode: Optional[str] = UNSET
"""Mode for parsing entities in the animation caption. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details.""" """Mode for parsing entities in the animation caption. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details."""
caption_entities: Optional[List[MessageEntity]] = None caption_entities: Optional[List[MessageEntity]] = None
"""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*"""
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."""
reply_to_message_id: Optional[int] = None reply_to_message_id: Optional[int] = None

View file

@ -37,7 +37,7 @@ class SendAudio(TelegramMethod[Message]):
parse_mode: Optional[str] = UNSET parse_mode: Optional[str] = UNSET
"""Mode for parsing entities in the audio caption. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details.""" """Mode for parsing entities in the audio caption. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details."""
caption_entities: Optional[List[MessageEntity]] = None caption_entities: Optional[List[MessageEntity]] = None
"""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*"""
duration: Optional[int] = None duration: Optional[int] = None
"""Duration of the audio in seconds""" """Duration of the audio in seconds"""
performer: Optional[str] = None performer: Optional[str] = None

View file

@ -24,7 +24,7 @@ class SendChatAction(TelegramMethod[bool]):
chat_id: Union[int, str] chat_id: Union[int, str]
"""Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)""" """Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)"""
action: str action: str
"""Type of action to broadcast. Choose one, depending on what the user is about to receive: *typing* for `text messages <https://core.telegram.org/bots/api#sendmessage>`_, *upload_photo* for `photos <https://core.telegram.org/bots/api#sendphoto>`_, *record_video* or *upload_video* for `videos <https://core.telegram.org/bots/api#sendvideo>`_, *record_voice* or *upload_voice* for `voice notes <https://core.telegram.org/bots/api#sendvoice>`_, *upload_document* for `general files <https://core.telegram.org/bots/api#senddocument>`_, *find_location* for `location data <https://core.telegram.org/bots/api#sendlocation>`_, *record_video_note* or *upload_video_note* for `video notes <https://core.telegram.org/bots/api#sendvideonote>`_.""" """Type of action to broadcast. Choose one, depending on what the user is about to receive: *typing* for `text messages <https://core.telegram.org/bots/api#sendmessage>`_, *upload_photo* for `photos <https://core.telegram.org/bots/api#sendphoto>`_, *record_video* or *upload_video* for `videos <https://core.telegram.org/bots/api#sendvideo>`_, *record_voice* or *upload_voice* for `voice notes <https://core.telegram.org/bots/api#sendvoice>`_, *upload_document* for `general files <https://core.telegram.org/bots/api#senddocument>`_, *choose_sticker* for `stickers <https://core.telegram.org/bots/api#sendsticker>`_, *find_location* for `location data <https://core.telegram.org/bots/api#sendlocation>`_, *record_video_note* or *upload_video_note* for `video notes <https://core.telegram.org/bots/api#sendvideonote>`_."""
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

@ -38,7 +38,7 @@ class SendDocument(TelegramMethod[Message]):
parse_mode: Optional[str] = UNSET parse_mode: Optional[str] = UNSET
"""Mode for parsing entities in the document caption. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details.""" """Mode for parsing entities in the document caption. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details."""
caption_entities: Optional[List[MessageEntity]] = None caption_entities: Optional[List[MessageEntity]] = None
"""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*"""
disable_content_type_detection: Optional[bool] = None disable_content_type_detection: Optional[bool] = None
"""Disables automatic server-side content type detection for files uploaded using multipart/form-data""" """Disables automatic server-side content type detection for files uploaded using multipart/form-data"""
disable_notification: Optional[bool] = None disable_notification: Optional[bool] = None

View file

@ -33,7 +33,7 @@ class SendMessage(TelegramMethod[Message]):
parse_mode: Optional[str] = UNSET parse_mode: Optional[str] = UNSET
"""Mode for parsing entities in the message text. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details.""" """Mode for parsing entities in the message text. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details."""
entities: Optional[List[MessageEntity]] = None entities: Optional[List[MessageEntity]] = None
"""List of special entities that appear in message text, which can be specified instead of *parse_mode*""" """A JSON-serialized list of special entities that appear in message text, which can be specified instead of *parse_mode*"""
disable_web_page_preview: Optional[bool] = None disable_web_page_preview: Optional[bool] = None
"""Disables link previews for links in this message""" """Disables link previews for links in this message"""
disable_notification: Optional[bool] = None disable_notification: Optional[bool] = None

View file

@ -36,7 +36,7 @@ class SendPhoto(TelegramMethod[Message]):
parse_mode: Optional[str] = UNSET parse_mode: Optional[str] = UNSET
"""Mode for parsing entities in the photo caption. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details.""" """Mode for parsing entities in the photo caption. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details."""
caption_entities: Optional[List[MessageEntity]] = None caption_entities: Optional[List[MessageEntity]] = None
"""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*"""
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."""
reply_to_message_id: Optional[int] = None reply_to_message_id: Optional[int] = None

View file

@ -34,11 +34,11 @@ class SendPoll(TelegramMethod[Message]):
options: List[str] options: List[str]
"""A JSON-serialized list of answer options, 2-10 strings 1-100 characters each""" """A JSON-serialized list of answer options, 2-10 strings 1-100 characters each"""
is_anonymous: Optional[bool] = None is_anonymous: Optional[bool] = None
"""True, if the poll needs to be anonymous, defaults to :code:`True`""" """:code:`True`, if the poll needs to be anonymous, defaults to :code:`True`"""
type: Optional[str] = None type: Optional[str] = None
"""Poll type, 'quiz' or 'regular', defaults to 'regular'""" """Poll type, 'quiz' or 'regular', defaults to 'regular'"""
allows_multiple_answers: Optional[bool] = None allows_multiple_answers: Optional[bool] = None
"""True, if the poll allows multiple answers, ignored for polls in quiz mode, defaults to :code:`False`""" """:code:`True`, if the poll allows multiple answers, ignored for polls in quiz mode, defaults to :code:`False`"""
correct_option_id: Optional[int] = None correct_option_id: Optional[int] = None
"""0-based identifier of the correct answer option, required for polls in quiz mode""" """0-based identifier of the correct answer option, required for polls in quiz mode"""
explanation: Optional[str] = None explanation: Optional[str] = None
@ -46,7 +46,7 @@ class SendPoll(TelegramMethod[Message]):
explanation_parse_mode: Optional[str] = UNSET explanation_parse_mode: Optional[str] = UNSET
"""Mode for parsing entities in the explanation. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details.""" """Mode for parsing entities in the explanation. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details."""
explanation_entities: Optional[List[MessageEntity]] = None explanation_entities: Optional[List[MessageEntity]] = None
"""List of special entities that appear in the poll explanation, which can be specified instead of *parse_mode*""" """A JSON-serialized list of special entities that appear in the poll explanation, which can be specified instead of *parse_mode*"""
open_period: Optional[int] = None open_period: Optional[int] = None
"""Amount of time in seconds the poll will be active after creation, 5-600. Can't be used together with *close_date*.""" """Amount of time in seconds the poll will be active after creation, 5-600. Can't be used together with *close_date*."""
close_date: Optional[Union[datetime.datetime, datetime.timedelta, int]] = None close_date: Optional[Union[datetime.datetime, datetime.timedelta, int]] = None

View file

@ -44,7 +44,7 @@ class SendVideo(TelegramMethod[Message]):
parse_mode: Optional[str] = UNSET parse_mode: Optional[str] = UNSET
"""Mode for parsing entities in the video caption. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details.""" """Mode for parsing entities in the video caption. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details."""
caption_entities: Optional[List[MessageEntity]] = None caption_entities: Optional[List[MessageEntity]] = None
"""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

View file

@ -36,7 +36,7 @@ class SendVoice(TelegramMethod[Message]):
parse_mode: Optional[str] = UNSET parse_mode: Optional[str] = UNSET
"""Mode for parsing entities in the voice message caption. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details.""" """Mode for parsing entities in the voice message caption. See `formatting options <https://core.telegram.org/bots/api#formatting-options>`_ for more details."""
caption_entities: Optional[List[MessageEntity]] = None caption_entities: Optional[List[MessageEntity]] = None
"""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*"""
duration: Optional[int] = None duration: Optional[int] = None
"""Duration of the voice message in seconds""" """Duration of the voice message in seconds"""
disable_notification: Optional[bool] = None disable_notification: Optional[bool] = None

View file

@ -10,7 +10,7 @@ if TYPE_CHECKING:
class SetChatDescription(TelegramMethod[bool]): class SetChatDescription(TelegramMethod[bool]):
""" """
Use this method to change the description of a group, a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns :code:`True` on success. Use this method to change the description of a group, a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns :code:`True` on success.
Source: https://core.telegram.org/bots/api#setchatdescription Source: https://core.telegram.org/bots/api#setchatdescription
""" """

View file

@ -11,7 +11,7 @@ if TYPE_CHECKING:
class SetChatPermissions(TelegramMethod[bool]): class SetChatPermissions(TelegramMethod[bool]):
""" """
Use this method to set default chat permissions for all members. The bot must be an administrator in the group or a supergroup for this to work and must have the *can_restrict_members* admin rights. Returns :code:`True` on success. Use this method to set default chat permissions for all members. The bot must be an administrator in the group or a supergroup for this to work and must have the *can_restrict_members* administrator rights. Returns :code:`True` on success.
Source: https://core.telegram.org/bots/api#setchatpermissions Source: https://core.telegram.org/bots/api#setchatpermissions
""" """
@ -21,7 +21,7 @@ class SetChatPermissions(TelegramMethod[bool]):
chat_id: Union[int, str] chat_id: Union[int, str]
"""Unique identifier for the target chat or username of the target supergroup (in the format :code:`@supergroupusername`)""" """Unique identifier for the target chat or username of the target supergroup (in the format :code:`@supergroupusername`)"""
permissions: ChatPermissions permissions: ChatPermissions
"""New default chat permissions""" """A JSON-serialized object for new default chat permissions"""
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

@ -11,7 +11,7 @@ if TYPE_CHECKING:
class SetChatPhoto(TelegramMethod[bool]): class SetChatPhoto(TelegramMethod[bool]):
""" """
Use this method to set a new profile photo for the chat. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns :code:`True` on success. Use this method to set a new profile photo for the chat. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns :code:`True` on success.
Source: https://core.telegram.org/bots/api#setchatphoto Source: https://core.telegram.org/bots/api#setchatphoto
""" """

View file

@ -10,7 +10,7 @@ if TYPE_CHECKING:
class SetChatStickerSet(TelegramMethod[bool]): class SetChatStickerSet(TelegramMethod[bool]):
""" """
Use this method to set a new group sticker set for a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Use the field *can_set_sticker_set* optionally returned in :class:`aiogram.methods.get_chat.GetChat` requests to check if the bot can use this method. Returns :code:`True` on success. Use this method to set a new group sticker set for a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Use the field *can_set_sticker_set* optionally returned in :class:`aiogram.methods.get_chat.GetChat` requests to check if the bot can use this method. Returns :code:`True` on success.
Source: https://core.telegram.org/bots/api#setchatstickerset Source: https://core.telegram.org/bots/api#setchatstickerset
""" """

View file

@ -10,7 +10,7 @@ if TYPE_CHECKING:
class SetChatTitle(TelegramMethod[bool]): class SetChatTitle(TelegramMethod[bool]):
""" """
Use this method to change the title of a chat. Titles can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns :code:`True` on success. Use this method to change the title of a chat. Titles can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns :code:`True` on success.
Source: https://core.telegram.org/bots/api#setchattitle Source: https://core.telegram.org/bots/api#setchattitle
""" """

View file

@ -11,7 +11,7 @@ if TYPE_CHECKING:
class SetGameScore(TelegramMethod[Union[Message, bool]]): class SetGameScore(TelegramMethod[Union[Message, bool]]):
""" """
Use this method to set the score of the specified user in a game. On success, if the message was sent by the bot, returns the edited :class:`aiogram.types.message.Message`, otherwise returns :code:`True`. Returns an error, if the new score is not greater than the user's current score in the chat and *force* is :code:`False`. Use this method to set the score of the specified user in a game message. On success, if the message is not an inline message, the :class:`aiogram.types.message.Message` is returned, otherwise :code:`True` is returned. Returns an error, if the new score is not greater than the user's current score in the chat and *force* is :code:`False`.
Source: https://core.telegram.org/bots/api#setgamescore Source: https://core.telegram.org/bots/api#setgamescore
""" """
@ -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 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 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

@ -11,7 +11,7 @@ if TYPE_CHECKING:
class StopMessageLiveLocation(TelegramMethod[Union[Message, bool]]): class StopMessageLiveLocation(TelegramMethod[Union[Message, bool]]):
""" """
Use this method to stop updating a live location message before *live_period* expires. On success, if the message was sent by the bot, the sent :class:`aiogram.types.message.Message` is returned, otherwise :code:`True` is returned. Use this method to stop updating a live location message before *live_period* expires. On success, if the message is not an inline message, the edited :class:`aiogram.types.message.Message` is returned, otherwise :code:`True` is returned.
Source: https://core.telegram.org/bots/api#stopmessagelivelocation Source: https://core.telegram.org/bots/api#stopmessagelivelocation
""" """

View file

@ -11,7 +11,7 @@ if TYPE_CHECKING:
class StopPoll(TelegramMethod[Poll]): class StopPoll(TelegramMethod[Poll]):
""" """
Use this method to stop a poll which was sent by the bot. On success, the stopped :class:`aiogram.types.poll.Poll` with the final results is returned. Use this method to stop a poll which was sent by the bot. On success, the stopped :class:`aiogram.types.poll.Poll` is returned.
Source: https://core.telegram.org/bots/api#stoppoll Source: https://core.telegram.org/bots/api#stoppoll
""" """

View file

@ -10,7 +10,7 @@ if TYPE_CHECKING:
class UnpinAllChatMessages(TelegramMethod[bool]): class UnpinAllChatMessages(TelegramMethod[bool]):
""" """
Use this method to clear the list of pinned messages in a chat. If the chat is not a private chat, the bot must be an administrator in the chat for this to work and must have the 'can_pin_messages' admin right in a supergroup or 'can_edit_messages' admin right in a channel. Returns :code:`True` on success. Use this method to clear the list of pinned messages in a chat. If the chat is not a private chat, the bot must be an administrator in the chat for this to work and must have the 'can_pin_messages' administrator right in a supergroup or 'can_edit_messages' administrator right in a channel. Returns :code:`True` on success.
Source: https://core.telegram.org/bots/api#unpinallchatmessages Source: https://core.telegram.org/bots/api#unpinallchatmessages
""" """

View file

@ -10,7 +10,7 @@ if TYPE_CHECKING:
class UnpinChatMessage(TelegramMethod[bool]): class UnpinChatMessage(TelegramMethod[bool]):
""" """
Use this method to remove a message from the list of pinned messages in a chat. If the chat is not a private chat, the bot must be an administrator in the chat for this to work and must have the 'can_pin_messages' admin right in a supergroup or 'can_edit_messages' admin right in a channel. Returns :code:`True` on success. Use this method to remove a message from the list of pinned messages in a chat. If the chat is not a private chat, the bot must be an administrator in the chat for this to work and must have the 'can_pin_messages' administrator right in a supergroup or 'can_edit_messages' administrator right in a channel. Returns :code:`True` on success.
Source: https://core.telegram.org/bots/api#unpinchatmessage Source: https://core.telegram.org/bots/api#unpinchatmessage
""" """

View file

@ -14,6 +14,7 @@ from .callback_game import CallbackGame
from .callback_query import CallbackQuery from .callback_query import CallbackQuery
from .chat import Chat from .chat import Chat
from .chat_invite_link import ChatInviteLink from .chat_invite_link import ChatInviteLink
from .chat_join_request import ChatJoinRequest
from .chat_location import ChatLocation from .chat_location import ChatLocation
from .chat_member import ChatMember from .chat_member import ChatMember
from .chat_member_administrator import ChatMemberAdministrator from .chat_member_administrator import ChatMemberAdministrator
@ -181,6 +182,7 @@ __all__ = (
"ChatMemberLeft", "ChatMemberLeft",
"ChatMemberBanned", "ChatMemberBanned",
"ChatMemberUpdated", "ChatMemberUpdated",
"ChatJoinRequest",
"ChatPermissions", "ChatPermissions",
"ChatLocation", "ChatLocation",
"BotCommand", "BotCommand",

View file

@ -32,4 +32,4 @@ class Animation(TelegramObject):
mime_type: Optional[str] = None mime_type: Optional[str] = None
"""*Optional*. MIME type of the file as defined by sender""" """*Optional*. MIME type of the file as defined by sender"""
file_size: Optional[int] = None file_size: Optional[int] = None
"""*Optional*. File size""" """*Optional*. File size in bytes"""

View file

@ -8,6 +8,7 @@ if TYPE_CHECKING:
from .photo_size import PhotoSize from .photo_size import PhotoSize
# === Generated region: Audio ===
class Audio(TelegramObject): class Audio(TelegramObject):
""" """
This object represents an audio file to be treated as music by the Telegram clients. This object represents an audio file to be treated as music by the Telegram clients.
@ -30,6 +31,9 @@ class Audio(TelegramObject):
mime_type: Optional[str] = None mime_type: Optional[str] = None
"""*Optional*. MIME type of the file as defined by sender""" """*Optional*. MIME type of the file as defined by sender"""
file_size: Optional[int] = None file_size: Optional[int] = None
"""*Optional*. File size""" """*Optional*. File size in bytes"""
thumb: Optional[PhotoSize] = None thumb: Optional[PhotoSize] = None
"""*Optional*. Thumbnail of the album cover to which the music file belongs""" """*Optional*. Thumbnail of the album cover to which the music file belongs"""
# === End of generated region: Audio ===

View file

@ -43,13 +43,13 @@ class Chat(TelegramObject):
permissions: Optional[ChatPermissions] = None permissions: Optional[ChatPermissions] = None
"""*Optional*. Default chat member permissions, for groups and supergroups. Returned only in :class:`aiogram.methods.get_chat.GetChat`.""" """*Optional*. Default chat member permissions, for groups and supergroups. Returned only in :class:`aiogram.methods.get_chat.GetChat`."""
slow_mode_delay: Optional[int] = None slow_mode_delay: Optional[int] = None
"""*Optional*. For supergroups, the minimum allowed delay between consecutive messages sent by each unpriviledged user. Returned only in :class:`aiogram.methods.get_chat.GetChat`.""" """*Optional*. For supergroups, the minimum allowed delay between consecutive messages sent by each unpriviledged user; in seconds. Returned only in :class:`aiogram.methods.get_chat.GetChat`."""
message_auto_delete_time: Optional[int] = None message_auto_delete_time: Optional[int] = None
"""*Optional*. The time after which all messages sent to the chat will be automatically deleted; in seconds. Returned only in :class:`aiogram.methods.get_chat.GetChat`.""" """*Optional*. The time after which all messages sent to the chat will be automatically deleted; in seconds. Returned only in :class:`aiogram.methods.get_chat.GetChat`."""
sticker_set_name: Optional[str] = None sticker_set_name: Optional[str] = None
"""*Optional*. For supergroups, name of group sticker set. Returned only in :class:`aiogram.methods.get_chat.GetChat`.""" """*Optional*. For supergroups, name of group sticker set. Returned only in :class:`aiogram.methods.get_chat.GetChat`."""
can_set_sticker_set: Optional[bool] = None can_set_sticker_set: Optional[bool] = None
"""*Optional*. True, if the bot can change the group sticker set. Returned only in :class:`aiogram.methods.get_chat.GetChat`.""" """*Optional*. :code:`True`, if the bot can change the group sticker set. Returned only in :class:`aiogram.methods.get_chat.GetChat`."""
linked_chat_id: Optional[int] = None linked_chat_id: Optional[int] = None
"""*Optional*. Unique identifier for the linked chat, i.e. the discussion group identifier for a channel and vice versa; for supergroups and channel chats. This identifier may be greater than 32 bits and some programming languages may have difficulty/silent defects in interpreting it. But it is smaller than 52 bits, so a signed 64 bit integer or double-precision float type are safe for storing this identifier. Returned only in :class:`aiogram.methods.get_chat.GetChat`.""" """*Optional*. Unique identifier for the linked chat, i.e. the discussion group identifier for a channel and vice versa; for supergroups and channel chats. This identifier may be greater than 32 bits and some programming languages may have difficulty/silent defects in interpreting it. But it is smaller than 52 bits, so a signed 64 bit integer or double-precision float type are safe for storing this identifier. Returned only in :class:`aiogram.methods.get_chat.GetChat`."""
location: Optional[ChatLocation] = None location: Optional[ChatLocation] = None

View file

@ -19,11 +19,17 @@ class ChatInviteLink(TelegramObject):
"""The invite link. If the link was created by another chat administrator, then the second part of the link will be replaced with ''.""" """The invite link. If the link was created by another chat administrator, then the second part of the link will be replaced with ''."""
creator: User creator: User
"""Creator of the link""" """Creator of the link"""
creates_join_request: bool
""":code:`True`, if users joining the chat via the link need to be approved by chat administrators"""
is_primary: bool is_primary: bool
"""True, if the link is primary""" """:code:`True`, if the link is primary"""
is_revoked: bool is_revoked: bool
"""True, if the link is revoked""" """:code:`True`, if the link is revoked"""
name: Optional[str] = None
"""*Optional*. Invite link name"""
expire_date: Optional[int] = None expire_date: Optional[int] = None
"""*Optional*. Point in time (Unix timestamp) when the link will expire or has been expired""" """*Optional*. Point in time (Unix timestamp) when the link will expire or has been expired"""
member_limit: Optional[int] = None member_limit: Optional[int] = None
"""*Optional*. Maximum number of users that can be members of the chat simultaneously after joining the chat via this invite link; 1-99999""" """*Optional*. Maximum number of users that can be members of the chat simultaneously after joining the chat via this invite link; 1-99999"""
pending_join_request_count: Optional[int] = None
"""*Optional*. Number of pending join requests created using this link"""

View file

@ -0,0 +1,57 @@
from __future__ import annotations
import datetime
from typing import TYPE_CHECKING, Optional
from pydantic import Field
from .base import TelegramObject
if TYPE_CHECKING:
from ..methods import ApproveChatJoinRequest, DeclineChatJoinRequest
if TYPE_CHECKING:
from .chat import Chat
from .chat_invite_link import ChatInviteLink
from .user import User
class ChatJoinRequest(TelegramObject):
"""
Represents a join request sent to a chat.
Source: https://core.telegram.org/bots/api#chatjoinrequest
"""
chat: Chat
"""Chat to which the request was sent"""
from_user: User = Field(..., alias="from")
"""User that sent the join request"""
date: datetime.datetime
"""Date the request was sent in Unix time"""
bio: Optional[str] = None
"""*Optional*. Bio of the user."""
invite_link: Optional[ChatInviteLink] = None
"""*Optional*. Chat invite link that was used by the user to send the join request"""
def approve(self) -> ApproveChatJoinRequest:
"""
Use this method to approve a chat join request.
"""
from ..methods import ApproveChatJoinRequest
return ApproveChatJoinRequest(
chat_id=self.chat.id,
user_id=self.from_user.id,
)
def decline(self) -> DeclineChatJoinRequest:
"""
Use this method to decline a chat join request.
"""
from ..methods import DeclineChatJoinRequest
return DeclineChatJoinRequest(
chat_id=self.chat.id,
user_id=self.from_user.id,
)

View file

@ -22,28 +22,28 @@ class ChatMemberAdministrator(ChatMember):
user: User user: User
"""Information about the user""" """Information about the user"""
can_be_edited: bool can_be_edited: bool
"""True, if the bot is allowed to edit administrator privileges of that user""" """:code:`True`, if the bot is allowed to edit administrator privileges of that user"""
is_anonymous: bool is_anonymous: bool
"""True, if the user's presence in the chat is hidden""" """:code:`True`, if the user's presence in the chat is hidden"""
can_manage_chat: bool can_manage_chat: bool
"""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""" """: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_delete_messages: bool can_delete_messages: bool
"""True, if the administrator can delete messages of other users""" """:code:`True`, if the administrator can delete messages of other users"""
can_manage_voice_chats: bool can_manage_voice_chats: bool
"""True, if the administrator can manage voice chats""" """:code:`True`, if the administrator can manage voice chats"""
can_restrict_members: bool can_restrict_members: bool
"""True, if the administrator can restrict, ban or unban chat members""" """:code:`True`, if the administrator can restrict, ban or unban chat members"""
can_promote_members: bool can_promote_members: bool
"""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 the user)""" """: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 the user)"""
can_change_info: bool can_change_info: bool
"""True, if the user is allowed to change the chat title, photo and other settings""" """:code:`True`, if the user is allowed to change the chat title, photo and other settings"""
can_invite_users: bool can_invite_users: bool
"""True, if the user is allowed to invite new users to the chat""" """:code:`True`, if the user is allowed to invite new users to the chat"""
can_post_messages: Optional[bool] = None can_post_messages: Optional[bool] = None
"""*Optional*. True, if the administrator can post in the channel; channels only""" """*Optional*. :code:`True`, if the administrator can post in the channel; channels only"""
can_edit_messages: Optional[bool] = None can_edit_messages: Optional[bool] = None
"""*Optional*. True, if the administrator can edit messages of other users and can pin messages; channels only""" """*Optional*. :code:`True`, if the administrator can edit messages of other users and can pin messages; channels only"""
can_pin_messages: Optional[bool] = None can_pin_messages: Optional[bool] = None
"""*Optional*. True, if the user is allowed to pin messages; groups and supergroups only""" """*Optional*. :code:`True`, if the user is allowed to pin messages; groups and supergroups only"""
custom_title: Optional[str] = None custom_title: Optional[str] = None
"""*Optional*. Custom title for this user""" """*Optional*. Custom title for this user"""

View file

@ -23,4 +23,4 @@ class ChatMemberBanned(ChatMember):
user: User user: User
"""Information about the user""" """Information about the user"""
until_date: Union[datetime.datetime, datetime.timedelta, int] until_date: Union[datetime.datetime, datetime.timedelta, int]
"""Date when restrictions will be lifted for this user; unix time""" """Date when restrictions will be lifted for this user; unix time. If 0, then the user is banned forever"""

View file

@ -22,6 +22,6 @@ class ChatMemberOwner(ChatMember):
user: User user: User
"""Information about the user""" """Information about the user"""
is_anonymous: bool is_anonymous: bool
"""True, if the user's presence in the chat is hidden""" """:code:`True`, if the user's presence in the chat is hidden"""
custom_title: Optional[str] = None custom_title: Optional[str] = None
"""*Optional*. Custom title for this user""" """*Optional*. Custom title for this user"""

View file

@ -23,22 +23,22 @@ class ChatMemberRestricted(ChatMember):
user: User user: User
"""Information about the user""" """Information about the user"""
is_member: bool is_member: bool
"""True, if the user is a member of the chat at the moment of the request""" """:code:`True`, if the user is a member of the chat at the moment of the request"""
can_change_info: bool can_change_info: bool
"""True, if the user is allowed to change the chat title, photo and other settings""" """:code:`True`, if the user is allowed to change the chat title, photo and other settings"""
can_invite_users: bool can_invite_users: bool
"""True, if the user is allowed to invite new users to the chat""" """:code:`True`, if the user is allowed to invite new users to the chat"""
can_pin_messages: bool can_pin_messages: bool
"""True, if the user is allowed to pin messages; groups and supergroups only""" """:code:`True`, if the user is allowed to pin messages"""
can_send_messages: bool can_send_messages: bool
"""True, if the user is allowed to send text messages, contacts, locations and venues""" """:code:`True`, if the user is allowed to send text messages, contacts, locations and venues"""
can_send_media_messages: bool can_send_media_messages: bool
"""True, if the user is allowed to send audios, documents, photos, videos, video notes and voice notes""" """:code:`True`, if the user is allowed to send audios, documents, photos, videos, video notes and voice notes"""
can_send_polls: bool can_send_polls: bool
"""True, if the user is allowed to send polls""" """:code:`True`, if the user is allowed to send polls"""
can_send_other_messages: bool can_send_other_messages: bool
"""True, if the user is allowed to send animations, games, stickers and use inline bots""" """:code:`True`, if the user is allowed to send animations, games, stickers and use inline bots"""
can_add_web_page_previews: bool can_add_web_page_previews: bool
"""True, if the user is allowed to add web page previews to their messages""" """:code:`True`, if the user is allowed to add web page previews to their messages"""
until_date: Union[datetime.datetime, datetime.timedelta, int] until_date: Union[datetime.datetime, datetime.timedelta, int]
"""Date when restrictions will be lifted for this user; unix time""" """Date when restrictions will be lifted for this user; unix time. If 0, then the user is restricted forever"""

View file

@ -13,18 +13,18 @@ class ChatPermissions(MutableTelegramObject):
""" """
can_send_messages: Optional[bool] = None can_send_messages: Optional[bool] = None
"""*Optional*. True, if the user is allowed to send text messages, contacts, locations and venues""" """*Optional*. :code:`True`, if the user is allowed to send text messages, contacts, locations and venues"""
can_send_media_messages: Optional[bool] = None can_send_media_messages: Optional[bool] = None
"""*Optional*. True, if the user is allowed to send audios, documents, photos, videos, video notes and voice notes, implies can_send_messages""" """*Optional*. :code:`True`, if the user is allowed to send audios, documents, photos, videos, video notes and voice notes, implies can_send_messages"""
can_send_polls: Optional[bool] = None can_send_polls: Optional[bool] = None
"""*Optional*. True, if the user is allowed to send polls, implies can_send_messages""" """*Optional*. :code:`True`, if the user is allowed to send polls, implies can_send_messages"""
can_send_other_messages: Optional[bool] = None can_send_other_messages: Optional[bool] = None
"""*Optional*. True, if the user is allowed to send animations, games, stickers and use inline bots, implies can_send_media_messages""" """*Optional*. :code:`True`, if the user is allowed to send animations, games, stickers and use inline bots, implies can_send_media_messages"""
can_add_web_page_previews: Optional[bool] = None can_add_web_page_previews: Optional[bool] = None
"""*Optional*. True, if the user is allowed to add web page previews to their messages, implies can_send_media_messages""" """*Optional*. :code:`True`, if the user is allowed to add web page previews to their messages, implies can_send_media_messages"""
can_change_info: Optional[bool] = None can_change_info: Optional[bool] = None
"""*Optional*. True, if the user is allowed to change the chat title, photo and other settings. Ignored in public supergroups""" """*Optional*. :code:`True`, if the user is allowed to change the chat title, photo and other settings. Ignored in public supergroups"""
can_invite_users: Optional[bool] = None can_invite_users: Optional[bool] = None
"""*Optional*. True, if the user is allowed to invite new users to the chat""" """*Optional*. :code:`True`, if the user is allowed to invite new users to the chat"""
can_pin_messages: Optional[bool] = None can_pin_messages: Optional[bool] = None
"""*Optional*. True, if the user is allowed to pin messages. Ignored in public supergroups""" """*Optional*. :code:`True`, if the user is allowed to pin messages. Ignored in public supergroups"""

View file

@ -26,4 +26,4 @@ class Document(TelegramObject):
mime_type: Optional[str] = None mime_type: Optional[str] = None
"""*Optional*. MIME type of the file as defined by sender""" """*Optional*. MIME type of the file as defined by sender"""
file_size: Optional[int] = None file_size: Optional[int] = None
"""*Optional*. File size""" """*Optional*. File size in bytes"""

View file

@ -19,6 +19,6 @@ class File(TelegramObject):
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."""
file_size: Optional[int] = None file_size: Optional[int] = None
"""*Optional*. File size, if known""" """*Optional*. File size in bytes, if known"""
file_path: Optional[str] = None file_path: Optional[str] = None
"""*Optional*. File path. Use :code:`https://api.telegram.org/file/bot<token>/<file_path>` to get the file.""" """*Optional*. File path. Use :code:`https://api.telegram.org/file/bot<token>/<file_path>` to get the file."""

View file

@ -31,4 +31,4 @@ class InlineKeyboardButton(MutableTelegramObject):
callback_game: Optional[CallbackGame] = None callback_game: Optional[CallbackGame] = None
"""*Optional*. Description of the game that will be launched when the user presses the button.""" """*Optional*. Description of the game that will be launched when the user presses the button."""
pay: Optional[bool] = None pay: Optional[bool] = None
"""*Optional*. Specify True, to send a `Pay button <https://core.telegram.org/bots/api#payments>`_.""" """*Optional*. Specify :code:`True`, to send a `Pay button <https://core.telegram.org/bots/api#payments>`_."""

View file

@ -44,7 +44,7 @@ class InlineQueryResultDocument(InlineQueryResult):
input_message_content: Optional[InputMessageContent] = None input_message_content: Optional[InputMessageContent] = None
"""*Optional*. Content of the message to be sent instead of the file""" """*Optional*. Content of the message to be sent instead of the file"""
thumb_url: Optional[str] = None thumb_url: Optional[str] = None
"""*Optional*. URL of the thumbnail (jpeg only) for the file""" """*Optional*. URL of the thumbnail (JPEG only) for the file"""
thumb_width: Optional[int] = None thumb_width: Optional[int] = None
"""*Optional*. Thumbnail width""" """*Optional*. Thumbnail width"""
thumb_height: Optional[int] = None thumb_height: Optional[int] = None

View file

@ -33,7 +33,7 @@ class InlineQueryResultGif(InlineQueryResult):
gif_height: Optional[int] = None gif_height: Optional[int] = None
"""*Optional*. Height of the GIF""" """*Optional*. Height of the GIF"""
gif_duration: Optional[int] = None gif_duration: Optional[int] = None
"""*Optional*. Duration of the GIF""" """*Optional*. Duration of the GIF in seconds"""
thumb_mime_type: Optional[str] = None thumb_mime_type: Optional[str] = None
"""*Optional*. MIME type of the thumbnail, must be one of 'image/jpeg', 'image/gif', or 'video/mp4'. Defaults to 'image/jpeg'""" """*Optional*. MIME type of the thumbnail, must be one of 'image/jpeg', 'image/gif', or 'video/mp4'. Defaults to 'image/jpeg'"""
title: Optional[str] = None title: Optional[str] = None

View file

@ -33,7 +33,7 @@ class InlineQueryResultMpeg4Gif(InlineQueryResult):
mpeg4_height: Optional[int] = None mpeg4_height: Optional[int] = None
"""*Optional*. Video height""" """*Optional*. Video height"""
mpeg4_duration: Optional[int] = None mpeg4_duration: Optional[int] = None
"""*Optional*. Video duration""" """*Optional*. Video duration in seconds"""
thumb_mime_type: Optional[str] = None thumb_mime_type: Optional[str] = None
"""*Optional*. MIME type of the thumbnail, must be one of 'image/jpeg', 'image/gif', or 'video/mp4'. Defaults to 'image/jpeg'""" """*Optional*. MIME type of the thumbnail, must be one of 'image/jpeg', 'image/gif', or 'video/mp4'. Defaults to 'image/jpeg'"""
title: Optional[str] = None title: Optional[str] = None

View file

@ -25,7 +25,7 @@ class InlineQueryResultPhoto(InlineQueryResult):
id: str id: str
"""Unique identifier for this result, 1-64 bytes""" """Unique identifier for this result, 1-64 bytes"""
photo_url: str photo_url: str
"""A valid URL of the photo. Photo must be in **jpeg** format. Photo size must not exceed 5MB""" """A valid URL of the photo. Photo must be in **JPEG** format. Photo size must not exceed 5MB"""
thumb_url: str thumb_url: str
"""URL of the thumbnail for the photo""" """URL of the thumbnail for the photo"""
photo_width: Optional[int] = None photo_width: Optional[int] = None

View file

@ -31,7 +31,7 @@ class InlineQueryResultVideo(InlineQueryResult):
mime_type: str mime_type: str
"""Mime type of the content of video url, 'text/html' or 'video/mp4'""" """Mime type of the content of video url, 'text/html' or 'video/mp4'"""
thumb_url: str thumb_url: str
"""URL of the thumbnail (jpeg only) for the video""" """URL of the thumbnail (JPEG only) for the video"""
title: str title: str
"""Title for the result""" """Title for the result"""
caption: Optional[str] = None caption: Optional[str] = None

View file

@ -36,4 +36,4 @@ class InputMediaAnimation(InputMedia):
height: Optional[int] = None height: Optional[int] = None
"""*Optional*. Animation height""" """*Optional*. Animation height"""
duration: Optional[int] = None duration: Optional[int] = None
"""*Optional*. Animation duration""" """*Optional*. Animation duration in seconds"""

View file

@ -32,4 +32,4 @@ class InputMediaDocument(InputMedia):
caption_entities: Optional[List[MessageEntity]] = None caption_entities: Optional[List[MessageEntity]] = None
"""*Optional*. List of special entities that appear in the caption, which can be specified instead of *parse_mode*""" """*Optional*. List of special entities that appear in the caption, which can be specified instead of *parse_mode*"""
disable_content_type_detection: Optional[bool] = None disable_content_type_detection: Optional[bool] = None
"""*Optional*. Disables automatic server-side content type detection for files uploaded using multipart/form-data. Always true, if the document is sent as part of an album.""" """*Optional*. Disables automatic server-side content type detection for files uploaded using multipart/form-data. Always :code:`True`, if the document is sent as part of an album."""

View file

@ -36,6 +36,6 @@ class InputMediaVideo(InputMedia):
height: Optional[int] = None height: Optional[int] = None
"""*Optional*. Video height""" """*Optional*. Video height"""
duration: Optional[int] = None duration: Optional[int] = None
"""*Optional*. Video duration""" """*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

@ -19,7 +19,7 @@ class Location(TelegramObject):
horizontal_accuracy: Optional[float] = None horizontal_accuracy: Optional[float] = None
"""*Optional*. The radius of uncertainty for the location, measured in meters; 0-1500""" """*Optional*. The radius of uncertainty for the location, measured in meters; 0-1500"""
live_period: Optional[int] = None live_period: Optional[int] = None
"""*Optional*. Time relative to the message sending date, during which the location can be updated, in seconds. For active live locations only.""" """*Optional*. Time relative to the message sending date, during which the location can be updated; in seconds. For active live locations only."""
heading: Optional[int] = None heading: Optional[int] = None
"""*Optional*. The direction in which user is moving, in degrees; 1-360. For active live locations only.""" """*Optional*. The direction in which user is moving, in degrees; 1-360. For active live locations only."""
proximity_alert_radius: Optional[int] = None proximity_alert_radius: Optional[int] = None

View file

@ -22,4 +22,4 @@ class LoginUrl(TelegramObject):
bot_username: Optional[str] = None bot_username: Optional[str] = None
"""*Optional*. Username of a bot, which will be used for user authorization. See `Setting up a bot <https://core.telegram.org/widgets/login#setting-up-a-bot>`_ for more details. If not specified, the current bot's username will be assumed. The *url*'s domain must be the same as the domain linked with the bot. See `Linking your domain to the bot <https://core.telegram.org/widgets/login#linking-your-domain-to-the-bot>`_ for more details.""" """*Optional*. Username of a bot, which will be used for user authorization. See `Setting up a bot <https://core.telegram.org/widgets/login#setting-up-a-bot>`_ for more details. If not specified, the current bot's username will be assumed. The *url*'s domain must be the same as the domain linked with the bot. See `Linking your domain to the bot <https://core.telegram.org/widgets/login#linking-your-domain-to-the-bot>`_ for more details."""
request_write_access: Optional[bool] = None request_write_access: Optional[bool] = None
"""*Optional*. Pass True to request the permission for your bot to send messages to the user.""" """*Optional*. Pass :code:`True` to request the permission for your bot to send messages to the user."""

View file

@ -11,4 +11,4 @@ class MessageAutoDeleteTimerChanged(TelegramObject):
""" """
message_auto_delete_time: int message_auto_delete_time: int
"""New auto-delete time for messages in the chat""" """New auto-delete time for messages in the chat; in seconds"""

View file

@ -15,6 +15,6 @@ class PassportFile(TelegramObject):
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."""
file_size: int file_size: int
"""File size""" """File size in bytes"""
file_date: int file_date: int
"""Unix time when the file was uploaded""" """Unix time when the file was uploaded"""

View file

@ -21,4 +21,4 @@ class PhotoSize(TelegramObject):
height: int height: int
"""Photo height""" """Photo height"""
file_size: Optional[int] = None file_size: Optional[int] = None
"""*Optional*. File size""" """*Optional*. File size in bytes"""

View file

@ -26,13 +26,13 @@ class Poll(TelegramObject):
total_voter_count: int total_voter_count: int
"""Total number of users that voted in the poll""" """Total number of users that voted in the poll"""
is_closed: bool is_closed: bool
"""True, if the poll is closed""" """:code:`True`, if the poll is closed"""
is_anonymous: bool is_anonymous: bool
"""True, if the poll is anonymous""" """:code:`True`, if the poll is anonymous"""
type: str type: str
"""Poll type, currently can be 'regular' or 'quiz'""" """Poll type, currently can be 'regular' or 'quiz'"""
allows_multiple_answers: bool allows_multiple_answers: bool
"""True, if the poll allows multiple answers""" """:code:`True`, if the poll allows multiple answers"""
correct_option_id: Optional[int] = None correct_option_id: Optional[int] = None
"""*Optional*. 0-based identifier of the correct answer option. Available only for polls in the quiz mode, which are closed, or was sent (not forwarded) by the bot or to the private chat with the bot.""" """*Optional*. 0-based identifier of the correct answer option. Available only for polls in the quiz mode, which are closed, or was sent (not forwarded) by the bot or to the private chat with the bot."""
explanation: Optional[str] = None explanation: Optional[str] = None

View file

@ -35,4 +35,4 @@ class Sticker(TelegramObject):
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"""
file_size: Optional[int] = None file_size: Optional[int] = None
"""*Optional*. File size""" """*Optional*. File size in bytes"""

View file

@ -7,6 +7,7 @@ from .base import TelegramObject
if TYPE_CHECKING: if TYPE_CHECKING:
from .callback_query import CallbackQuery from .callback_query import CallbackQuery
from .chat_join_request import ChatJoinRequest
from .chat_member_updated import ChatMemberUpdated from .chat_member_updated import ChatMemberUpdated
from .chosen_inline_result import ChosenInlineResult from .chosen_inline_result import ChosenInlineResult
from .inline_query import InlineQuery from .inline_query import InlineQuery
@ -54,6 +55,8 @@ class Update(TelegramObject):
"""*Optional*. The bot's chat member status was updated in a chat. For private chats, this update is received only when the bot is blocked or unblocked by the user.""" """*Optional*. The bot's chat member status was updated in a chat. For private chats, this update is received only when the bot is blocked or unblocked by the user."""
chat_member: Optional[ChatMemberUpdated] = None chat_member: Optional[ChatMemberUpdated] = None
"""*Optional*. A chat member's status was updated in a chat. The bot must be an administrator in the chat and must explicitly specify 'chat_member' in the list of *allowed_updates* to receive these updates.""" """*Optional*. A chat member's status was updated in a chat. The bot must be an administrator in the chat and must explicitly specify 'chat_member' in the list of *allowed_updates* to receive these updates."""
chat_join_request: Optional[ChatJoinRequest] = None
"""*Optional*. A request to join the chat has been sent. The bot must have the *can_invite_users* administrator right in the chat to receive these updates."""
def __hash__(self) -> int: def __hash__(self) -> int:
return hash((type(self), self.update_id)) return hash((type(self), self.update_id))
@ -93,6 +96,8 @@ class Update(TelegramObject):
return "my_chat_member" return "my_chat_member"
if self.chat_member: if self.chat_member:
return "chat_member" return "chat_member"
if self.chat_join_request:
return "chat_join_request"
raise UpdateTypeLookupError("Update does not contain any known event type.") raise UpdateTypeLookupError("Update does not contain any known event type.")

View file

@ -15,7 +15,7 @@ class User(TelegramObject):
id: int id: int
"""Unique identifier for this user or bot. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a 64-bit integer or double-precision float type are safe for storing this identifier.""" """Unique identifier for this user or bot. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a 64-bit integer or double-precision float type are safe for storing this identifier."""
is_bot: bool is_bot: bool
"""True, if this user is a bot""" """:code:`True`, if this user is a bot"""
first_name: str first_name: str
"""User's or bot's first name""" """User's or bot's first name"""
last_name: Optional[str] = None last_name: Optional[str] = None
@ -25,11 +25,11 @@ class User(TelegramObject):
language_code: Optional[str] = None language_code: Optional[str] = None
"""*Optional*. `IETF language tag <https://en.wikipedia.org/wiki/IETF_language_tag>`_ of the user's language""" """*Optional*. `IETF language tag <https://en.wikipedia.org/wiki/IETF_language_tag>`_ of the user's language"""
can_join_groups: Optional[bool] = None can_join_groups: Optional[bool] = None
"""*Optional*. True, if the bot can be invited to groups. Returned only in :class:`aiogram.methods.get_me.GetMe`.""" """*Optional*. :code:`True`, if the bot can be invited to groups. Returned only in :class:`aiogram.methods.get_me.GetMe`."""
can_read_all_group_messages: Optional[bool] = None can_read_all_group_messages: Optional[bool] = None
"""*Optional*. True, if `privacy mode <https://core.telegram.org/bots#privacy-mode>`_ is disabled for the bot. Returned only in :class:`aiogram.methods.get_me.GetMe`.""" """*Optional*. :code:`True`, if `privacy mode <https://core.telegram.org/bots#privacy-mode>`_ is disabled for the bot. Returned only in :class:`aiogram.methods.get_me.GetMe`."""
supports_inline_queries: Optional[bool] = None supports_inline_queries: Optional[bool] = None
"""*Optional*. True, if the bot supports inline queries. Returned only in :class:`aiogram.methods.get_me.GetMe`.""" """*Optional*. :code:`True`, if the bot supports inline queries. Returned only in :class:`aiogram.methods.get_me.GetMe`."""
@property @property
def full_name(self) -> str: def full_name(self) -> str:

View file

@ -32,4 +32,4 @@ class Video(TelegramObject):
mime_type: Optional[str] = None mime_type: Optional[str] = None
"""*Optional*. Mime type of a file as defined by sender""" """*Optional*. Mime type of a file as defined by sender"""
file_size: Optional[int] = None file_size: Optional[int] = None
"""*Optional*. File size""" """*Optional*. File size in bytes"""

View file

@ -26,4 +26,4 @@ class VideoNote(TelegramObject):
thumb: Optional[PhotoSize] = None thumb: Optional[PhotoSize] = None
"""*Optional*. Video thumbnail""" """*Optional*. Video thumbnail"""
file_size: Optional[int] = None file_size: Optional[int] = None
"""*Optional*. File size""" """*Optional*. File size in bytes"""

View file

@ -21,4 +21,4 @@ class Voice(TelegramObject):
mime_type: Optional[str] = None mime_type: Optional[str] = None
"""*Optional*. MIME type of the file as defined by sender""" """*Optional*. MIME type of the file as defined by sender"""
file_size: Optional[int] = None file_size: Optional[int] = None
"""*Optional*. File size""" """*Optional*. File size in bytes"""

View file

@ -11,4 +11,4 @@ class VoiceChatEnded(TelegramObject):
""" """
duration: int duration: int
"""Voice chat duration; in seconds""" """Voice chat duration in seconds"""

View file

@ -15,7 +15,7 @@ class WebhookInfo(TelegramObject):
url: str url: str
"""Webhook URL, may be empty if webhook is not set up""" """Webhook URL, may be empty if webhook is not set up"""
has_custom_certificate: bool has_custom_certificate: bool
"""True, if a custom certificate was provided for webhook certificate checks""" """:code:`True`, if a custom certificate was provided for webhook certificate checks"""
pending_update_count: int pending_update_count: int
"""Number of updates awaiting delivery""" """Number of updates awaiting delivery"""
ip_address: Optional[str] = None ip_address: Optional[str] = None

View file

@ -0,0 +1,51 @@
######################
approveChatJoinRequest
######################
Returns: :obj:`bool`
.. automodule:: aiogram.methods.approve_chat_join_request
:members:
:member-order: bysource
:undoc-members: True
Usage
=====
As bot method
-------------
.. code-block::
result: bool = await bot.approve_chat_join_request(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods.approve_chat_join_request import ApproveChatJoinRequest`
- alias: :code:`from aiogram.methods import ApproveChatJoinRequest`
In handlers with current bot
----------------------------
.. code-block:: python
result: bool = await ApproveChatJoinRequest(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block:: python
result: bool = await bot(ApproveChatJoinRequest(...))
As reply into Webhook in handler
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block:: python
return ApproveChatJoinRequest(...)

View file

@ -0,0 +1,51 @@
######################
declineChatJoinRequest
######################
Returns: :obj:`bool`
.. automodule:: aiogram.methods.decline_chat_join_request
:members:
:member-order: bysource
:undoc-members: True
Usage
=====
As bot method
-------------
.. code-block::
result: bool = await bot.decline_chat_join_request(...)
Method as object
----------------
Imports:
- :code:`from aiogram.methods.decline_chat_join_request import DeclineChatJoinRequest`
- alias: :code:`from aiogram.methods import DeclineChatJoinRequest`
In handlers with current bot
----------------------------
.. code-block:: python
result: bool = await DeclineChatJoinRequest(...)
With specific bot
~~~~~~~~~~~~~~~~~
.. code-block:: python
result: bool = await bot(DeclineChatJoinRequest(...))
As reply into Webhook in handler
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block:: python
return DeclineChatJoinRequest(...)

View file

@ -2,7 +2,7 @@
getChatAdministrators getChatAdministrators
##################### #####################
Returns: :obj:`List[ChatMember]` Returns: :obj:`List[Union[ChatMemberOwner, ChatMemberAdministrator, ChatMemberMember, ChatMemberRestricted, ChatMemberLeft, ChatMemberBanned]]`
.. automodule:: aiogram.methods.get_chat_administrators .. automodule:: aiogram.methods.get_chat_administrators
:members: :members:
@ -18,7 +18,7 @@ As bot method
.. code-block:: .. code-block::
result: List[ChatMember] = await bot.get_chat_administrators(...) result: List[Union[ChatMemberOwner, ChatMemberAdministrator, ChatMemberMember, ChatMemberRestricted, ChatMemberLeft, ChatMemberBanned]] = await bot.get_chat_administrators(...)
Method as object Method as object
@ -34,11 +34,11 @@ In handlers with current bot
.. code-block:: python .. code-block:: python
result: List[ChatMember] = await GetChatAdministrators(...) result: List[Union[ChatMemberOwner, ChatMemberAdministrator, ChatMemberMember, ChatMemberRestricted, ChatMemberLeft, ChatMemberBanned]] = await GetChatAdministrators(...)
With specific bot With specific bot
~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~
.. code-block:: python .. code-block:: python
result: List[ChatMember] = await bot(GetChatAdministrators(...)) result: List[Union[ChatMemberOwner, ChatMemberAdministrator, ChatMemberMember, ChatMemberRestricted, ChatMemberLeft, ChatMemberBanned]] = await bot(GetChatAdministrators(...))

View file

@ -2,7 +2,7 @@
getChatMember getChatMember
############# #############
Returns: :obj:`ChatMember` Returns: :obj:`Union[ChatMemberOwner, ChatMemberAdministrator, ChatMemberMember, ChatMemberRestricted, ChatMemberLeft, ChatMemberBanned]`
.. automodule:: aiogram.methods.get_chat_member .. automodule:: aiogram.methods.get_chat_member
:members: :members:
@ -18,7 +18,7 @@ As bot method
.. code-block:: .. code-block::
result: ChatMember = await bot.get_chat_member(...) result: Union[ChatMemberOwner, ChatMemberAdministrator, ChatMemberMember, ChatMemberRestricted, ChatMemberLeft, ChatMemberBanned] = await bot.get_chat_member(...)
Method as object Method as object
@ -34,11 +34,11 @@ In handlers with current bot
.. code-block:: python .. code-block:: python
result: ChatMember = await GetChatMember(...) result: Union[ChatMemberOwner, ChatMemberAdministrator, ChatMemberMember, ChatMemberRestricted, ChatMemberLeft, ChatMemberBanned] = await GetChatMember(...)
With specific bot With specific bot
~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~
.. code-block:: python .. code-block:: python
result: ChatMember = await bot(GetChatMember(...)) result: Union[ChatMemberOwner, ChatMemberAdministrator, ChatMemberMember, ChatMemberRestricted, ChatMemberLeft, ChatMemberBanned] = await bot(GetChatMember(...))

View file

@ -59,6 +59,8 @@ Available methods
create_chat_invite_link create_chat_invite_link
edit_chat_invite_link edit_chat_invite_link
revoke_chat_invite_link revoke_chat_invite_link
approve_chat_join_request
decline_chat_join_request
set_chat_photo set_chat_photo
delete_chat_photo delete_chat_photo
set_chat_title set_chat_title

View file

@ -0,0 +1,9 @@
###############
ChatJoinRequest
###############
.. automodule:: aiogram.types.chat_join_request
:members:
:member-order: bysource
:undoc-members: True

View file

@ -67,6 +67,7 @@ Available types
chat_member_left chat_member_left
chat_member_banned chat_member_banned
chat_member_updated chat_member_updated
chat_join_request
chat_permissions chat_permissions
chat_location chat_location
bot_command bot_command

View file

@ -0,0 +1,30 @@
import pytest
from aiogram.methods import ApproveChatJoinRequest, Request
from tests.mocked_bot import MockedBot
class TestApproveChatJoinRequest:
@pytest.mark.asyncio
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(ApproveChatJoinRequest, ok=True, result=True)
response: bool = await ApproveChatJoinRequest(
chat_id=-42,
user_id=42,
)
request: Request = bot.get_request()
assert request.method == "approveChatJoinRequest"
assert response == prepare_result.result
@pytest.mark.asyncio
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(ApproveChatJoinRequest, ok=True, result=None)
response: bool = await bot.approve_chat_join_request(
chat_id=-42,
user_id=42,
)
request: Request = bot.get_request()
assert request.method == "approveChatJoinRequest"
assert response == prepare_result.result

View file

@ -17,6 +17,7 @@ class TestCreateChatInviteLink:
creator=User(id=42, is_bot=False, first_name="User"), creator=User(id=42, is_bot=False, first_name="User"),
is_primary=False, is_primary=False,
is_revoked=False, is_revoked=False,
creates_join_request=False,
), ),
) )
@ -37,6 +38,7 @@ class TestCreateChatInviteLink:
creator=User(id=42, is_bot=False, first_name="User"), creator=User(id=42, is_bot=False, first_name="User"),
is_primary=False, is_primary=False,
is_revoked=False, is_revoked=False,
creates_join_request=False,
), ),
) )

View file

@ -0,0 +1,30 @@
import pytest
from aiogram.methods import DeclineChatJoinRequest, Request
from tests.mocked_bot import MockedBot
class TestDeclineChatJoinRequest:
@pytest.mark.asyncio
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(DeclineChatJoinRequest, ok=True, result=True)
response: bool = await DeclineChatJoinRequest(
chat_id=-42,
user_id=42,
)
request: Request = bot.get_request()
assert request.method == "declineChatJoinRequest"
assert response == prepare_result.result
@pytest.mark.asyncio
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(DeclineChatJoinRequest, ok=True, result=True)
response: bool = await bot.decline_chat_join_request(
chat_id=-42,
user_id=42,
)
request: Request = bot.get_request()
assert request.method == "declineChatJoinRequest"
assert response == prepare_result.result

View file

@ -17,6 +17,7 @@ class TestEditChatInviteLink:
creator=User(id=42, is_bot=False, first_name="User"), creator=User(id=42, is_bot=False, first_name="User"),
is_primary=False, is_primary=False,
is_revoked=False, is_revoked=False,
creates_join_request=False,
), ),
) )
@ -25,7 +26,6 @@ class TestEditChatInviteLink:
) )
request: Request = bot.get_request() request: Request = bot.get_request()
assert request.method == "editChatInviteLink" assert request.method == "editChatInviteLink"
# assert request.data == {}
assert response == prepare_result.result assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot): async def test_bot_method(self, bot: MockedBot):
@ -37,6 +37,7 @@ class TestEditChatInviteLink:
creator=User(id=42, is_bot=False, first_name="User"), creator=User(id=42, is_bot=False, first_name="User"),
is_primary=False, is_primary=False,
is_revoked=False, is_revoked=False,
creates_join_request=False,
), ),
) )
@ -45,5 +46,4 @@ class TestEditChatInviteLink:
) )
request: Request = bot.get_request() request: Request = bot.get_request()
assert request.method == "editChatInviteLink" assert request.method == "editChatInviteLink"
# assert request.data == {}
assert response == prepare_result.result assert response == prepare_result.result

View file

@ -17,6 +17,7 @@ class TestRevokeChatInviteLink:
creator=User(id=42, is_bot=False, first_name="User"), creator=User(id=42, is_bot=False, first_name="User"),
is_primary=False, is_primary=False,
is_revoked=True, is_revoked=True,
creates_join_request=False,
), ),
) )
@ -26,7 +27,6 @@ class TestRevokeChatInviteLink:
) )
request: Request = bot.get_request() request: Request = bot.get_request()
assert request.method == "revokeChatInviteLink" assert request.method == "revokeChatInviteLink"
# assert request.data == {}
assert response == prepare_result.result assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot): async def test_bot_method(self, bot: MockedBot):
@ -38,6 +38,7 @@ class TestRevokeChatInviteLink:
creator=User(id=42, is_bot=False, first_name="User"), creator=User(id=42, is_bot=False, first_name="User"),
is_primary=False, is_primary=False,
is_revoked=True, is_revoked=True,
creates_join_request=False,
), ),
) )
@ -47,5 +48,4 @@ class TestRevokeChatInviteLink:
) )
request: Request = bot.get_request() request: Request = bot.get_request()
assert request.method == "revokeChatInviteLink" assert request.method == "revokeChatInviteLink"
# assert request.data == {}
assert response == prepare_result.result assert response == prepare_result.result

View file

@ -0,0 +1,32 @@
import datetime
from aiogram.methods import ApproveChatJoinRequest, DeclineChatJoinRequest
from aiogram.types import Chat, ChatJoinRequest, User
class TestChatJoinRequest:
def test_approve_alias(self):
chat_join_request = ChatJoinRequest(
chat=Chat(id=-42, type="supergroup"),
from_user=User(id=42, is_bot=False, first_name="Test"),
date=datetime.datetime.now(),
)
api_method = chat_join_request.approve()
assert isinstance(api_method, ApproveChatJoinRequest)
assert api_method.chat_id == chat_join_request.chat.id
assert api_method.user_id == chat_join_request.from_user.id
def test_decline_alias(self):
chat_join_request = ChatJoinRequest(
chat=Chat(id=-42, type="supergroup"),
from_user=User(id=42, is_bot=False, first_name="Test"),
date=datetime.datetime.now(),
)
api_method = chat_join_request.decline()
assert isinstance(api_method, DeclineChatJoinRequest)
assert api_method.chat_id == chat_join_request.chat.id
assert api_method.user_id == chat_join_request.from_user.id

View file

@ -15,6 +15,7 @@ from aiogram.methods import GetMe, GetUpdates, SendMessage
from aiogram.types import ( from aiogram.types import (
CallbackQuery, CallbackQuery,
Chat, Chat,
ChatJoinRequest,
ChatMemberMember, ChatMemberMember,
ChatMemberUpdated, ChatMemberUpdated,
ChosenInlineResult, ChosenInlineResult,
@ -418,6 +419,19 @@ class TestDispatcher:
True, True,
True, True,
), ),
pytest.param(
"chat_join_request",
Update(
update_id=42,
chat_join_request=ChatJoinRequest(
chat=Chat(id=42, type="private"),
from_user=User(id=42, is_bot=False, first_name="Test"),
date=datetime.datetime.now(),
),
),
True,
True,
),
], ],
) )
async def test_listen_update( async def test_listen_update(