MCPcopy Index your code
hub / github.com/python-telegram-bot/python-telegram-bot / quiz

Function quiz

examples/pollbot.py:102–112  ·  view source on GitHub ↗

Send a predefined poll

(update: Update, context: ContextTypes.DEFAULT_TYPE)

Source from the content-addressed store, hash-verified

100
101
102async def quiz(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
103 """Send a predefined poll"""
104 questions = ["1", "2", "4", "20"]
105 message = await update.effective_message.reply_poll(
106 "How many eggs do you need for a cake?", questions, type=Poll.QUIZ, correct_option_id=2
107 )
108 # Save some info about the poll the bot_data for later use in receive_quiz_answer
109 payload = {
110 message.poll.id: {"chat_id": update.effective_chat.id, "message_id": message.message_id}
111 }
112 context.bot_data.update(payload)
113
114
115async def receive_quiz_answer(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:

Callers

nothing calls this directly

Calls 2

reply_pollMethod · 0.80
updateMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…