Fix file read-write
This commit is contained in:
parent
c798cc2ffb
commit
fd22566ddf
|
@ -1,4 +1,6 @@
|
|||
from telethon import TelegramClient, events
|
||||
import json
|
||||
|
||||
import config
|
||||
from utils import parse_menu_message, InvalidMenuMessageError
|
||||
|
||||
|
@ -15,10 +17,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)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue