mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-25 19:03:46 +03:00
Change list of buttons to show up as rows and not cols
This commit is contained in:
parent
3bc46e8072
commit
dc29a95cef
|
@ -204,6 +204,33 @@ either ``.md_text`` or ``.html_text`` as needed. This is because both ``.text``
|
|||
may disappear in future versions, and their behaviour is not immediately obvious.
|
||||
|
||||
|
||||
Using a flat list to define buttons will now create rows and not columns
|
||||
------------------------------------------------------------------------
|
||||
|
||||
When sending a message with buttons under a bot account, passing a flat list such as the following:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
bot.send_message(chat, message, buttons=[
|
||||
Button.inline('top'),
|
||||
Button.inline('middle'),
|
||||
Button.inline('bottom'),
|
||||
])
|
||||
|
||||
Will now send a message with 3 rows of buttons, instead of a message with 3 columns (old behaviour).
|
||||
If you still want the old behaviour, wrap the list inside another list:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
bot.send_message(chat, message, buttons=[[
|
||||
# +
|
||||
Button.inline('top'),
|
||||
Button.inline('middle'),
|
||||
Button.inline('bottom'),
|
||||
]])
|
||||
#+
|
||||
|
||||
|
||||
The Conversation API has been removed
|
||||
-------------------------------------
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ from ..types import _custom
|
|||
def build_reply_markup(
|
||||
buttons: 'typing.Optional[hints.MarkupLike]',
|
||||
inline_only: bool = False) -> 'typing.Optional[_tl.TypeReplyMarkup]':
|
||||
if buttons is None:
|
||||
if not buttons:
|
||||
return None
|
||||
|
||||
try:
|
||||
|
@ -18,9 +18,9 @@ def build_reply_markup(
|
|||
pass
|
||||
|
||||
if not utils.is_list_like(buttons):
|
||||
buttons = [[buttons]]
|
||||
elif not buttons or not utils.is_list_like(buttons[0]):
|
||||
buttons = [buttons]
|
||||
if not utils.is_list_like(buttons[0]):
|
||||
buttons = [[b] for b in buttons]
|
||||
|
||||
is_inline = False
|
||||
is_normal = False
|
||||
|
|
Loading…
Reference in New Issue
Block a user