2024-03-24 09:43:34 +08:00
|
|
|
import nonebot.plugin
|
|
|
|
|
2024-05-12 00:18:53 +08:00
|
|
|
from liteyuki.internal import init_log
|
|
|
|
from liteyuki.internal.base.config import get_config
|
|
|
|
from liteyuki.internal.base.data_manager import InstalledPlugin, plugin_db
|
|
|
|
from liteyuki.internal.base.resource import load_resources
|
|
|
|
from liteyuki.internal.message.tools import check_for_package
|
2024-03-24 09:43:34 +08:00
|
|
|
|
2024-04-06 08:48:21 +08:00
|
|
|
load_resources()
|
2024-04-06 04:23:01 +08:00
|
|
|
init_log()
|
2024-03-24 09:43:34 +08:00
|
|
|
|
|
|
|
nonebot.plugin.load_plugins("liteyuki/plugins")
|
2024-04-06 04:23:01 +08:00
|
|
|
# 从数据库读取已安装的插件
|
2024-04-20 12:46:49 +08:00
|
|
|
if not get_config("safe_mode", False):
|
|
|
|
# 安全模式下,不加载插件
|
2024-04-26 12:39:43 +08:00
|
|
|
|
2024-05-12 00:18:53 +08:00
|
|
|
installed_plugins: list[InstalledPlugin] = plugin_db.where_all(InstalledPlugin())
|
2024-04-20 12:46:49 +08:00
|
|
|
if installed_plugins:
|
|
|
|
for installed_plugin in installed_plugins:
|
|
|
|
if not check_for_package(installed_plugin.module_name):
|
|
|
|
nonebot.logger.error(f"{installed_plugin.module_name} not installed, but in loading database. please run `npm fixup` in chat to reinstall it.")
|
|
|
|
else:
|
|
|
|
nonebot.load_plugin(installed_plugin.module_name)
|
2024-04-26 12:39:43 +08:00
|
|
|
|
|
|
|
nonebot.plugin.load_plugins("plugins")
|
2024-04-20 12:46:49 +08:00
|
|
|
else:
|
|
|
|
nonebot.logger.info("Safe mode is on, no plugin loaded.")
|