Close quiz after three participants took it
(update: Update, context: ContextTypes.DEFAULT_TYPE)
| 113 | |
| 114 | |
| 115 | async def receive_quiz_answer(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: |
| 116 | """Close quiz after three participants took it""" |
| 117 | # the bot can receive closed poll updates we don't care about |
| 118 | if update.poll.is_closed: |
| 119 | return |
| 120 | if update.poll.total_voter_count == TOTAL_VOTER_COUNT: |
| 121 | try: |
| 122 | quiz_data = context.bot_data[update.poll.id] |
| 123 | # this means this poll answer update is from an old poll, we can't stop it then |
| 124 | except KeyError: |
| 125 | return |
| 126 | await context.bot.stop_poll(quiz_data["chat_id"], quiz_data["message_id"]) |
| 127 | |
| 128 | |
| 129 | async def preview(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: |
nothing calls this directly
no test coverage detected
searching dependent graphs…