From 97dbf42a4d3abec78d39cb0290611c7ab8291cb3 Mon Sep 17 00:00:00 2001 From: snowy Date: Wed, 24 Jul 2024 02:57:35 +0800 Subject: [PATCH] =?UTF-8?q?:zap:=20=E6=B7=BB=E5=8A=A0=E8=BF=9B=E7=A8=8B?= =?UTF-8?q?=E5=8F=8A=E7=94=9F=E5=91=BD=E5=91=A8=E6=9C=9F=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=99=A8=EF=BC=8C=E6=B7=BB=E5=8A=A0=E8=BD=BB=E9=9B=AA=E6=A1=86?= =?UTF-8?q?=E6=9E=B6=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- liteyuki/plugins/plugin_loader/__init__.py | 10 +++++++++- src/liteyuki_main/core.py | 19 +++++++++++++------ 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/liteyuki/plugins/plugin_loader/__init__.py b/liteyuki/plugins/plugin_loader/__init__.py index 507631a0..54be78b0 100644 --- a/liteyuki/plugins/plugin_loader/__init__.py +++ b/liteyuki/plugins/plugin_loader/__init__.py @@ -1,4 +1,5 @@ import multiprocessing +import time import nonebot from nonebot import get_driver @@ -14,12 +15,19 @@ __plugin_metadata__ = PluginMetadata( homepage="" ) +from src.utils import TempConfig, common_db + liteyuki = get_bot() @liteyuki.on_after_start def _(): - print("轻雪启动完成,运行在进程", multiprocessing.current_process().name) + temp_data = common_db.where_one(TempConfig(), default=TempConfig()) + # 储存重启信息 + if temp_data.data.get("reload", False): + delta_time = time.time() - temp_data.data.get("reload_time", 0) + temp_data.data["delta_time"] = delta_time + common_db.save(temp_data) # 更新数据 @liteyuki.on_before_start diff --git a/src/liteyuki_main/core.py b/src/liteyuki_main/core.py index a0d2a279..0304d502 100644 --- a/src/liteyuki_main/core.py +++ b/src/liteyuki_main/core.py @@ -322,12 +322,19 @@ async def test_for_md_image(bot: T_Bot, api: str, data: dict): @driver.on_startup async def on_startup(): - temp_data = common_db.where_one(TempConfig(), default=TempConfig()) - # 储存重启信息 - if temp_data.data.get("reload", False): - delta_time = time.time() - temp_data.data.get("reload_time", 0) - temp_data.data["delta_time"] = delta_time - common_db.save(temp_data) # 更新数据 + # temp_data = common_db.where_one(TempConfig(), default=TempConfig()) + # # 储存重启信息 + # if temp_data.data.get("reload", False): + # delta_time = time.time() - temp_data.data.get("reload_time", 0) + # temp_data.data["delta_time"] = delta_time + # common_db.save(temp_data) # 更新数据 + """ + 该部分迁移至轻雪生命周期 + Returns: + + """ + + pass @driver.on_shutdown