Telegram bot API:我可以混合使用自定义键盘和 force_reply 吗? [英] Telegram bot API: Can I mix a custom keyboard and a force_reply?

查看:42
本文介绍了Telegram bot API:我可以混合使用自定义键盘和 force_reply 吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个自定义键盘,但要处理答案,我需要强制回复,以便我在下一条消息中回复问题.我已经这样做了:

var opts = {回复标记:JSON.stringify({键盘:[['确定','取消']],one_time_keyboard: 真,resize_keyboard: 真,force_reply: 真})};

键盘有效,但 force_reply 无效.强制回复自己的作品?不能与自定义键盘结合使用吗?

解决方案

可能来不及帮助你,但它来了.

目前只有一个 reply_markup 字段是允许的,并且该字段必须只包含以下类型之一:ReplyKeyboardMarkupReplyKeyboardHideForceReply(参见文档)

在任何情况下,您都可以使用 ReplyKeyboardMarkup,它会直接在用户应用程序中弹出一个自定义键盘并对您的机器人进行编码,使其只接受您自己的自定义键盘中的一个答案.>

此外,如果您真的想强制用户回复,您可以在每个用户的无效回复后继续发送相同的ReplyKeyboardMarkup.

I have a custom keyboard but to process the answer i need a force reply so i get the question back in the next message. I have done this:

var opts = {
    reply_markup: JSON.stringify({ 
        keyboard: [['OK','Cancel']],
        one_time_keyboard: true,
        resize_keyboard: true,
        force_reply: true
    })
};

The keyboard works but not the force_reply. Force reply on its own works? Can i not use it in combination with a custom keyboard?

解决方案

It may be late to help you, but here it goes.

Currently only one reply_markup field is allow and this field must contain only one of the following types: ReplyKeyboardMarkup or ReplyKeyboardHide or ForceReply (see docs)

In any case, you can use ReplyKeyboardMarkup that will pop up a custom keyboard in the user app directly and code your bot so it only accept one of the answer in your own custom keyboards.

Furthermore, if you really want to force that the user reply, you can keep sending the same ReplyKeyboardMarkup after each user's invalid answer.

这篇关于Telegram bot API:我可以混合使用自定义键盘和 force_reply 吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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