Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
xaoyaoo committed Apr 19, 2024
1 parent 10c051a commit 173c87e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pywxdump/api/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,15 @@ def save_session(session_file, wxid, arg, value):
except json.JSONDecodeError as e:
logging.error(f"Error decoding JSON file: {e}")
return False

if wxid not in session:
session[wxid] = {}
if not isinstance(session[wxid], dict):
session[wxid] = {}
session[wxid][arg] = value
try:
with open(session_file, 'w') as f:
json.dump(session, f, indent=4)
json.dump(session, f, indent=4, ensure_ascii=False)
except Exception as e:
logging.error(f"Error writing to file: {e}")
return False
Expand Down

0 comments on commit 173c87e

Please sign in to comment.