Working cross-server chat

This commit is contained in:
Teknique
2023-08-01 23:02:33 -07:00
parent 781051783c
commit 92439fede9
3 changed files with 221 additions and 98 deletions
+26
View File
@@ -0,0 +1,26 @@
"""Load and save configuration."""
import json
from pathlib import Path
KEYFILE = Path(".demokeys")
def read_keys() -> dict:
"""Load the stored keys from disk."""
try:
keydata = KEYFILE.read_text()
except FileNotFoundError:
return {
"self": None,
"peers": {},
}
return json.loads(keydata)
def write_keys(keydata: dict):
"""Save the keys to disk."""
KEYFILE.write_text(json.dumps(keydata, indent=2))