2022-04-10 20:48:53 +00:00
|
|
|
import { Character } from "../components/models.js";
|
|
|
|
import { Cfg } from "../components/index.js";
|
|
|
|
import { segment } from "oicq";
|
|
|
|
import lodash from "lodash";
|
|
|
|
|
|
|
|
const _path = process.cwd();
|
|
|
|
const helpFilePath = `${_path}/plugins/miao-plugin/resources/help/help-list.js`;
|
|
|
|
|
|
|
|
export async function help(e, { render }) {
|
|
|
|
|
2022-04-10 21:11:39 +00:00
|
|
|
if (!/喵喵/.test(e.msg) && !Cfg.get("sys.help", false)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
let helpFile = {};
|
2022-04-10 20:48:53 +00:00
|
|
|
helpFile = await import(`file://${helpFilePath}?version=${new Date().getTime()}`);
|
|
|
|
|
|
|
|
const { helpCfg } = helpFile;
|
2022-04-12 19:28:01 +00:00
|
|
|
let helpGroup = [];
|
2022-04-10 20:48:53 +00:00
|
|
|
|
|
|
|
lodash.forEach(helpCfg, (group) => {
|
2022-04-12 19:28:01 +00:00
|
|
|
if (group.auth && group.auth === "master" && !e.isMaster) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-04-10 20:48:53 +00:00
|
|
|
lodash.forEach(group.list, (help) => {
|
|
|
|
let icon = help.icon * 1;
|
|
|
|
if (!icon) {
|
|
|
|
help.css = `display:none`;
|
|
|
|
} else {
|
|
|
|
let x = (icon - 1) % 10, y = (icon - x - 1) / 10;
|
|
|
|
help.css = `background-position:-${x * 50}px -${y * 50}px`;
|
|
|
|
}
|
|
|
|
|
2022-04-12 19:28:01 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
helpGroup.push(group);
|
2022-04-10 20:48:53 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
let base64 = await render("help", "index", {
|
2022-04-12 19:28:01 +00:00
|
|
|
helpCfg: helpGroup,
|
|
|
|
cfgScale: Cfg.scale(1.05)
|
2022-04-10 20:48:53 +00:00
|
|
|
}, "png");
|
|
|
|
if (base64) {
|
|
|
|
e.reply(segment.image(`base64://${base64}`));
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|