【问题标题】:Telegram bot: customise buttons position on keyboardTelegram bot:自定义键盘上的按钮位置
【发布时间】:2017-06-13 14:49:06
【问题描述】:

有没有办法自定义键盘上的按钮位置?

例子:我们有

import telegram

def start(bot, update):

    kb = [[telegram.KeyboardButton('/command1')],
          [telegram.KeyboardButton('/command2')],
          [telegram.KeyboardButton('/command3')]]
    kb_markup = telegram.ReplyKeyboardMarkup(kb, resize_keyboard=True)

    bot.send_message(chat_id=update.message.chat_id,
                     text="Welcome!",
                     reply_markup=kb_markup)

因此我们的键盘有 3 个按钮,每个按钮在自己的一行中。

我想在第一行有 2 个按钮,在第二行有 1 个按钮。有可能吗?

【问题讨论】:

    标签: python telegram telegram-bot python-telegram-bot


    【解决方案1】:

    是的,当然!

    [[button1, button2],
     [button3]]
    

    整体列表中的每一行对应kb上的一行

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-09-14
      • 2016-04-26
      • 2020-03-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-24
      • 1970-01-01
      • 2017-01-05
      相关资源
      最近更新 更多