A
A
arsfilinov2021-09-18 18:28:42
Bots
arsfilinov, 2021-09-18 18:28:42

How to schedule an action in python?

I have a telegram bot. Where should auto income from internal businesses go in the bot. How can I add a certain amount to a variable every hour?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
antares4045, 2021-09-18
@arsfilinov

Question from the title: shedule library
Question from the text of the question: Threading+sleep library
In fact, improve the formula that calculates based on the current date, the date when the formula was last calculated and the value of this formula in the last calculation. Store the date and past value and update when the user asks. This approach will save you a lot of computing resources.

I
invilso, 2021-09-18
@invilso

Head-on solution:

import time
while True:
    time.sleep(59)
    if time.localtime().tm_min == 59:
        #тут действие

K
kalterfad, 2021-09-20
@kalterfad

To perform periodic tasks, there is Celery.
It is quite easy to set up and works, in the literal sense, like a clock.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question