Rename warnsv2.json to userlog.py

This commit is contained in:
Ave Ozkal 2018-12-27 14:19:33 +03:00
parent 03cdf7cf3b
commit 91dd17e967
No known key found for this signature in database
GPG key ID: 09356ABAA42C842B
3 changed files with 7 additions and 5 deletions

View file

@ -16,6 +16,8 @@ Code is based on https://gitlab.com/ao/dpybotbase and https://github.com/916253/
To keep the bot running, you might want to use pm2 or a systemd service.
If you're moving from Kurisu/Robocop, you'll want to copy your `data` folder over. Make sure to rename your `warnsv2.json` file to `userlog.json`.
---
## TODO

View file

@ -171,7 +171,7 @@ if not os.path.exists("data"):
os.makedirs("data")
wanted_jsons = ["data/restrictions.json",
"data/warnsv2.json"]
"data/userlog.json"]
for wanted_json in wanted_jsons:
if not os.path.exists(wanted_json):

View file

@ -9,17 +9,17 @@ userlog_event_types = {"warns": "Warn",
def get_userlog():
with open("data/warnsv2.json", "r") as f:
with open("data/userlog.json", "r") as f:
return json.load(f)
def set_userlog(contents):
with open("data/warnsv2.json", "w") as f:
with open("data/userlog.json", "w") as f:
f.write(contents)
def userlog(uid, issuer, reason, event_type, uname: str = ""):
with open("data/warnsv2.json", "r") as f:
with open("data/userlog.json", "r") as f:
userlogs = json.load(f)
uid = str(uid)
if uid not in userlogs:
@ -40,6 +40,6 @@ def userlog(uid, issuer, reason, event_type, uname: str = ""):
if event_type not in userlogs[uid]:
userlogs[uid][event_type] = []
userlogs[uid][event_type].append(log_data)
with open("data/warnsv2.json", "w") as f:
with open("data/userlog.json", "w") as f:
json.dump(userlogs, f)
return len(userlogs[uid][event_type])