#喵喵设置 支持配置 #喵喵帮助

This commit is contained in:
yoimiya-kokomi 2022-04-11 05:11:39 +08:00
parent a43fc838d2
commit 16cd4dba59
4 changed files with 22 additions and 9 deletions

View File

@ -16,6 +16,7 @@ let cfgMap = {
"图片": "wiki.pic",
"深渊": "wiki.abyss",
"渲染": "sys.scale",
"帮助": "sys.help",
};
let sysCfgReg = `^#喵喵设置\s*(${lodash.keys(cfgMap).join("|")})?\s*(.*)$`;
export const rule = {
@ -81,6 +82,7 @@ export async function sysCfg(e, { render }) {
pic: getStatus("wiki.pic"),
abyss: getStatus("wiki.hutao"),
imgPlus: fs.existsSync(plusPath),
help: getStatus("sys.help", false),
scale: Cfg.get("sys.scale", 100)
}
@ -94,8 +96,8 @@ export async function sysCfg(e, { render }) {
return true;
}
const getStatus = function (rote) {
if (Cfg.get(rote, true)) {
const getStatus = function (rote, def = true) {
if (Cfg.get(rote, def)) {
return `<div class="cfg-status" >已开启</div>`;
} else {
return `<div class="cfg-status status-off">已关闭</div>`;

View File

@ -7,9 +7,12 @@ const _path = process.cwd();
const helpFilePath = `${_path}/plugins/miao-plugin/resources/help/help-list.js`;
export async function help(e, { render }) {
let bg = Character.getRandomImg('party');
let helpFile = {};
if (!/喵喵/.test(e.msg) && !Cfg.get("sys.help", false)) {
return false;
}
let helpFile = {};
helpFile = await import(`file://${helpFilePath}?version=${new Date().getTime()}`);
const { helpCfg } = helpFile;
@ -29,7 +32,6 @@ export async function help(e, { render }) {
let base64 = await render("help", "index", {
helpCfg,
bg,
cfgScale: Cfg.scale(1)
}, "png");
if (base64) {

View File

@ -28,7 +28,7 @@ let rule = {
reg: "^#(喵喵)?.*(天赋|技能|命座|命之座|资料|照片|写真|图片|插画)$",
},
help: {
reg: "#(喵喵)帮助"
reg: "#(喵喵)?帮助"
},
...adminRule
};

View File

@ -100,11 +100,20 @@
<li class="cfg-li">
<div class="cfg-line">
更新版本
<div class="cfg-status">#喵喵更新</div>
喵喵作为默认帮助
<span class="cfg-hint">#喵喵设置帮助 + 开启/关闭 </span>
{{@help}}
</div>
<div class="cfg-desc">更新喵喵Plugin可能需要重启Yunzai-Bot</div>
<div class="cfg-desc">开启后将使用喵喵版帮助作为Yunzai的默认帮助</div>
</li>
<!-- <li class="cfg-li">
<div class="cfg-line">
更新版本
<div class="cfg-status">#喵喵更新</div>
</div>
<div class="cfg-desc">更新喵喵Plugin可能需要重启Yunzai-Bot</div>
</li>-->
</ul>
</div>