用户在Telegram Bot API中单击后如何隐藏ReplyKeyboardMarkup [英] How to hide ReplyKeyboardMarkup after user click in Telegram Bot API

查看:664
本文介绍了用户在Telegram Bot API中单击后如何隐藏ReplyKeyboardMarkup的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Node.js telegram-bot-api

I am using Node.js telegram-bot-api.

想法:


  1. 用一个按钮显示自定义键盘 - 分享我的电话号码。

  2. 当用户点击此按钮时,应发送联系人并从屏幕上删除按钮。



<这是我现在使用的代码:

Here is a code I am using right now:

bot.sendMessage({
    text: 'Please give us your phone number',
    reply_markup: JSON.stringify({
        keyboard: [
            [{
                text: 'Share my phone number',
                request_contact: true
            }]
        ],
        resize_keyboard: true,
        one_time_keyboard: true
    })
});

问题:


  • 当用户点击分享我的电话号码按钮时,它会分享他的联系人,但即使在此之后按钮仍然可见。

  • 当我不使用 request_contact flag, one_time_keyboard 正常工作(使用后隐藏按钮),但即使在这种情况下它只是隐藏按钮,因此用户可以单击一个图标将它带回屏幕,这一点都不好。

  • When user clicks "Share my phone number" button, it shares his contact but button is visible even after that.
  • When I am not using request_contact flag, one_time_keyboard works correctly (hides the button after its usage), but even in that case it just hides the button, so user can click an icon to bring it back to screen, which is not good at all.

请告诉我这里是否做错了。谢谢

Please tell me if I am doing something wrong here. Thanks

推荐答案

找到它。

这是一个解决方案:

bot.sendMessage({
    chat_id: message.chat.id,
    text: 'Some text...',
    reply_markup: JSON.stringify({
        hide_keyboard: true
    })
});

这篇关于用户在Telegram Bot API中单击后如何隐藏ReplyKeyboardMarkup的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆