36 lines
934 B
Python
36 lines
934 B
Python
# -*- 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):
|
|
database = sync.json_read("data/database.json")
|
|
del database[str(userid)][key]
|
|
sync.json_write(database, "data/database.json")
|
|
|
|
|
|
def userGet(userid, key: str):
|
|
try:
|
|
return sync.json_read("data/database.json")[str(userid)][key]
|
|
except KeyError:
|
|
return None
|
|
except FileNotFoundError:
|
|
return None
|