From 784d349ef933f510683baf029a72f9e8530efaee Mon Sep 17 00:00:00 2001 From: Pedro Rey Anca Date: Mon, 10 Feb 2025 13:59:52 +0100 Subject: [PATCH] Fix file read-write --- bot/bot_listen.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/bot/bot_listen.py b/bot/bot_listen.py index d6f3327..d8da1d6 100644 --- a/bot/bot_listen.py +++ b/bot/bot_listen.py @@ -15,10 +15,14 @@ async def handler(event): except InvalidMenuMessageError as e: print(e) return - with open(config.menu_history_file_path, "rw", encoding='utf-8') as f: + + with open(config.menu_history_file_path, "r", encoding='utf-8') as f: menus = json.load(f) - menus[msg.date.strftime("%d-%m-%Y")] = {"courses": courses, - "message": msg.message} + + menus[msg.date.strftime("%d-%m-%Y")] = {"courses": courses, + "message": msg.message} + + with open(config.menu_history_file_path, "w", encoding='utf-8') as f: json.dump(menus, f, ensure_ascii=False, indent=4)