Summarize a users poll vote
(update: Update, context: ContextTypes.DEFAULT_TYPE)
| 73 | |
| 74 | |
| 75 | async def receive_poll_answer(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: |
| 76 | """Summarize a users poll vote""" |
| 77 | answer = update.poll_answer |
| 78 | answered_poll = context.bot_data[answer.poll_id] |
| 79 | try: |
| 80 | questions = answered_poll["questions"] |
| 81 | # this means this poll answer update is from an old poll, we can't do our answering then |
| 82 | except KeyError: |
| 83 | return |
| 84 | selected_options = answer.option_ids |
| 85 | answer_string = "" |
| 86 | for question_id in selected_options: |
| 87 | if question_id != selected_options[-1]: |
| 88 | answer_string += questions[question_id] + " and " |
| 89 | else: |
| 90 | answer_string += questions[question_id] |
| 91 | await context.bot.send_message( |
| 92 | answered_poll["chat_id"], |
| 93 | f"{update.effective_user.mention_html()} feels {answer_string}!", |
| 94 | parse_mode=ParseMode.HTML, |
| 95 | ) |
| 96 | answered_poll["answers"] += 1 |
| 97 | # Close poll after three participants voted |
| 98 | if answered_poll["answers"] == TOTAL_VOTER_COUNT: |
| 99 | await context.bot.stop_poll(answered_poll["chat_id"], answered_poll["message_id"]) |
| 100 | |
| 101 | |
| 102 | async def quiz(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: |
nothing calls this directly
no test coverage detected
searching dependent graphs…