This repository has been archived on 2024-08-21. You can view files and clone it, but cannot push or open issues or pull requests.
BWTAqua/modules/utils.py

34 lines
905 B
Python
Raw Normal View History

2023-05-16 21:50:18 +03:00
# -*- 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]
2023-07-14 13:36:42 +03:00
except (KeyError, FileNotFoundError):
2023-05-16 21:50:18 +03:00
return None