How do you do the telegram bot?
Welcome! I need to make a timer in Telegram bot'e, which, every three days, reminds the group to do the repairs.
User to command /remont - Main Answers the question, "What is it?" Answers the question, "What malfunction?" This is further entered into the SQLite database in line: user_id, what_broke, defect, date_of_detection.
date_of_detection receives as follows:
tconv = lambda x: time.strftime("%H:%M:%S %d.%m.%Y", time.localtime(x)) date = tconv(message.date)
The table looks like this:
What did I try?
I'll try to do this through a separate cycle that, once every three days, turns on and checks the date, stuck in the OBD test, I can't compare it properly to the date in the database, it gives very strange meanings. def select_yesterday_tasks(cursor): cursor = conn.cursor() cursor.execute('SELECT (*) FROM remont WHERE date_of_detection date('now','3 day') for row in rows: bot.send_message(group_id, row)
In the case of the above table, 1 communication 1.2, 3.4 shall be issued in turn 4. Although the dates indicated do not correspond to the 3 days from the 'now' (proposed that the OBD considers its date of application to the table, but also does not correspond to the condition)
I'd like to see that the extradition is broken, which corresponds to the condition (- 3 day).
I'd be happy to see any example, a solution to my problem or another implementation plan, or I'm confused.
P. S. TelegramBotAPI+Python+SQLite
Of course, my decision can be compared to the crutch, which is even true. But you can try to keep the date in line, and secondly, you don't really understand why you're having a cycle.
который раз в трое суток включается♪ So it's time, and you can go, or if you want to work with a lot of communities, you're already doing a cycle, like once a minute, and you're already running through the database and watching where time has passed. Also, you may, when the program is launched, introduce a counter. And when you get a message to the bud, you're gonna have to inject this counter. And bypassing the database, check the difference between the current counter and the sheets. But even though this method is easier, I don't recommend it because the server can fall off and time will come.