E
E
Evgeny Kokorin2021-03-10 22:36:16
Python
Evgeny Kokorin, 2021-03-10 22:36:16

How to make timer in python with validation(pytelegrambotapi)?

I have a method that handles buttons:

@bot.message_handler(content_types=['text'])
def buttons(message):
    if message.chat.type == 'private':
        if message.text == 'Задание 1':
           <..Запуск таймера, 30 секунд..>
           <..Результат..>
        elif message.text == 'Задание 2':
           <..Запуск таймера, 60 секунд..>               
           <..Результат..>

How to create two different timers and most importantly, how to make a check: if one is running, then the second cannot be started until the first one ends. All I could find on the Internet is a proposal to create a class with a timer and a boolean variable. If it is correct, please tell me how to do it.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question