Answer the question
In order to leave comments, you need to log in
How to implement adding options to a poll using python-telegram-bot?
I'm trying to write a telegram bot using python-telegram-bot.
I can't figure out how to implement adding answer options to the poll as inline buttons.
As I see it, there are 3 options:
1 - You can create each option in one message on different lines. Then you need to somehow describe the function that creates the number of options = the number of lines. Use a loop? what to cling to?
2 - You can create a button each separately, but in this case, if you refer to the same function, where to store the previous buttons? they will be interchangeable.
I wanted to try to do it using the ConversationHandler, but, as I understand it, in this way you can only add a fixed value of options (for example, only 3)
Perhaps all of these options are initially wrong. Please give me an idea.
Answer the question
In order to leave comments, you need to log in
#Список с ответами
answers = ['вариант 1', 'вариант 2', 'вариант 3', 'вариант 4']
markup = types.InlineKeyboardMarkup()
for answer in answers:
button = types.InlineKeyboardButton(text=answer, callback_data=answer)
markup.row(button)
question = 'какой вариант выберете?'
bot.send_message(message.chat.id, question, reply_markup=marckup)
May be able to help: https://groosha.gitbook.io/telegram-bot-lessons/ch...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question