From 190e6cf8634ee165fe717a7e0e63f72783bbdf70 Mon Sep 17 00:00:00 2001 From: missytake Date: Sun, 3 Sep 2023 13:27:06 +0200 Subject: [PATCH] actually we want to remind chats, not users --- src/remember_remember_bot/commands.py | 5 ++--- src/remember_remember_bot/loop.py | 11 +++-------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/remember_remember_bot/commands.py b/src/remember_remember_bot/commands.py index 874004b..6f8b256 100644 --- a/src/remember_remember_bot/commands.py +++ b/src/remember_remember_bot/commands.py @@ -12,8 +12,7 @@ def setup(email: str, password: str, db: str, debug: bool) -> deltachat.Account: return ac -def remind_user(user: deltachat.Contact): - chat = user.get_chat() +def remind_chat(chat: deltachat.Chat): messages = [msg.text for msg in chat.get_messages()] if chat_is_active(messages): file_path = get_file_path(messages) @@ -35,7 +34,7 @@ def activate_chat(msg: deltachat.Message): return reply(msg.chat, f"I will send you daily reminders from the file {file_path}.") msg.chat.set_ephemeral_timer(60 * 60 * 24) - remind_user(msg.get_sender_contact()) + remind_chat(msg.get_sender_contact()) def reply( diff --git a/src/remember_remember_bot/loop.py b/src/remember_remember_bot/loop.py index 040ef84..150c1f8 100644 --- a/src/remember_remember_bot/loop.py +++ b/src/remember_remember_bot/loop.py @@ -2,7 +2,7 @@ import time import deltachat -from remember_remember_bot.commands import remind_user, activate_chat, reply +from remember_remember_bot.commands import remind_chat, activate_chat, reply from remember_remember_bot.util import check_new_day, update_day @@ -10,11 +10,8 @@ def loop(ac: deltachat.Account): current_day = 0 while True: if check_new_day(current_day): - for user in ac.get_contacts(): - if ( - user.get_chat() - ): # does this return None if there is no existing chat? - remind_user(user) + for chat in ac.get_chats(): + remind_chat(chat) current_day = update_day() for msg in ac.get_fresh_messages(): handle_incoming_message(msg) @@ -29,5 +26,3 @@ def handle_incoming_message(msg: deltachat.Message): msg.chat.set_ephemeral_timer(0) reply(msg.chat, "I will stop sending you messages now.", quote=msg) msg.mark_seen() - -