【问题标题】:How to use ForceReply in python-telegram-bot wrapper如何在 python-telegram-bot 包装器中使用 ForceReply
【发布时间】:2018-03-08 20:00:59
【问题描述】:

我已经尝试了很长一段时间,阅读 python-telegram-bot 包装器 APIpython-telegram-bot wrapper、电报 bot API、代码 sn-ps 等,但我缺乏理解(我的编程知识是选择性的谷歌复制粘贴) 不允许我成功实施 ForceReply 选项。 (ForceReply

基本上我正在尝试的是当用户键入 /sett 时,机器人会说“输入否”。并强制用户回复该消息。

对不起,如果我遗漏了一些明显的东西。

【问题讨论】:

标签: python telegram python-telegram-bot


【解决方案1】:
bot.send_message(chat_id, 'Enter No.', reply_markup=ForceReply())

【讨论】:

  • 我已经尝试过了,但它并没有让我的电报信使引用消息(“HI”)。下面是我尝试过的代码: bot.send_message(chat_id=update.message.chat_id, text="HI", reply_markup=ForceReply())
  • 好的,我现有的机器人中似乎存在冲突代码。在新的机器人中尝试上面的代码绝对没问题。感谢您的回答。
【解决方案2】:
@bot.message_handler(content_types=['text'])
def but(message):
    markup = types.ForceReply(selective=False)
    bot.send_message(message.chat.id, "Send me another word:", reply_markup=markup)

【讨论】:

  • 欢迎来到 Stack Overflow,感谢您提供答案。如果它还包括解释,这将更有用。您可以编辑您的答案以包含它吗?
猜你喜欢
  • 1970-01-01
  • 2019-03-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-03-12
  • 1970-01-01
  • 2019-08-07
相关资源
最近更新 更多