Browse Source

Rename warnsv2.json to userlog.py

main
Ave Ozkal 2 years ago
parent
commit
1e445ce07b
3 changed files with 7 additions and 5 deletions
  1. +2
    -0
      README.md
  2. +1
    -1
      Robocop.py
  3. +4
    -4
      helpers/userlogs.py

+ 2
- 0
README.md 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


+ 1
- 1
Robocop.py 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):


+ 4
- 4
helpers/userlogs.py 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])

Loading…
Cancel
Save