2
0
mirror of https://github.com/ctrlcvs/xiaoyao-cvs-plugin.git synced 2024-12-23 03:20:52 +08:00
xiaoyao-cvs-plugin/apps/xiaoyao_image.js

104 lines
2.3 KiB
JavaScript
Raw Normal View History

import {
segment
} from "oicq";
import fs from "fs";
import path from 'path';
const _path = process.cwd();
const __dirname = path.resolve();
export async function roleInfo(e) {
// let msg=e.msg.replace(/#|图鉴/g,"");
let msg = e.msg.replace(/#||信息|图鉴|命座|天赋|突破/g, "");
let id = YunzaiApps.mysInfo.roleIdToName(msg);
let name;
if (["10000005", "10000007", "20000000"].includes(id)) {
if (!["风主", "岩主", "雷主"].includes(msg)) {
e.reply("请选择:风主图鉴、岩主图鉴、雷主图鉴");
return true;
}
name = msg;
} else {
name = YunzaiApps.mysInfo.roleIdToName(id, true);
if (!name) return false;
}
2022-06-18 12:01:41 +08:00
// console.log(name)
2022-06-18 21:30:24 +08:00
send_Msg(e, "juese_tujian", name)
return true;
}
2022-06-18 21:30:24 +08:00
const send_Msg = function(e, type, name) {
let path = `${_path}/plugins/cvs-plugin/resources/res-plus/${type}/${name}.png`
if (!fs.existsSync(path)) {
return true;
}
e.reply(segment.image(`file:///${path}`));
}
let weapon = new Map();
let weaponFile = [];
await init();
export async function init(isUpdate = false) {
2022-06-18 21:30:24 +08:00
let weaponJson = JSON.parse(fs.readFileSync("./config/genshin/weapon.json", "utf8"));
for (let i in weaponJson) {
for (let val of weaponJson[i]) {
weapon.set(val, i);
}
}
2022-06-18 21:30:24 +08:00
weaponFile = fs.readdirSync("./resources/weaponInfo_xiaoyao");
for (let val of weaponFile) {
let name = val.replace(".png", "");
weapon.set(name, name);
}
}
export async function weaponInfo(e) {
2022-06-18 21:30:24 +08:00
let msg = e.msg || '';
if (e.atBot) {
msg = "#" + msg.replace("#", "");
}
if (!/(#*(.*)(信息|图鉴|突破)|#(.*))$/.test(msg)) return;
2022-06-18 21:30:24 +08:00
let name = weapon.get(msg.replace(/#||信息|图鉴|突破/g, ""));
2022-06-18 21:30:24 +08:00
if (name) {
send_Msg(e, "wuqi_tujian", name)
return true;
}
2022-06-18 21:30:24 +08:00
return false;
}
2022-06-18 12:01:41 +08:00
export async function monsterInfo(e) {
2022-06-18 21:30:24 +08:00
let msg = e.msg || '';
2022-06-18 12:01:41 +08:00
2022-06-18 21:30:24 +08:00
if (e.atBot) {
msg = "#" + msg.replace("#", "");
}
if (!/(#*食物(.*)|#(.*))$/.test(msg)) return;
let name = msg.replace(/#||信息|图鉴|突破|食物/g, "");
if (name) {
send_Msg(e, "shiwu_tujian", name)
return true;
}
return false;
2022-06-18 12:01:41 +08:00
}
2022-06-18 21:30:24 +08:00
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;
}