2
0
mirror of https://github.com/ctrlcvs/xiaoyao-cvs-plugin.git synced 2025-01-22 22:11:22 +08:00

更新体力开关按钮

This commit is contained in:
leiyilu 2022-06-23 23:06:30 +08:00
parent d361ff155d
commit 33bfc66a77
6 changed files with 59 additions and 10 deletions

View File

@ -8,6 +8,9 @@ import format from "date-format";
import puppeteer from "puppeteer"; import puppeteer from "puppeteer";
import common from "../../../lib/common.js"; import common from "../../../lib/common.js";
import lodash from "lodash"; import lodash from "lodash";
import {
Cfg
} from "../components/index.js";
// import MysApi from "../components/MysApi.js" // import MysApi from "../components/MysApi.js"
import { import {
@ -21,6 +24,9 @@ const _path = process.cwd();
export async function Note(e, { export async function Note(e, {
render render
}) { }) {
if(!Cfg.get("sys.Note")){
return false;
}
let cookie, uid; let cookie, uid;
if (NoteCookie[e.user_id]) { if (NoteCookie[e.user_id]) {
cookie = NoteCookie[e.user_id].cookie; cookie = NoteCookie[e.user_id].cookie;

View File

@ -17,11 +17,12 @@ import {
init init
} from "../apps/xiaoyao_image.js" } from "../apps/xiaoyao_image.js"
const require = createRequire( const require = createRequire(
import.meta.url); import.meta.url);
let cfgMap = {
"体力": "sys.Note",
};
let sysCfgReg = `^#图鉴设置\s*(${lodash.keys(cfgMap).join("|")})?\s*(.*)$`;
export const rule = { export const rule = {
updateRes: { updateRes: {
hashMark: true, hashMark: true,
@ -33,7 +34,11 @@ export const rule = {
reg: "^#图鉴插件(强制)?更新", reg: "^#图鉴插件(强制)?更新",
describe: "【#管理】图鉴更新", describe: "【#管理】图鉴更新",
}, },
sysCfg: {
hashMark: true,
reg: sysCfgReg,
describe: "【#管理】系统设置"
}
}; };
@ -41,6 +46,43 @@ const _path = process.cwd();
const resPath = `${_path}/plugins/xiaoyao-cvs-plugin/resources/`; const resPath = `${_path}/plugins/xiaoyao-cvs-plugin/resources/`;
const plusPath = `${resPath}/xiaoyao-plus/`; const plusPath = `${resPath}/xiaoyao-plus/`;
export async function sysCfg(e, {
render
}) {
if (!await checkAuth(e)) {
return true;
}
let cfgReg = new RegExp(sysCfgReg);
let regRet = cfgReg.exec(e.msg);
if (!regRet) {
return true;
}
console.log(regRet)
if (regRet[1]) {
// 设置模式
let val = regRet[2] || "";
let cfgKey = cfgMap[regRet[1]];
if (cfgKey === "sys.scale") {
val = Math.min(200, Math.max(50, val * 1 || 100));
} else {
val = !/关闭/.test(val);
}
if (cfgKey) {
console.log(val)
Cfg.set(cfgKey, val);
}
}
e.reply("设置成功!!");
return true;
// //渲染图像
// return await Common.render("admin/index", {
// ...cfg,
// }, { e, render, scale: 1.4 });
}
const checkAuth = async function(e) { const checkAuth = async function(e) {
return await e.checkAuth({ return await e.checkAuth({
auth: "master", auth: "master",

View File

@ -2,7 +2,7 @@ import fs from "fs";
import lodash from "lodash"; import lodash from "lodash";
const _path = process.cwd(); const _path = process.cwd();
const _cfgPath = `${_path}/plugins/miao-plugin/components/`; const _cfgPath = `${_path}/plugins/xiaoyao-cvs-plugin/components/`;
let cfg = {}; let cfg = {};
try { try {
@ -31,7 +31,7 @@ let Cfg = {
if (Cfg.get(rote, true)) { if (Cfg.get(rote, true)) {
return false; return false;
} }
if (/^#*喵喵/.test(e.msg || "")) { if (/^#*图鉴/.test(e.msg || "")) {
return false; return false;
} }
return true; return true;

View File

@ -1,5 +1,6 @@
{ {
"sys": { "sys": {
"help": true "help": true,
"Note": false
} }
} }

View File

@ -11,13 +11,13 @@ import {
} from "./apps/Note.js" } from "./apps/Note.js"
import { import {
rule as adminRule, rule as adminRule,
updateRes, updateRes,sysCfg,
updateMiaoPlugin updateMiaoPlugin
} from "./apps/admin.js"; } from "./apps/admin.js";
export { export {
updateRes, updateRes,
updateMiaoPlugin, updateMiaoPlugin,
versionInfo, versionInfo,sysCfg,
calendar, calendar,
AtlasAlias, AtlasAlias,
Note Note