mirror of
https://github.com/TriM-Organization/LiteyukiBot-TriM.git
synced 2024-11-25 00:25:04 +08:00
✨ 新增安全模式启动
This commit is contained in:
parent
7585a5473d
commit
18d9ac3249
@ -21,6 +21,7 @@ superusers: [ "1919810" ] # 超级用户列表
|
|||||||
```
|
```
|
||||||
|
|
||||||
## **其他配置**
|
## **其他配置**
|
||||||
|
|
||||||
以下为默认值,如需自定义请手动添加
|
以下为默认值,如需自定义请手动添加
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
@ -30,16 +31,9 @@ log_level: "INFO" # 日志等级
|
|||||||
log_icon: true # 是否显示日志等级图标(某些控制台字体不可用)
|
log_icon: true # 是否显示日志等级图标(某些控制台字体不可用)
|
||||||
auto_report: true # 是否自动上报问题给轻雪服务器
|
auto_report: true # 是否自动上报问题给轻雪服务器
|
||||||
auto_update: true # 是否自动更新轻雪,每天4点检查更新
|
auto_update: true # 是否自动更新轻雪,每天4点检查更新
|
||||||
fake_device_info: # 用于保护设备隐私
|
|
||||||
cpu:
|
|
||||||
brand: AMD
|
|
||||||
cores: 16 # 物理核心数
|
|
||||||
logical_cores: 32 # 逻辑核心数
|
|
||||||
frequency: 3600 # CPU主频:MHz
|
|
||||||
mem:
|
|
||||||
total: 32768000000 # 内存总数:字节
|
|
||||||
alconna_use_command_start: false # alconna是否使用默认指令前缀,默认false
|
alconna_use_command_start: false # alconna是否使用默认指令前缀,默认false
|
||||||
alconna_auto_completion: false # alconna是否自动补全指令,默认false,建议开启
|
alconna_auto_completion: false # alconna是否自动补全指令,默认false,建议开启
|
||||||
|
safe_mode: false # 安全模式,开启后将不会加载任何第三方插件
|
||||||
|
|
||||||
# 其他Nonebot插件的配置项
|
# 其他Nonebot插件的配置项
|
||||||
custom_config_1: "custom_value1"
|
custom_config_1: "custom_value1"
|
||||||
|
@ -28,8 +28,11 @@ tag:
|
|||||||
你需要使用Onebot标准的实现端来连接到轻雪并将消息上报给轻雪,下面已经列出一些推荐的实现端
|
你需要使用Onebot标准的实现端来连接到轻雪并将消息上报给轻雪,下面已经列出一些推荐的实现端
|
||||||
- `Playwright`安装失败
|
- `Playwright`安装失败
|
||||||
- 输入`playwright install`安装浏览器
|
- 输入`playwright install`安装浏览器
|
||||||
|
- 有的插件安装后报错无法启动
|
||||||
|
- 请先查阅插件文档,确认插件必要配置项完好后,仍然出现问题,请联系插件作者或在安全模式`safe_mode: true`下启动轻雪,在安全模式下你可以使用`npm uninstall`卸载问题插件
|
||||||
- 其他问题
|
- 其他问题
|
||||||
- 加入QQ群[775840726](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=SzmDYbfR6jY94o9KFNon7AwelRyI6M_u&authKey=ygeBdEmdFNyCWuNR4w0M1M8%2B5oDg7k%2FDfN0tzBkYcnbB%2FGHNnlVEnCIGbdftsnn7&noverify=0&group_code=775840726)
|
-
|
||||||
|
加入QQ群[775840726](http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=SzmDYbfR6jY94o9KFNon7AwelRyI6M_u&authKey=ygeBdEmdFNyCWuNR4w0M1M8%2B5oDg7k%2FDfN0tzBkYcnbB%2FGHNnlVEnCIGbdftsnn7&noverify=0&group_code=775840726)
|
||||||
|
|
||||||
## **推荐方案(QQ)**
|
## **推荐方案(QQ)**
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import nonebot.plugin
|
import nonebot.plugin
|
||||||
|
|
||||||
from liteyuki.utils import init_log
|
from liteyuki.utils import init_log
|
||||||
|
from liteyuki.utils.base.config import get_config
|
||||||
from liteyuki.utils.base.data_manager import InstalledPlugin, plugin_db
|
from liteyuki.utils.base.data_manager import InstalledPlugin, plugin_db
|
||||||
from liteyuki.utils.base.resource import load_resources
|
from liteyuki.utils.base.resource import load_resources
|
||||||
from liteyuki.utils.message.tools import check_for_package
|
from liteyuki.utils.message.tools import check_for_package
|
||||||
@ -9,13 +10,17 @@ load_resources()
|
|||||||
init_log()
|
init_log()
|
||||||
|
|
||||||
nonebot.plugin.load_plugins("liteyuki/plugins")
|
nonebot.plugin.load_plugins("liteyuki/plugins")
|
||||||
nonebot.plugin.load_plugins("plugins")
|
|
||||||
|
|
||||||
# 从数据库读取已安装的插件
|
# 从数据库读取已安装的插件
|
||||||
installed_plugins: list[InstalledPlugin] = plugin_db.all(InstalledPlugin())
|
if not get_config("safe_mode", False):
|
||||||
if installed_plugins:
|
# 安全模式下,不加载插件
|
||||||
for installed_plugin in installed_plugins:
|
nonebot.plugin.load_plugins("plugins")
|
||||||
if not check_for_package(installed_plugin.module_name):
|
installed_plugins: list[InstalledPlugin] = plugin_db.all(InstalledPlugin())
|
||||||
nonebot.logger.error(f"{installed_plugin.module_name} not installed, but in loading database. please run `npm fixup` in chat to reinstall it.")
|
if installed_plugins:
|
||||||
else:
|
for installed_plugin in installed_plugins:
|
||||||
nonebot.load_plugin(installed_plugin.module_name)
|
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)
|
||||||
|
else:
|
||||||
|
nonebot.logger.info("Safe mode is on, no plugin loaded.")
|
||||||
|
@ -36,12 +36,18 @@ def load_from_yaml(file: str) -> dict:
|
|||||||
return conf
|
return conf
|
||||||
|
|
||||||
|
|
||||||
def get_config(key: str, *, bot: T_Bot = None, default=None):
|
def get_config(key: str, default=None):
|
||||||
"""获取配置项,优先级:bot > config > db > yaml"""
|
"""获取配置项,优先级:bot > config > db > yaml"""
|
||||||
|
try:
|
||||||
|
bot = nonebot.get_bot()
|
||||||
|
except:
|
||||||
|
bot = None
|
||||||
|
|
||||||
if bot is None:
|
if bot is None:
|
||||||
bot_config = {}
|
bot_config = {}
|
||||||
else:
|
else:
|
||||||
bot_config = bot.config.dict()
|
bot_config = bot.config.dict()
|
||||||
|
|
||||||
if key in bot_config:
|
if key in bot_config:
|
||||||
return bot_config[key]
|
return bot_config[key]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user