Archived
1
0
Fork 0
This repository has been archived on 2024-04-26. You can view files and clone it, but cannot push or open issues or pull requests.
akari-bot/core/utils/storedata.py
2023-08-30 02:13:34 +08:00

22 lines
540 B
Python

from typing import Union
import ujson as json
from core.types import FetchTarget
from database import BotDBUtil
def get_stored_list(bot: Union[FetchTarget, str], name: str) -> list:
get = BotDBUtil.Data(bot).get(name=name)
if get is None:
return []
else:
return json.loads(get.value)
def update_stored_list(bot: Union[FetchTarget, str], name: str, value: list):
edit = BotDBUtil.Data(bot).update(name=name, value=json.dumps(value))
return edit
__all__ = ['get_stored_list', 'update_stored_list']