No need to save the file path in the chat anymore.
This commit is contained in:
parent
d548ebf3b8
commit
7711c106b7
|
@ -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):
|
||||
|
|
Loading…
Reference in a new issue