2024-08-08 18:06:03 +08:00
|
|
|
|
from typing import Optional, TYPE_CHECKING
|
2024-07-24 02:36:46 +08:00
|
|
|
|
|
|
|
|
|
import nonebot
|
|
|
|
|
|
2024-07-31 02:28:25 +08:00
|
|
|
|
from liteyuki.core.nb import adapter_manager, driver_manager
|
2024-07-24 02:36:46 +08:00
|
|
|
|
|
2024-08-08 18:06:03 +08:00
|
|
|
|
if TYPE_CHECKING:
|
|
|
|
|
from liteyuki.comm.channel import Channel
|
|
|
|
|
|
2024-07-24 02:36:46 +08:00
|
|
|
|
timeout_limit: int = 20
|
2024-07-31 02:28:25 +08:00
|
|
|
|
|
2024-08-08 18:06:03 +08:00
|
|
|
|
"""导出对象,用于主进程与nonebot通信"""
|
|
|
|
|
chan_in_spawn_nb: Optional["Channel"] = None
|
2024-07-31 02:28:25 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def nb_run(chan, *args, **kwargs):
|
|
|
|
|
"""
|
|
|
|
|
初始化NoneBot并运行在子进程
|
|
|
|
|
Args:
|
|
|
|
|
|
2024-08-08 18:06:03 +08:00
|
|
|
|
chan:
|
2024-07-31 02:28:25 +08:00
|
|
|
|
*args:
|
|
|
|
|
**kwargs:
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
|
|
|
|
|
"""
|
2024-08-08 18:06:03 +08:00
|
|
|
|
global chan_in_spawn_nb
|
|
|
|
|
chan_in_spawn_nb = chan
|
2024-07-31 02:28:25 +08:00
|
|
|
|
nonebot.init(**kwargs)
|
|
|
|
|
driver_manager.init(config=kwargs)
|
|
|
|
|
adapter_manager.init(kwargs)
|
|
|
|
|
adapter_manager.register()
|
|
|
|
|
nonebot.load_plugin("src.liteyuki_main")
|
|
|
|
|
nonebot.run()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def mb_run(chan, *args, **kwargs):
|
|
|
|
|
"""
|
|
|
|
|
初始化MeloBot并运行在子进程
|
|
|
|
|
Args:
|
|
|
|
|
chan
|
|
|
|
|
*args:
|
|
|
|
|
**kwargs:
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
# bot = MeloBot(__name__)
|
|
|
|
|
# bot.init(AbstractConnector(cd_time=0))
|
|
|
|
|
# bot.run()
|