问题描述
我对python还是比较陌生,我正在尝试使用telebot创建电报机器人,这将创建一个类似测验的游戏,并且每个用户也可以创建自己的类似测验的游戏。在由用户创建此测验的分步过程中,一次,我需要他们向我发送调查,就像他们在组中创建新调查一样。但是电报bot内没有创建轮询按钮,因为这些按钮通常在组中而不是在一对一聊天中找到。 因此,我需要创建一个嵌入式键盘按钮,单击该按钮将使用户可以创建民意调查并将其发送给机器人。我浏览了github中的文档,找不到任何有用的东西。
类似的事情由电报自己的“ Quizbot”实现。为了清楚起见,我将附上该机器人的屏幕截图。请帮助我确定如何在我的漫游器中实现它。
我是python和编码的菜鸟,所以请帮我解决这个问题。
编辑:如果我使用电报桌面而不是通过电话,则可以将民意调查发送给漫游器。我想知道如何在手机中启用它。
解决方法
通过使用Telebot,我们可以做到这一点。这也使我们有机会从电话应用程序中创建民意调查。
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,reply_markup=remove_board)