Skip to content

Documentation Improvements #4303

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Jul 12, 2024
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ Feel free to copy (parts of) the checklist to the PR description to remind you o
- Added or updated documentation for the changed class(es) and/or method(s)
- Added the new method(s) to ``_extbot.py``
- Added or updated ``bot_methods.rst``
- Updated the Bot API version number in all places: ``README.rst`` and ``README_RAW.rst`` (including the badge), as well as ``telegram.constants.BOT_API_VERSION_INFO``
- Updated the Bot API version number in all places: ``README.rst`` (including the badge) and ``telegram.constants.BOT_API_VERSION_INFO``
- Added logic for arbitrary callback data in :class:`telegram.ext.ExtBot` for new methods that either accept a ``reply_markup`` in some form or have a return type that is/contains :class:`~telegram.Message`

Documenting
Expand Down
29 changes: 15 additions & 14 deletions telegram/_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -3972,7 +3972,7 @@ async def edit_message_text(
Use this method to edit text and game messages.

Note:
* |editreplymarkup|.
* |editreplymarkup|
* |bcid_edit_time|

.. seealso:: :attr:`telegram.Game.text`
Expand Down Expand Up @@ -5037,15 +5037,16 @@ async def send_invoice(
.. versionchanged:: 20.0
|sequenceargs|
max_tip_amount (:obj:`int`, optional): The maximum accepted amount for tips in the
*smallest* units of the currency (integer, **not** float/double). For example, for
a maximum tip of US$ 1.45 pass ``max_tip_amount = 145``. See the exp parameter in
`currencies.json <https://core.telegram.org/bots/payments/currencies.json>`_, it
shows the number of digits past the decimal point for each currency (2 for the
majority of currencies). Defaults to ``0``. Not supported for payment in |tg_stars|
*smallest units* of the currency (integer, **not** float/double). For example, for
a maximum tip of ``US$ 1.45`` pass ``max_tip_amount = 145``. See the ``exp``
parameter in `currencies.json
<https://core.telegram.org/bots/payments/currencies.json>`_, it shows the number of
digits past the decimal point for each currency (2 for the majority of currencies).
Defaults to ``0``. Not supported for payment in |tg_stars|.

.. versionadded:: 13.5
suggested_tip_amounts (Sequence[:obj:`int`], optional): An array of
suggested amounts of tips in the *smallest* units of the currency (integer, **not**
suggested amounts of tips in the *smallest units* of the currency (integer, **not**
float/double). At most :tg-const:`telegram.Invoice.MAX_TIP_AMOUNTS` suggested tip
amounts can be specified. The suggested tip amounts must be positive, passed in a
strictly increased order and must not exceed :paramref:`max_tip_amount`.
Expand Down Expand Up @@ -7978,14 +7979,14 @@ async def create_invoice_link(
.. versionchanged:: 20.0
|sequenceargs|
max_tip_amount (:obj:`int`, optional): The maximum accepted amount for tips in the
*smallest* units of the currency (integer, **not** float/double). For example, for
a maximum tip of US$ 1.45 pass ``max_tip_amount = 145``. See the exp parameter in
`currencies.json <https://core.telegram.org/bots/payments/currencies.json>`_, it
shows the number of digits past the decimal point for each currency (2 for the
majority of currencies). Defaults to ``0``. Not supported for payments in
|tg_stars|.
*smallest units* of the currency (integer, **not** float/double). For example, for
a maximum tip of ``US$ 1.45`` pass ``max_tip_amount = 145``. See the ``exp``
parameter in `currencies.json
<https://core.telegram.org/bots/payments/currencies.json>`_, it shows the number of
digits past the decimal point for each currency (2 for the majority of currencies).
Defaults to ``0``. Not supported for payments in |tg_stars|.
suggested_tip_amounts (Sequence[:obj:`int`], optional): An array of
suggested amounts of tips in the *smallest* units of the currency (integer, **not**
suggested amounts of tips in the *smallest units* of the currency (integer, **not**
float/double). At most :tg-const:`telegram.Invoice.MAX_TIP_AMOUNTS` suggested tip
amounts can be specified. The suggested tip amounts must be positive, passed in a
strictly increased order and must not exceed :paramref:`max_tip_amount`.
Expand Down
2 changes: 1 addition & 1 deletion telegram/_callbackquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class CallbackQuery(TelegramObject):
with the callback button that originated the query.

.. versionchanged:: 20.8
Objects maybe be of type :class:`telegram.MaybeInaccessibleMessage` since Bot API
Objects may be of type :class:`telegram.MaybeInaccessibleMessage` since Bot API
7.0.
data (:obj:`str` | :obj:`object`): Optional. Data associated with the callback button.
Be aware that the message, which originated the query, can contain no callback buttons
Expand Down
20 changes: 13 additions & 7 deletions telegram/_inline/inlinekeyboardbutton.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class InlineKeyboardButton(TelegramObject):
working as expected. Putting a game short name in it might, but is not guaranteed to
work.
* If your bot allows for arbitrary callback data, in keyboards returned in a response
from telegram, :attr:`callback_data` maybe be an instance of
from telegram, :attr:`callback_data` may be an instance of
:class:`telegram.ext.InvalidCallbackData`. This will be the case, if the data
associated with the button was already deleted.

Expand Down Expand Up @@ -119,9 +119,12 @@ class InlineKeyboardButton(TelegramObject):
This is similar to the new parameter :paramref:`switch_inline_query_chosen_chat`,
but gives no control over which chats can be selected.
switch_inline_query_current_chat (:obj:`str`, optional): If set, pressing the button will
prompt the user to select one of their chats of the specified type, open that chat and
insert the bot's username and the specified inline query in the input field. Not
supported for messages sent on behalf of a Telegram Business account.
insert the bot's username and the specified inline query in the current chat's input
field. May be empty, in which case only the bot's username will be inserted.

This offers a quick way for the user to open your bot in inline mode in the same chat
- good for selecting something from multiple options. Not supported in channels and for
messages sent on behalf of a Telegram Business account.
callback_game (:class:`telegram.CallbackGame`, optional): Description of the game that will
be launched when the user presses the button

Expand Down Expand Up @@ -187,9 +190,12 @@ class InlineKeyboardButton(TelegramObject):
This is similar to the new parameter :paramref:`switch_inline_query_chosen_chat`,
but gives no control over which chats can be selected.
switch_inline_query_current_chat (:obj:`str`): Optional. If set, pressing the button will
prompt the user to select one of their chats of the specified type, open that chat and
insert the bot's username and the specified inline query in the input field. Not
supported for messages sent on behalf of a Telegram Business account.
insert the bot's username and the specified inline query in the current chat's input
field. May be empty, in which case only the bot's username will be inserted.

This offers a quick way for the user to open your bot in inline mode in the same chat
- good for selecting something from multiple options. Not supported in channels and for
messages sent on behalf of a Telegram Business account.
callback_game (:class:`telegram.CallbackGame`): Optional. Description of the game that will
be launched when the user presses the button.

Expand Down
2 changes: 1 addition & 1 deletion telegram/_inline/inlinekeyboardmarkup.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class InlineKeyboardMarkup(TelegramObject):
An inline keyboard on a message

.. seealso::
An another kind of keyboard would be the :class:`telegram.ReplyKeyboardMarkup`.
Another kind of keyboard would be the :class:`telegram.ReplyKeyboardMarkup`.

Examples:
* :any:`Inline Keyboard 1 <examples.inlinekeyboard>`
Expand Down
15 changes: 7 additions & 8 deletions telegram/_inline/inputinvoicemessagecontent.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,13 @@ class InputInvoiceMessageContent(InputMessageContent):
|sequenceclassargs|

max_tip_amount (:obj:`int`, optional): The maximum accepted amount for tips in the
*smallest* units of the currency (integer, **not** float/double). For example, for a
maximum tip of US$ 1.45 pass ``max_tip_amount = 145``. See the ``exp`` parameter in
*smallest units* of the currency (integer, **not** float/double). For example, for a
maximum tip of ``US$ 1.45`` pass ``max_tip_amount = 145``. See the ``exp`` parameter in
`currencies.json <https://core.telegram.org/bots/payments/currencies.json>`_, it
shows the number of digits past the decimal point for each currency (2 for the majority
of currencies). Defaults to ``0``. Defaults to ``0``. Not supported for payments in
|tg_stars|.
of currencies). Defaults to ``0``. Not supported for payments in |tg_stars|.
suggested_tip_amounts (Sequence[:obj:`int`], optional): An array of suggested
amounts of tip in the *smallest* units of the currency (integer, **not** float/double).
amounts of tip in the *smallest units* of the currency (integer, **not** float/double).
At most 4 suggested tip amounts can be specified. The suggested tip amounts must be
positive, passed in a strictly increased order and must not exceed
:attr:`max_tip_amount`.
Expand Down Expand Up @@ -131,13 +130,13 @@ class InputInvoiceMessageContent(InputMessageContent):
|tupleclassattrs|

max_tip_amount (:obj:`int`): Optional. The maximum accepted amount for tips in the
*smallest* units of the currency (integer, **not** float/double). For example, for a
maximum tip of US$ 1.45 ``max_tip_amount`` is ``145``. See the ``exp`` parameter in
*smallest units* of the currency (integer, **not** float/double). For example, for a
maximum tip of ``US$ 1.45`` ``max_tip_amount`` is ``145``. See the ``exp`` parameter in
`currencies.json <https://core.telegram.org/bots/payments/currencies.json>`_, it
shows the number of digits past the decimal point for each currency (2 for the majority
of currencies). Defaults to ``0``. Not supported for payments in |tg_stars|.
suggested_tip_amounts (Tuple[:obj:`int`]): Optional. An array of suggested
amounts of tip in the *smallest* units of the currency (integer, **not** float/double).
amounts of tip in the *smallest units* of the currency (integer, **not** float/double).
At most 4 suggested tip amounts can be specified. The suggested tip amounts must be
positive, passed in a strictly increased order and must not exceed
:attr:`max_tip_amount`.
Expand Down
14 changes: 4 additions & 10 deletions telegram/_keyboardbuttonrequest.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,12 @@

class KeyboardButtonRequestUsers(TelegramObject):
"""This object defines the criteria used to request a suitable user. The identifier of the
selected user will be shared with the bot when the corresponding button is pressed.
selected user will be shared with the bot when the corresponding button is pressed. `More
about requesting users » <https://core.telegram.org/bots/features#chat-and-user-selection>`_.

Objects of this class are comparable in terms of equality. Two objects of this class are
considered equal, if their :attr:`request_id` is equal.

.. seealso::
`Telegram Docs on requesting users \
<https://core.telegram.org/bots/features#chat-and-user-selection>`_

.. versionadded:: 20.8
This class was previously named ``KeyboardButtonRequestUser``.

Expand Down Expand Up @@ -136,15 +133,12 @@ def __init__(

class KeyboardButtonRequestChat(TelegramObject):
"""This object defines the criteria used to request a suitable chat. The identifier of the
selected user will be shared with the bot when the corresponding button is pressed.
selected user will be shared with the bot when the corresponding button is pressed. `More
about requesting users » <https://core.telegram.org/bots/features#chat-and-user-selection>`_.

Objects of this class are comparable in terms of equality. Two objects of this class are
considered equal, if their :attr:`request_id` is equal.

.. seealso::
`Telegram Docs on requesting chats \
<https://core.telegram.org/bots/features#chat-and-user-selection>`_

.. versionadded:: 20.1

Args:
Expand Down
16 changes: 13 additions & 3 deletions telegram/_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ class Message(MaybeInaccessibleMessage):
effect_id (:obj:`str`, optional): Unique identifier of the message effect added to the
message.

..versionadded:: 21.3
.. versionadded:: 21.3

caption_entities (Sequence[:class:`telegram.MessageEntity`], optional): For messages with a
Caption. Special entities like usernames, URLs, bot commands, etc. that appear in the
Expand All @@ -358,6 +358,7 @@ class Message(MaybeInaccessibleMessage):
about the animation. For backward compatibility, when this field is set, the document
field will also be set.
game (:class:`telegram.Game`, optional): Message is a game, information about the game.
`More about games >> <https://core.telegram.org/bots/api#games>`_.
photo (Sequence[:class:`telegram.PhotoSize`], optional): Message is a photo, available
sizes of the photo. This list is empty if the message does not contain a photo.

Expand All @@ -373,7 +374,8 @@ class Message(MaybeInaccessibleMessage):
video.
voice (:class:`telegram.Voice`, optional): Message is a voice message, information about
the file.
video_note (:class:`telegram.VideoNote`, optional): Message is a video note, information
video_note (:class:`telegram.VideoNote`, optional): Message is a
`video note <https://telegram.org/blog/video-messages-and-telescope>`_, information
about the video message.
new_chat_members (Sequence[:class:`telegram.User`], optional): New members that were added
to the group or supergroup and information about them (the bot itself may be one of
Expand Down Expand Up @@ -429,10 +431,13 @@ class Message(MaybeInaccessibleMessage):
:class:`telegram.InaccessibleMessage`.
invoice (:class:`telegram.Invoice`, optional): Message is an invoice for a payment,
information about the invoice.
`More about payments >> <https://core.telegram.org/bots/api#payments>`_.
successful_payment (:class:`telegram.SuccessfulPayment`, optional): Message is a service
message about a successful payment, information about the payment.
`More about payments >> <https://core.telegram.org/bots/api#payments>`_.
connected_website (:obj:`str`, optional): The domain name of the website on which the user
has logged in.
`More about Telegram Login >> <https://core.telegram.org/widgets/login>`_.
author_signature (:obj:`str`, optional): Signature of the post author for messages in
channels, or the custom title of an anonymous group administrator.
passport_data (:class:`telegram.PassportData`, optional): Telegram Passport data.
Expand Down Expand Up @@ -670,6 +675,7 @@ class Message(MaybeInaccessibleMessage):

.. seealso:: :wiki:`Working with Files and Media <Working-with-Files-and-Media>`
game (:class:`telegram.Game`): Optional. Message is a game, information about the game.
`More about games >> <https://core.telegram.org/bots/api#games>`_.
photo (Tuple[:class:`telegram.PhotoSize`]): Optional. Message is a photo, available
sizes of the photo. This list is empty if the message does not contain a photo.

Expand All @@ -693,7 +699,8 @@ class Message(MaybeInaccessibleMessage):
the file.

.. seealso:: :wiki:`Working with Files and Media <Working-with-Files-and-Media>`
video_note (:class:`telegram.VideoNote`): Optional. Message is a video note, information
video_note (:class:`telegram.VideoNote`): Optional. Message is a
`video note <https://telegram.org/blog/video-messages-and-telescope>`_, information
about the video message.

.. seealso:: :wiki:`Working with Files and Media <Working-with-Files-and-Media>`
Expand Down Expand Up @@ -750,10 +757,13 @@ class Message(MaybeInaccessibleMessage):
:class:`telegram.InaccessibleMessage`.
invoice (:class:`telegram.Invoice`): Optional. Message is an invoice for a payment,
information about the invoice.
`More about payments >> <https://core.telegram.org/bots/api#payments>`_.
successful_payment (:class:`telegram.SuccessfulPayment`): Optional. Message is a service
message about a successful payment, information about the payment.
`More about payments >> <https://core.telegram.org/bots/api#payments>`_.
connected_website (:obj:`str`): Optional. The domain name of the website on which the user
has logged in.
`More about Telegram Login >> <https://core.telegram.org/widgets/login>`_.
author_signature (:obj:`str`): Optional. Signature of the post author for messages in
channels, or the custom title of an anonymous group administrator.
passport_data (:class:`telegram.PassportData`): Optional. Telegram Passport data.
Expand Down
12 changes: 6 additions & 6 deletions telegram/_payment/invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ class Invoice(TelegramObject):
generate this invoice.
currency (:obj:`str`): Three-letter ISO 4217 currency code, or ``XTR`` for payments in
|tg_stars|.
total_amount (:obj:`int`): Total price in the smallest units of the currency (integer, not
float/double). For example, for a price of US$ 1.45 pass ``amount = 145``. See the
``exp`` parameter in
total_amount (:obj:`int`): Total price in the smallest units of the currency (integer,
**not** float/double). For example, for a price of ``US$ 1.45`` pass ``amount = 145``.
See the ``exp`` parameter in
`currencies.json <https://core.telegram.org/bots/payments/currencies.json>`_,
it shows the number of digits past the decimal point for each currency
(2 for the majority of currencies).
Expand All @@ -53,9 +53,9 @@ class Invoice(TelegramObject):
generate this invoice.
currency (:obj:`str`): Three-letter ISO 4217 currency code, or ``XTR`` for payments in
|tg_stars|.
total_amount (:obj:`int`): Total price in the smallest units of the currency (integer, not
float/double). For example, for a price of US$ 1.45 ``amount`` is ``145``. See the
``exp`` parameter in
total_amount (:obj:`int`): Total price in the smallest units of the currency (integer,
**not** float/double). For example, for a price of ``US$ 1.45`` pass ``amount = 145``.
See the ``exp`` parameter in
`currencies.json <https://core.telegram.org/bots/payments/currencies.json>`_,
it shows the number of digits past the decimal point for each currency
(2 for the majority of currencies).
Expand Down
Loading
Loading