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-08-10 22:25:41 +08:00
|
|
|
|
from liteyuki.comm.channel import set_channel
|
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通信"""
|
2024-08-10 22:25:41 +08:00
|
|
|
|
_channels = {}
|
2024-07-31 02:28:25 +08:00
|
|
|
|
|
|
|
|
|
|
2024-08-10 22:25:41 +08:00
|
|
|
|
def nb_run(chan_active: "Channel", chan_passive: "Channel", *args, **kwargs):
|
2024-07-31 02:28:25 +08:00
|
|
|
|
"""
|
|
|
|
|
初始化NoneBot并运行在子进程
|
|
|
|
|
Args:
|
|
|
|
|
|
2024-08-10 22:25:41 +08:00
|
|
|
|
chan_active:
|
|
|
|
|
chan_passive:
|
2024-07-31 02:28:25 +08:00
|
|
|
|
**kwargs:
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
|
|
|
|
|
"""
|
2024-08-10 22:25:41 +08:00
|
|
|
|
set_channel("nonebot-active", chan_active)
|
|
|
|
|
set_channel("nonebot-passive", chan_passive)
|
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()
|
|
|
|
|
|
|
|
|
|
|
2024-08-10 22:25:41 +08:00
|
|
|
|
def mb_run(chan_active: "Channel", chan_passive: "Channel", *args, **kwargs):
|
2024-07-31 02:28:25 +08:00
|
|
|
|
"""
|
|
|
|
|
初始化MeloBot并运行在子进程
|
|
|
|
|
Args:
|
2024-08-10 22:25:41 +08:00
|
|
|
|
chan_active
|
|
|
|
|
chan_passive
|
2024-07-31 02:28:25 +08:00
|
|
|
|
*args:
|
|
|
|
|
**kwargs:
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
|
|
|
|
|
"""
|
2024-08-10 22:25:41 +08:00
|
|
|
|
set_channel("melobot-active", chan_active)
|
|
|
|
|
set_channel("melobot-passive", chan_passive)
|
|
|
|
|
|
2024-07-31 02:28:25 +08:00
|
|
|
|
# bot = MeloBot(__name__)
|
|
|
|
|
# bot.init(AbstractConnector(cd_time=0))
|
|
|
|
|
# bot.run()
|