A
A
Alexunkas2020-05-11 00:45:18
Python
Alexunkas, 2020-05-11 00:45:18

How to implement timer action execution in telegram bot?

I welcome everyone!
Such a question, how to implement a time report in a telegram bot? I write in python with telebot.
Is it necessary to use the time module or can it be omitted?

The bottom line is that the bot, after selecting a specific button, must count down the time until the next same period of time and, after it expires, perform an action, for example, +1 to the variable. How can this be implemented?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
recallyourname, 2020-05-11
@Alexunkas

For example, you can send a message when a button is clicked, notifying you of the action taken. Each object of type Message has a date field, which records the time the message was sent in unix time format. This time can be written to a variable in the executable script. On pressing the button a second time, send a notification and write this time into the second variable, subtract their difference and perform the necessary actions based on the received time. On subsequent clicks, you can change the values ​​\u200b\u200bwith a construction like

prev_time, current_time = current_time, message.date

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question