diff --git a/gsuid_core/buildin_plugins/core_command/core_status/__init__.py b/gsuid_core/buildin_plugins/core_command/core_status/__init__.py index 09d9f7e..48a7464 100644 --- a/gsuid_core/buildin_plugins/core_command/core_status/__init__.py +++ b/gsuid_core/buildin_plugins/core_command/core_status/__init__.py @@ -6,11 +6,10 @@ import gsuid_core.global_val as gv from gsuid_core.models import Event from gsuid_core.aps import scheduler from gsuid_core.logger import logger +from gsuid_core.global_val import save_all_global_val from gsuid_core.status.draw_status import draw_status from gsuid_core.utils.database.models import CoreUser, CoreGroup -from .command_global_val import save_global_val - sv_core_status = SV('Core状态', pm=0) template = '''收:{} @@ -40,9 +39,10 @@ async def count_group_user(): @scheduler.scheduled_job('cron', hour='0', minute='0') async def scheduled_save_global_val(): global bot_val - await save_global_val() + await save_all_global_val(1) gv.bot_val = {} await count_group_user() + logger.success('[早柚核心] 状态已保存!') @sv_core_status.on_fullmatch( diff --git a/gsuid_core/global_val.py b/gsuid_core/global_val.py index a19da15..359ceb7 100644 --- a/gsuid_core/global_val.py +++ b/gsuid_core/global_val.py @@ -150,11 +150,11 @@ async def load_all_global_val(): bot_val[bot_id_path.stem][self_id_path.stem] = data -async def save_all_global_val(): +async def save_all_global_val(day: int = 0): global bot_val for bot_id in bot_val: for bot_self_id in bot_val[bot_id]: - await save_global_val(bot_id, bot_self_id) + await save_global_val(bot_id, bot_self_id, day) async def get_global_val( @@ -182,13 +182,13 @@ async def get_sp_val(bot_id: str, bot_self_id: str, sp: str) -> PlatformVal: return data -async def save_global_val(bot_id: str, bot_self_id: str): +async def save_global_val(bot_id: str, bot_self_id: str, day: int = 0): if not bot_self_id: return local_val = get_platform_val(bot_id, bot_self_id) - today = datetime.date.today() + today = datetime.date.today() - datetime.timedelta(days=day) date_format = today.strftime("%Y_%d_%b") path = global_val_path / bot_id / bot_self_id