1
0
mirror of https://github.com/eternnoir/pyTelegramBotAPI.git synced 2023-08-10 21:12:57 +03:00

Fix documentation for InlineKeyboardMarkup and quick_markup

This commit is contained in:
Mike Lei 2023-03-24 02:17:44 +08:00 committed by GitHub
parent da57174635
commit bd69492ed4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 11 deletions

View File

@ -2432,23 +2432,29 @@ class InlineKeyboardMarkup(Dictionaryable, JsonSerializable, JsonDeserializable)
This object represents an inline keyboard that appears right next to the message it belongs to.
.. note::
It is recommended to use :meth:`telebot.service_utils..quick_markup` instead.
It is recommended to use :meth:`telebot.util.quick_markup` instead.
.. code-block:: python3
:caption: Example of a custom keyboard with buttons.
from telebot.service_utils..import quick_markup
from telebot.util import quick_markup
markup = quick_markup(
{'text': 'Press me', 'callback_data': 'press'},
{'text': 'Press me too', 'callback_data': 'press_too'}
)
markup = quick_markup({
'Twitter': {'url': 'https://twitter.com'},
'Facebook': {'url': 'https://facebook.com'},
'Back': {'callback_data': 'whatever'}
}, row_width=2)
# returns an InlineKeyboardMarkup with two buttons in a row, one leading to Twitter, the other to facebook
# and a back button below
Telegram Documentation: https://core.telegram.org/bots/api#inlinekeyboardmarkup
:param inline_keyboard: :obj:`list` of button rows, each represented by an :obj:`list` of
:param keyboard: :obj:`list` of button rows, each represented by an :obj:`list` of
:class:`telebot.types.InlineKeyboardButton` objects
:type inline_keyboard: :obj:`list` of :obj:`list` of :class:`telebot.types.InlineKeyboardButton`
:type keyboard: :obj:`list` of :obj:`list` of :class:`telebot.types.InlineKeyboardButton`
:param row_width: number of :class:`telebot.types.InlineKeyboardButton` objects on each row
:type row_width: :obj:`int`
:return: Instance of the class
:rtype: :class:`telebot.types.InlineKeyboardMarkup`

View File

@ -420,11 +420,13 @@ def quick_markup(values: Dict[str, Dict[str, Any]], row_width: int = 2) -> types
.. code-block:: python3
:caption: Using quick_markup:
quick_markup({
from telebot.util import quick_markup
markup = quick_markup({
'Twitter': {'url': 'https://twitter.com'},
'Facebook': {'url': 'https://facebook.com'},
'Back': {'callback_data': 'whatever'}
}, row_width=2):
}, row_width=2)
# returns an InlineKeyboardMarkup with two buttons in a row, one leading to Twitter, the other to facebook
# and a back button below
@ -443,7 +445,7 @@ def quick_markup(values: Dict[str, Dict[str, Any]], row_width: int = 2) -> types
:param values: a dict containing all buttons to create in this format: {text: kwargs} {str:}
:type values: :obj:`dict`
:param row_width: int row width
:param row_width: number of :class:`telebot.types.InlineKeyboardButton` objects on each row
:type row_width: :obj:`int`
:return: InlineKeyboardMarkup