Python-telegram-bot 内联键盘消失并在操作后重新出现

问题描述 投票:0回答:1

我想单击内联键盘上的按钮,向用户发送一个骰子,使键盘消失,以便用户在骰子滚动时不会弄乱它,并且在骰子滚动后我想让它再次出现。 我用来掷骰子的代码是当用户单击“掷骰子”时执行的操作:

value = await update.callback_query.message.reply_dice(update.effective_message.chat_id, emoji= '🏀')
dice_value = valore.dice.value

键盘看起来像这样:

 keyboard_basketDemo = [
        [
            InlineKeyboardButton("⚙ Bet Settings 🍕", callback_data="SettingsDemoBet"),
            InlineKeyboardButton("Throw ball", callback_data="basketDemo"),
        ],
    ]

我如何确保键盘消失,并且在操作完成后,它会出现与之前相同的键盘,以便用户可以选择他想要执行的操作?

python-3.x python-telegram-bot
1个回答
0
投票

我用过

await update.callback_query.edit_message_reply_markup()

await update.callback_query.message.edit_text("My cards")

分别隐藏内联键盘并更改标题文本。 然后为了创建一个新键盘,我使用了

await update.callback_query.message.reply_text("Choose an option: ", reply_markup=reply_markup)
,回复标记是在函数中创建的新键盘

© www.soinside.com 2019 - 2024. All rights reserved.