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

23 lines
540 B
Python
Raw Normal View History

2023-08-29 18:13:34 +00:00
from typing import Union
2022-06-12 14:30:02 +00:00
import ujson as json
2023-02-05 14:33:33 +00:00
from core.types import FetchTarget
2022-06-12 14:30:02 +00:00
from database import BotDBUtil
2023-08-29 18:13:34 +00:00
def get_stored_list(bot: Union[FetchTarget, str], name: str) -> list:
2022-06-12 14:30:02 +00:00
get = BotDBUtil.Data(bot).get(name=name)
if get is None:
return []
else:
return json.loads(get.value)
2023-08-29 18:13:34 +00:00
def update_stored_list(bot: Union[FetchTarget, str], name: str, value: list):
2022-06-12 14:30:02 +00:00
edit = BotDBUtil.Data(bot).update(name=name, value=json.dumps(value))
return edit
__all__ = ['get_stored_list', 'update_stored_list']