N
N
NOblo2020-06-19 00:07:41
Python
NOblo, 2020-06-19 00:07:41

Timer in sqlite3..... How to implement?

I used threading.Timer() and suddenly noticed that it is global. And it will not be local for each user, that is, users will knock down the timer, and it will never reach the end ... (I make a bot for tg)
There is a table in the database, let's say there are 2 columns, Id and time. In Id we have user IDs, and in time we need to build a timer, it is necessary that every 1 hour, he writes "hello" (simplified example), how can I make a timer for each user ?? How to implement it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
ScriptKiddo, 2020-06-19
@ScriptKiddo

It is necessary to store the parameter of the time when the last message was sent to the user. In a new table, or in a separate field in a table with users
In a loop, unload users whose time since the last message was sent is more than an hour.
After sending a message to the user, set the current time.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question