如何使用 telebot 模块在 bot window 中创建一个内联按钮,如果单击该按钮,其工作方式与群组中的 'Create poll' 按钮非常相似?
How to use telebot module to create an inline button in bot window, which if clicked will work very similar to 'Create poll' button found in groups?
我对 python 比较陌生,我正在尝试使用 telebot 创建一个电报机器人,这将创建一个类似测验的游戏,每个用户也可以创建自己的类似测验的游戏。在用户逐步创建此测验的过程中,有一次,我需要他们向我发送一个投票,就像他们如何在一个组中创建一个新的投票一样。但是电报机器人中没有创建投票按钮,因为这些按钮通常在群组中找到,而不是在一对一聊天中。
所以我需要创建一个内联键盘按钮,单击该按钮将使用户创建一个投票并将其发送给机器人。我已经浏览了 github 中的文档,但找不到任何有用的信息。
这个类似的东西是由telegram自己的“Quizbot”实现的。为了清楚起见,我将附上该机器人的屏幕截图。请帮助我确定如何在我的机器人中实施它。
如果点击“创建问题”按钮:
我是 python 和编码的菜鸟,所以请帮我解决这个问题。
编辑:如果我使用的是电报桌面而不是 phone,我可以向机器人发送投票。我想知道如何在 phone.
中启用它
通过使用远程机器人,我们可以做到这一点。这也让我们有机会从 phone 个应用创建投票。
import telebot
from telebot.types import ReplyKeyboardMarkup,KeyboardButton,
KeyboardButtonPollType,ReplyKeyboardRemove
bot=telebot.Telebot(token='your bot token')
poll_markup=ReplyKeyboardMarkup(one_time_keyboard=True)
poll_markup.add(KeyboardButton('send me a poll',
request_poll=KeyboardButtonPollType(type='quiz')))
#from my experience, only quiz type and regular type polls can be send.
remove_board=ReplyKeyboardRemove()
bot.send_message(chat_id,text,reply_markup=poll_markup)
#some other code here
#this can be used to remove the replykeyboard when you no longer need it.
bot.send_message(chat_id,text,reply_markup=remove_board)
我对 python 比较陌生,我正在尝试使用 telebot 创建一个电报机器人,这将创建一个类似测验的游戏,每个用户也可以创建自己的类似测验的游戏。在用户逐步创建此测验的过程中,有一次,我需要他们向我发送一个投票,就像他们如何在一个组中创建一个新的投票一样。但是电报机器人中没有创建投票按钮,因为这些按钮通常在群组中找到,而不是在一对一聊天中。 所以我需要创建一个内联键盘按钮,单击该按钮将使用户创建一个投票并将其发送给机器人。我已经浏览了 github 中的文档,但找不到任何有用的信息。
这个类似的东西是由telegram自己的“Quizbot”实现的。为了清楚起见,我将附上该机器人的屏幕截图。请帮助我确定如何在我的机器人中实施它。
如果点击“创建问题”按钮:
我是 python 和编码的菜鸟,所以请帮我解决这个问题。
编辑:如果我使用的是电报桌面而不是 phone,我可以向机器人发送投票。我想知道如何在 phone.
中启用它通过使用远程机器人,我们可以做到这一点。这也让我们有机会从 phone 个应用创建投票。
import telebot
from telebot.types import ReplyKeyboardMarkup,KeyboardButton,
KeyboardButtonPollType,ReplyKeyboardRemove
bot=telebot.Telebot(token='your bot token')
poll_markup=ReplyKeyboardMarkup(one_time_keyboard=True)
poll_markup.add(KeyboardButton('send me a poll',
request_poll=KeyboardButtonPollType(type='quiz')))
#from my experience, only quiz type and regular type polls can be send.
remove_board=ReplyKeyboardRemove()
bot.send_message(chat_id,text,reply_markup=poll_markup)
#some other code here
#this can be used to remove the replykeyboard when you no longer need it.
bot.send_message(chat_id,text,reply_markup=remove_board)