actually we want to remind chats, not users
This commit is contained in:
parent
e5aa04fada
commit
190e6cf863
|
@ -12,8 +12,7 @@ def setup(email: str, password: str, db: str, debug: bool) -> deltachat.Account:
|
||||||
return ac
|
return ac
|
||||||
|
|
||||||
|
|
||||||
def remind_user(user: deltachat.Contact):
|
def remind_chat(chat: deltachat.Chat):
|
||||||
chat = user.get_chat()
|
|
||||||
messages = [msg.text for msg in chat.get_messages()]
|
messages = [msg.text for msg in chat.get_messages()]
|
||||||
if chat_is_active(messages):
|
if chat_is_active(messages):
|
||||||
file_path = get_file_path(messages)
|
file_path = get_file_path(messages)
|
||||||
|
@ -35,7 +34,7 @@ def activate_chat(msg: deltachat.Message):
|
||||||
return
|
return
|
||||||
reply(msg.chat, f"I will send you daily reminders from the file {file_path}.")
|
reply(msg.chat, f"I will send you daily reminders from the file {file_path}.")
|
||||||
msg.chat.set_ephemeral_timer(60 * 60 * 24)
|
msg.chat.set_ephemeral_timer(60 * 60 * 24)
|
||||||
remind_user(msg.get_sender_contact())
|
remind_chat(msg.get_sender_contact())
|
||||||
|
|
||||||
|
|
||||||
def reply(
|
def reply(
|
||||||
|
|
|
@ -2,7 +2,7 @@ import time
|
||||||
|
|
||||||
import deltachat
|
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
|
from remember_remember_bot.util import check_new_day, update_day
|
||||||
|
|
||||||
|
|
||||||
|
@ -10,11 +10,8 @@ def loop(ac: deltachat.Account):
|
||||||
current_day = 0
|
current_day = 0
|
||||||
while True:
|
while True:
|
||||||
if check_new_day(current_day):
|
if check_new_day(current_day):
|
||||||
for user in ac.get_contacts():
|
for chat in ac.get_chats():
|
||||||
if (
|
remind_chat(chat)
|
||||||
user.get_chat()
|
|
||||||
): # does this return None if there is no existing chat?
|
|
||||||
remind_user(user)
|
|
||||||
current_day = update_day()
|
current_day = update_day()
|
||||||
for msg in ac.get_fresh_messages():
|
for msg in ac.get_fresh_messages():
|
||||||
handle_incoming_message(msg)
|
handle_incoming_message(msg)
|
||||||
|
@ -29,5 +26,3 @@ def handle_incoming_message(msg: deltachat.Message):
|
||||||
msg.chat.set_ephemeral_timer(0)
|
msg.chat.set_ephemeral_timer(0)
|
||||||
reply(msg.chat, "I will stop sending you messages now.", quote=msg)
|
reply(msg.chat, "I will stop sending you messages now.", quote=msg)
|
||||||
msg.mark_seen()
|
msg.mark_seen()
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue