actually we want to remind chats, not users

This commit is contained in:
missytake 2023-09-03 13:27:06 +02:00
parent e5aa04fada
commit 190e6cf863
2 changed files with 5 additions and 11 deletions

View file

@ -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(

View file

@ -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()