'Pyrogram telegram poll : how to get the chosen option from user
I created a telegram bot that sends quiz with pyrogram, but i want to get the user's answer using a method called Poll.chosen_option and then compare it with the correct answer!! But this method returns None, Please how can i solve that and get what user chosen! Here is my code:
@app.on_message(filters.private & filters.text)
async def my_quiz(client, message : Message):
quiz() # function returns global vars question, answers, answersID
result = await app.send_poll(chat_id=message.chat.id, question=question, options=answers, is_anonymous=False, type="quiz", correct_option_id=answerID)
print(result.poll.chosen_option) # here it returns None, it should return the index of the answer that the user choose
Solution 1:[1]
result will give you the return value of sendPoll - immediately after the message has been sent and before the user could have a chance to vote on the poll.
You'll need to catch the poll answer event separately. TBH, I'm not familiar with pyrogram so I can't tell you how that's done in pyrogram.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | CallMeStag |
