【问题标题】:How to hide the reply keyboard after click on button in Telegram Bot using telebot?使用 Telebot 在 Telegram Bot 中单击按钮后如何隐藏回复键盘?
【发布时间】:2022-07-22 07:17:14
【问题描述】:

有些代码我创建了一个ReplyKeyboardMarkup 并希望在单击“聊天”按钮后隐藏ID。 这个怎么做?不发送新消息并删除她,例如: bot.send_message(mes.chat.id,“工作”,reply_markup=types.ReplyKeyboardRemove()) bot.delete_message(mes.chat.id, mes.message_id + 1)

以“/start”开头的代码:

def start_markup():
    markup = types.ReplyKeyboardMarkup(resize_keyboard=True, row_width=2)
    chat = types.KeyboardButton(text="Chat",)
    markup.add(chat)
    return markup

@bot.message_handler(commands=['start'])
def start(mes):
    res = bot.send_message(mes.chat.id , "Chose what do u want", reply_markup=start_markup())

//此时我已经不得不隐藏回复键盘了

@bot.message_handler() 
def get_message(mes):
    if mes.text == "Chat":
        markup = types.InlineKeyboardMarkup().add(types.InlineKeyboardButton(text='Click', url='...'))
        bot.send_message(mes.chat.id, "Click!!!", reply_markup = markup)

【问题讨论】:

    标签: python bots telegram-bot telebot


    【解决方案1】:

    我认为你只需要使用ReplyKeyboardRemove(),比如:

    reply_markup = ReplyKeyboardRemove()

    【讨论】:

      猜你喜欢
      • 2012-11-15
      • 2016-10-20
      • 2016-12-06
      • 2011-07-06
      • 2017-09-20
      • 2017-05-23
      • 2016-06-14
      • 2017-10-15
      相关资源
      最近更新 更多