2
0
mirror of https://github.com/ctrlcvs/xiaoyao-cvs-plugin.git synced 2024-12-23 11:40:51 +08:00

更新图鉴初版

This commit is contained in:
leiyilu 2022-06-18 21:30:24 +08:00
parent 0284949fbc
commit 6f32c8c081
4 changed files with 65 additions and 67 deletions

View File

@ -27,7 +27,7 @@ export const rule = {
const _path = process.cwd(); const _path = process.cwd();
const resPath = `${_path}/plugins/cvs-plugin/resources/`; const resPath = `${_path}/plugins/cvs-plugin/resources/`;
const plusPath = `${resPath}/res-plus/`; const plusPath = `${resPath}/xiaoyao-plus/`;
const checkAuth = async function (e) { const checkAuth = async function (e) {
return await e.checkAuth({ return await e.checkAuth({
@ -53,7 +53,7 @@ export async function updateRes(e) {
if (fs.existsSync(`${resPath}/res-plus/`)) { if (fs.existsSync(`${resPath}/res-plus/`)) {
e.reply("开始尝试更新,请耐心等待~"); e.reply("开始尝试更新,请耐心等待~");
command = `git pull`; command = `git pull`;
exec(command, { cwd: `${resPath}/res-plus/` }, function (error, stdout, stderr) { exec(command, { cwd: `${resPath}/xiaoyao-plus/` }, function (error, stdout, stderr) {
//console.log(stdout); //console.log(stdout);
if (/Already up to date/.test(stdout)) { if (/Already up to date/.test(stdout)) {
e.reply("目前所有图片都已经是最新了~"); e.reply("目前所有图片都已经是最新了~");
@ -71,7 +71,7 @@ export async function updateRes(e) {
} }
}); });
} else { } else {
command = `git clone https://gitee.com/leiyilu/image.git "${resPath}/res-plus/"`; command = `git clone https://gitee.com/xiao-_-yao/image.git "${resPath}/xiaoyao-plus/"`;
e.reply("开始尝试安装图片加量包,可能会需要一段时间,请耐心等待~"); e.reply("开始尝试安装图片加量包,可能会需要一段时间,请耐心等待~");
exec(command, function (error, stdout, stderr) { exec(command, function (error, stdout, stderr) {
if (error) { if (error) {

View File

@ -25,11 +25,11 @@ export async function roleInfo(e) {
} }
// console.log(name) // console.log(name)
send_Msg(e,"jiaose_tujian",name) send_Msg(e, "juese_tujian", name)
return true; return true;
} }
const send_Msg=function(e,type,name){ const send_Msg = function(e, type, name) {
let path = `${_path}/plugins/cvs-plugin/resources/res-plus/${type}/${name}.png` let path = `${_path}/plugins/cvs-plugin/resources/res-plus/${type}/${name}.png`
if (!fs.existsSync(path)) { if (!fs.existsSync(path)) {
return true; return true;
@ -40,75 +40,64 @@ let weapon = new Map();
let weaponFile = []; let weaponFile = [];
await init(); await init();
export async function init(isUpdate = false) { export async function init(isUpdate = false) {
let weaponJson = JSON.parse(fs.readFileSync("./config/genshin/weapon.json", "utf8")); let weaponJson = JSON.parse(fs.readFileSync("./config/genshin/weapon.json", "utf8"));
for (let i in weaponJson) { for (let i in weaponJson) {
for (let val of weaponJson[i]) { for (let val of weaponJson[i]) {
weapon.set(val, i); weapon.set(val, i);
} }
} }
weaponFile = fs.readdirSync("./resources/weaponInfo_xiaoyao"); weaponFile = fs.readdirSync("./resources/weaponInfo_xiaoyao");
for (let val of weaponFile) { for (let val of weaponFile) {
let name = val.replace(".png", ""); let name = val.replace(".png", "");
weapon.set(name, name); weapon.set(name, name);
} }
} }
export async function weaponInfo(e) { export async function weaponInfo(e) {
let msg = e.msg || ''; let msg = e.msg || '';
if (e.atBot) {
msg = "#" + msg.replace("#", "");
}
if (!/(#*(.*)(信息|图鉴|突破)|#(.*))$/.test(msg)) return;
if(e.atBot){ let name = weapon.get(msg.replace(/#||信息|图鉴|突破/g, ""));
msg = "#" + msg.replace("#", "");
}
if(!/(#*(.*)(信息|图鉴|突破)|#(.*))$/.test(msg)) return; if (name) {
send_Msg(e, "wuqi_tujian", name)
return true;
}
let name = weapon.get(msg.replace(/#||信息|图鉴|突破/g, "")); return false;
if (name) {
Bot.logger.mark(`[${e.group_name}] ${e.msg}:weaponInfo`);
let path = `${_path}/resources/weaponInfo_xiaoyao/${name}.png`
if (!fs.existsSync(path)) {
return true;
}
e.reply(segment.image(`file:///${path}`));
return true;
}
return false;
} }
export async function monsterInfo(e) { export async function monsterInfo(e) {
let msg = e.msg || ''; let msg = e.msg || '';
if(e.atBot){ if (e.atBot) {
msg = "#" + msg.replace("#", ""); msg = "#" + msg.replace("#", "");
} }
if (!/(#*食物(.*)|#(.*))$/.test(msg)) return;
if(!/(#*食物(.*)|#(.*))$/.test(msg)) return; let name = msg.replace(/#||信息|图鉴|突破|食物/g, "");
if (name) {
let name = weapon.get(msg.replace(/#||信息|图鉴|突破|食物/g, "")); send_Msg(e, "shiwu_tujian", name)
return true;
if (name) { }
return false;
Bot.logger.mark(`[${e.group_name}] ${e.msg}:weaponInfo`);
let path = `${_path}/resources/weaponInfo_xiaoyao/${name}.png`
if (!fs.existsSync(path)) {
return true;
}
e.reply(segment.image(`file:///${path}`));
return true;
}
return false;
} }
export async function RelicsInfo(e) {
let msg = e.msg || '';
if (e.atBot) {
msg = "#" + msg.replace("#", "");
}
if (!/(#*圣遗物(.*)|#(.*))$/.test(msg)) return;
let name = msg.replace(/#||信息|副本|本/g, "");
if (name) {
send_Msg(e, "shengyiwu_tujian", name)
return true;
}
return false;
}

View File

@ -1,6 +1,6 @@
import lodash from "lodash"; import lodash from "lodash";
import { import {
roleInfo,weaponInfo roleInfo,weaponInfo,monsterInfo,RelicsInfo
} from "./apps/xiaoyao_image.js" } from "./apps/xiaoyao_image.js"
import { import {
rule as adminRule, rule as adminRule,
@ -9,7 +9,7 @@ import {
} from "./apps/admin.js"; } from "./apps/admin.js";
export { export {
updateRes, updateRes,
roleInfo,weaponInfo roleInfo,weaponInfo,monsterInfo
}; };
@ -24,14 +24,22 @@ let rule = {
}, },
roleInfo: { roleInfo: {
reg: "#*(.*)(信息|图鉴|命座|天赋|突破|材料|素材)$", //匹配消息正则,命令正则 reg: "#*(.*)(信息|图鉴|命座|天赋|突破|材料|素材)$", //匹配消息正则,命令正则
priority: 900, //优先级,越小优先度越高 priority: 200, //优先级,越小优先度越高
describe: "【刻晴信息、刻晴图鉴、刻晴突破、刻晴命座】角色信息图鉴", //【命令】功能说明 describe: "【刻晴信息、刻晴图鉴、刻晴突破、刻晴命座】角色信息图鉴", //【命令】功能说明
}, },
weaponInfo: { weaponInfo: {
reg: "", //匹配消息正则,命令正则 reg: "", //匹配消息正则,命令正则
priority: 900, //优先级,越小优先度越高 priority: 200, //优先级,越小优先度越高
describe: "【刻晴信息、刻晴图鉴、刻晴突破、刻晴命座】角色信息图鉴", //【命令】功能说明 describe: "【刻晴信息、刻晴图鉴、刻晴突破、刻晴命座】角色信息图鉴", //【命令】功能说明
}, },
monsterInfo:{
reg: "#*食物(.*)$", //匹配消息正则,命令正则
describe: "食物图鉴", //【命令】功能说明
},
RelicsInfo:{
reg: "#*圣遗物(.*)$", //匹配消息正则,命令正则
describe: "圣遗物图鉴", //【命令】功能说明
},
...adminRule ...adminRule
}; };

1
resources/res-plus Submodule

@ -0,0 +1 @@
Subproject commit 5431648830f17b0d67514b8c41a37eae73b2b497