mirror of
https://github.com/LiteyukiStudio/LiteyukiBot.git
synced 2024-11-22 20:17:39 +08:00
⚡ 添加进程及生命周期管理器,添加轻雪框架支持
This commit is contained in:
parent
041a219151
commit
97dbf42a4d
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user