电报机器人中的轮询答案处理程序

poll answer handler in telegrapm bot

我需要从用户那里获得投票答案。

我看到了这个 ,但它对我不起作用。

@bot.message_handler(commands=['test'])
def start(message):
    bot.send_poll(message.chat.id, 'chose', ['a', 'b'])


@bot.poll_answer_handler(func=lambda call: True) #without lambda doesn't work too
def hadle_poll(call):
    print(call)

不知道怎么抓。请帮忙

编辑

我正在使用 pytelegrambotapi

解决方法很简单。 在 anonimous 民意调查中,您无法获得答案。所以你应该添加一个标志:

@bot.message_handler(commands=['test'])
def start(message):
    bot.send_poll(message.chat.id, 'chose', ['a', 'b'], is_anonymous = False)

然后您的投票处理程序将工作并获取答案。