2023-09-01 12:42:55 +00:00
|
|
|
import time
|
|
|
|
|
2023-09-01 13:00:55 +00:00
|
|
|
import deltachat
|
2023-09-01 12:42:55 +00:00
|
|
|
|
2023-09-01 21:58:54 +00:00
|
|
|
from remember_remember_bot.commands import remind_user, handle_incoming_message
|
2023-09-01 15:01:03 +00:00
|
|
|
from remember_remember_bot.util import check_new_day, update_day
|
|
|
|
|
2023-09-01 13:00:55 +00:00
|
|
|
|
|
|
|
def loop(ac: deltachat.Account):
|
2023-09-01 12:42:55 +00:00
|
|
|
current_day = 0
|
|
|
|
while True:
|
|
|
|
if check_new_day(current_day):
|
2023-09-01 15:01:03 +00:00
|
|
|
for user in ac.get_contacts():
|
|
|
|
if (
|
|
|
|
user.get_chat()
|
|
|
|
): # does this return None if there is no existing chat?
|
|
|
|
remind_user(user)
|
2023-09-01 12:42:55 +00:00
|
|
|
current_day = update_day()
|
2023-09-01 21:58:54 +00:00
|
|
|
for msg in ac.get_fresh_messages():
|
|
|
|
handle_incoming_message(msg)
|
2023-09-01 12:42:55 +00:00
|
|
|
time.sleep(1)
|