ed *_*tru 5 python telegram python-telegram-bot telegram-bot
def start(bot, update):
keyboard = [[InlineKeyboardButton("Apples", callback_data='1')],
[InlineKeyboardButton("Oranges", callback_data='2')],
[InlineKeyboardButton("Beans", callback_data='3')],
[InlineKeyboardButton("Rice", callback_data='4')],
[InlineKeyboardButton("Bread", callback_data='5')],
[InlineKeyboardButton("Tomatos", callback_data='6')],
[InlineKeyboardButton("Strawberry", callback_data='7')]
]
reply_markup = InlineKeyboardMarkup(keyboard)
update.message.reply_text('Multiple choice Quizz \nSelect all vegetables:', reply_markup=reply_markup)
Run Code Online (Sandbox Code Playgroud)
使用 InlineKeyboardMarkup,是否有一种方法可以为用户按钮选择提供反馈,而无需隐藏或删除 InlineKeyboardMarkup?
例如,当用户选择 InlineKeyboardButton 时,我可以:
Change the InlineKeyboardButton text
Change the appearance of the InlineKeyboardButton
Edit initial message in update.message.reply_text ( )
Run Code Online (Sandbox Code Playgroud)
我想看看是否可以提出多项选择问题,如果可以,我需要提供一种方法让用户知道按钮已被选择或按下。
如所述:https://core.telegram.org/bots#inline-keyboards-and-on-the-fly-updating
是的!可以像@music bot一样更新键盘和消息