mirror of
https://github.com/Ryujinx/ryuko-ng.git
synced 2024-12-23 01:35:30 +00:00
condensed a few lines to a new function
This commit is contained in:
parent
d056752e98
commit
656dbb1a0e
|
@ -18,9 +18,9 @@ def set_userlog(contents):
|
|||
f.write(contents)
|
||||
|
||||
|
||||
def userlog(uid, issuer, reason, event_type, uname: str = ""):
|
||||
def fill_userlog(userid, uname):
|
||||
userlogs = get_userlog()
|
||||
uid = str(uid)
|
||||
uid = str(userid)
|
||||
if uid not in userlogs:
|
||||
userlogs[uid] = {"warns": [],
|
||||
"mutes": [],
|
||||
|
@ -31,6 +31,13 @@ def userlog(uid, issuer, reason, event_type, uname: str = ""):
|
|||
"name": "n/a"}
|
||||
if uname:
|
||||
userlogs[uid]["name"] = uname
|
||||
|
||||
return userlogs, uid
|
||||
|
||||
|
||||
def userlog(uid, issuer, reason, event_type, uname: str = ""):
|
||||
userlogs, uid = fill_userlog(uid, uname)
|
||||
|
||||
timestamp = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
|
||||
log_data = {"issuer_id": issuer.id,
|
||||
"issuer_name": f"{issuer}",
|
||||
|
@ -44,19 +51,7 @@ def userlog(uid, issuer, reason, event_type, uname: str = ""):
|
|||
|
||||
|
||||
def setwatch(uid, issuer, watch_state, uname: str = ""):
|
||||
userlogs = get_userlog()
|
||||
uid = str(uid)
|
||||
# Can we reduce code repetition here?
|
||||
if uid not in userlogs:
|
||||
userlogs[uid] = {"warns": [],
|
||||
"mutes": [],
|
||||
"kicks": [],
|
||||
"bans": [],
|
||||
"notes": [],
|
||||
"watch": False,
|
||||
"name": "n/a"}
|
||||
if uname:
|
||||
userlogs[uid]["name"] = uname
|
||||
userlogs, uid = fill_userlog(uid, uname)
|
||||
|
||||
userlogs[uid]["watch"] = watch_state
|
||||
set_userlog(json.dumps(userlogs))
|
||||
|
|
Loading…
Reference in a new issue