No need to save the file path in the chat anymore.

main
missytake 2023-12-10 14:56:28 +01:00
parent d548ebf3b8
commit 7711c106b7
1 changed files with 2 additions and 7 deletions

View File

@ -38,7 +38,7 @@ def remind_chat(chat: deltachat.Chat):
def activate_chat(msg: deltachat.Message):
"""Activate a Chat after the user sent /start"""
file_path = get_file_path(msg.chat)
if not file_path:
if not os.path.exists(file_path):
reply(
msg.chat,
"You first need to send me a file path with the /file command.",
@ -55,17 +55,12 @@ def activate_chat(msg: deltachat.Message):
def store_file(msg: deltachat.Message):
"""Store a received file and reply without timer to the chat where it was stored"""
timer = msg.chat.get_ephemeral_timer()
if timer:
msg.chat.set_ephemeral_timer(0)
new_filename = "./files/" + str(msg.chat.id)
with open(msg.filename, "r") as read_file:
os.makedirs(os.path.dirname(new_filename), exist_ok=True)
with open(new_filename, "w+") as write_file:
write_file.write(read_file.read())
reply(msg.chat, f"Thanks, I stored the file at {new_filename}", quote=msg)
if timer:
msg.chat.set_ephemeral_timer(timer)
reply(msg.chat, f"Thanks, I will use this file for daily reminders now.", quote=msg)
def send_help(msg: deltachat.Message):