# -*- coding: utf-8 -*-
from libbot import json_read, sync
async def string(key: str, *args: str, userlocale="uk"):
locales = await json_read("strings.json")
strings = locales[userlocale]
string = strings
for dict_key in args:
string = string[dict_key]
return string[key]
def userSet(userid, key: str, value):
database = sync.json_read("data/database.json")
if str(userid) not in database:
database[str(userid)] = {}
database[str(userid)][key] = value
sync.json_write(database, "data/database.json")
def userReset(userid, key: str):
del database[str(userid)][key]
def userGet(userid, key: str):
try:
return sync.json_read("data/database.json")[str(userid)][key]
except (KeyError, FileNotFoundError):
return None