✨ 新增线程安全共享内存储存器
This commit is contained in:
@ -8,12 +8,9 @@ Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved
|
||||
@File : __init__.py.py
|
||||
@Software: PyCharm
|
||||
"""
|
||||
import asyncio
|
||||
import time
|
||||
|
||||
import nonebot
|
||||
|
||||
from liteyuki.comm import Channel, set_channel
|
||||
from liteyuki.core import IS_MAIN_PROCESS
|
||||
from liteyuki.plugin import PluginMetadata
|
||||
from .nb_utils import adapter_manager, driver_manager
|
||||
@ -23,20 +20,15 @@ __plugin_meta__ = PluginMetadata(
|
||||
)
|
||||
|
||||
|
||||
def nb_run(chan_active: "Channel", chan_passive: "Channel", *args, **kwargs):
|
||||
def nb_run(*args, **kwargs):
|
||||
"""
|
||||
初始化NoneBot并运行在子进程
|
||||
Args:
|
||||
|
||||
chan_active:
|
||||
chan_passive:
|
||||
**kwargs:
|
||||
|
||||
Returns:
|
||||
"""
|
||||
# 给子进程传递通道对象
|
||||
set_channel("nonebot-active", chan_active)
|
||||
set_channel("nonebot-passive", chan_passive)
|
||||
|
||||
kwargs.update(kwargs.get("nonebot", {})) # nonebot配置优先
|
||||
nonebot.init(**kwargs)
|
||||
|
@ -7,4 +7,5 @@ Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved
|
||||
@Email : snowykami@outlook.com
|
||||
@File : __init__.py
|
||||
@Software: PyCharm
|
||||
"""
|
||||
"""
|
||||
from .after_start import *
|
@ -11,13 +11,15 @@ Copyright (C) 2020-2024 LiteyukiStudio. All Rights Reserved
|
||||
import time
|
||||
|
||||
from liteyuki import get_bot
|
||||
from liteyuki.comm.storage import shared_memory
|
||||
|
||||
liteyuki = get_bot()
|
||||
|
||||
|
||||
@liteyuki.on_after_start
|
||||
@liteyuki.on_before_start
|
||||
def save_startup_timestamp():
|
||||
"""
|
||||
储存启动的时间戳
|
||||
"""
|
||||
startup_timestamp = time.time()
|
||||
shared_memory.set("startup_timestamp", startup_timestamp)
|
||||
|
Reference in New Issue
Block a user