mirror of
https://github.com/eternnoir/pyTelegramBotAPI.git
synced 2023-08-10 21:12:57 +03:00
Merge pull request #1894 from Muhammad-Aadil/master
Added poll_example.py in the examples
This commit is contained in:
commit
fdd82a5e4b
32
examples/poll_example.py
Normal file
32
examples/poll_example.py
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
|
||||||
|
# This is an example file to create quiz polls
|
||||||
|
import telebot
|
||||||
|
|
||||||
|
API_TOKEN = "<api_token>"
|
||||||
|
|
||||||
|
bot = telebot.TeleBot(API_TOKEN)
|
||||||
|
|
||||||
|
|
||||||
|
@bot.message_handler(commands=["poll"])
|
||||||
|
def create_poll(message):
|
||||||
|
bot.send_message(message.chat.id, "English Article Test")
|
||||||
|
answer_options = ["a", "an", "the", "-"]
|
||||||
|
|
||||||
|
bot.send_poll(
|
||||||
|
chat_id=message.chat.id,
|
||||||
|
question="We are going to '' park.",
|
||||||
|
options=answer_options,
|
||||||
|
type="quiz",
|
||||||
|
correct_option_id=2,
|
||||||
|
is_anonymous=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@bot.poll_answer_handler()
|
||||||
|
def handle_poll(poll):
|
||||||
|
# This handler can be used to log User answers and to send next poll
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
bot.infinity_polling()
|
Loading…
x
Reference in New Issue
Block a user