2022-03-26 08:21:44 +00:00
|
|
|
|
import { segment } from "oicq";
|
|
|
|
|
import lodash from "lodash";
|
2022-03-26 21:34:33 +00:00
|
|
|
|
import { Character } from "../components/models.js"
|
2022-04-09 21:33:21 +00:00
|
|
|
|
import { Cfg } from "../components/index.js";
|
2022-04-14 20:53:22 +00:00
|
|
|
|
import Profile from "../components/Profile.js";
|
|
|
|
|
import Format from "../components/Format.js"
|
2022-04-17 11:03:44 +00:00
|
|
|
|
import Reliquaries from "../components/models/Reliquaries.js";
|
2022-06-09 20:53:38 +00:00
|
|
|
|
import Reliquaries2 from "../components/models/Reliquaries2.js";
|
2022-04-23 21:16:37 +00:00
|
|
|
|
import Calc from "../components/Calc.js";
|
2022-05-22 13:10:10 +00:00
|
|
|
|
import Common from "../components/Common.js";
|
2022-04-23 21:16:37 +00:00
|
|
|
|
|
2022-03-26 08:21:44 +00:00
|
|
|
|
|
|
|
|
|
//角色昵称
|
|
|
|
|
let nameID = "";
|
|
|
|
|
let genshin = {};
|
|
|
|
|
await init();
|
|
|
|
|
|
2022-06-09 20:53:38 +00:00
|
|
|
|
const isNewScore = true;
|
|
|
|
|
|
2022-04-03 11:14:38 +00:00
|
|
|
|
const relationMap = {
|
|
|
|
|
wife: {
|
|
|
|
|
keyword: "老婆,媳妇,妻子,娘子".split(","),
|
|
|
|
|
type: 0
|
|
|
|
|
},
|
|
|
|
|
husband: {
|
|
|
|
|
keyword: "老公,丈夫,夫君,郎君".split(","),
|
|
|
|
|
type: 1
|
|
|
|
|
},
|
|
|
|
|
gf: {
|
|
|
|
|
keyword: "女朋友,女友,女神".split(","),
|
|
|
|
|
type: 0
|
|
|
|
|
},
|
|
|
|
|
bf: {
|
|
|
|
|
keyword: "男朋友,男友,男神".split(","),
|
|
|
|
|
type: 1
|
|
|
|
|
},
|
|
|
|
|
daughter: {
|
|
|
|
|
keyword: "女儿".split(","),
|
|
|
|
|
type: 2
|
|
|
|
|
},
|
|
|
|
|
son: {
|
|
|
|
|
keyword: "儿子".split(","),
|
|
|
|
|
type: 3
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const relation = lodash.flatMap(relationMap, (d) => d.keyword);
|
2022-04-23 21:40:00 +00:00
|
|
|
|
export const wifeReg = `^#?\\s*(${relation.join("|")})\\s*(设置|选择|指定|列表|查询|列表|是|是谁|照片|相片|图片|写真|图像)?\\s*([^\\d]*)\\s*(\\d*)$`;
|
2022-04-03 11:14:38 +00:00
|
|
|
|
|
2022-03-26 08:21:44 +00:00
|
|
|
|
export async function init(isUpdate = false) {
|
|
|
|
|
let _path = "file://" + process.cwd();
|
|
|
|
|
let version = isUpdate ? new Date().getTime() : 0;
|
|
|
|
|
genshin = await import(_path + `/config/genshin/roleId.js?version=${version}`);
|
|
|
|
|
nameID = "";
|
2022-04-14 20:53:22 +00:00
|
|
|
|
|
2022-03-26 08:21:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-03-26 21:34:33 +00:00
|
|
|
|
// 查看当前角色
|
2022-03-30 20:10:10 +00:00
|
|
|
|
export async function character(e, { render, User }) {
|
2022-04-14 20:53:22 +00:00
|
|
|
|
let msg = e.msg;
|
|
|
|
|
if (!msg) {
|
2022-03-27 11:24:06 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
2022-04-09 21:33:21 +00:00
|
|
|
|
|
2022-04-14 20:53:22 +00:00
|
|
|
|
let mode = 'card';
|
2022-06-04 21:29:24 +00:00
|
|
|
|
let uidRet = /[0-9]{9}/.exec(msg);
|
|
|
|
|
if (uidRet) {
|
|
|
|
|
e.uid = uidRet[0];
|
|
|
|
|
msg = msg.replace(uidRet[0], "");
|
|
|
|
|
}
|
|
|
|
|
let name = msg.replace(/#|老婆|老公/g, "").trim();
|
2022-05-31 21:16:10 +00:00
|
|
|
|
msg = msg.replace("面版", "面板")
|
2022-06-04 21:29:24 +00:00
|
|
|
|
let dmgRet = /伤害(\d?)$/.exec(msg), dmgIdx = 0;
|
2022-06-14 22:07:24 +00:00
|
|
|
|
if (/(详情|详细|面板|面版)\s*$/.test(msg) && !/更新|录入|输入/.test(msg)) {
|
2022-04-14 20:53:22 +00:00
|
|
|
|
mode = 'profile';
|
2022-05-31 21:16:10 +00:00
|
|
|
|
name = name.replace(/(详情|详细|面板)/, "").trim();
|
2022-04-30 21:06:17 +00:00
|
|
|
|
} else if (dmgRet) {
|
2022-04-29 22:35:21 +00:00
|
|
|
|
mode = 'dmg';
|
2022-04-30 21:06:17 +00:00
|
|
|
|
name = name.replace(/伤害[0-5]?/, "").trim();
|
|
|
|
|
if (dmgRet[1]) {
|
|
|
|
|
dmgIdx = dmgRet[1] * 1;
|
|
|
|
|
}
|
2022-05-31 21:16:10 +00:00
|
|
|
|
} else if (/(详情|详细|面板)更新$/.test(msg) || (/更新/.test(msg) && /(详情|详细|面板)$/.test(msg))) {
|
2022-04-28 19:38:43 +00:00
|
|
|
|
mode = "refresh";
|
2022-05-31 21:16:10 +00:00
|
|
|
|
name = name.replace(/详情|详细|面板|更新/g, "").trim();
|
|
|
|
|
} else if (/(录入|输入)/.test(msg) && /(详情|详细|面板)/.test(msg)) {
|
|
|
|
|
mode = "input";
|
|
|
|
|
let nameRet = /(?:录入|输入)(.+)(?:面板|详细|详情|数据)+/.exec(name);
|
|
|
|
|
if (nameRet) {
|
|
|
|
|
name = nameRet[1];
|
2022-06-04 21:29:24 +00:00
|
|
|
|
e.inputData = msg.replace(nameRet[0], "");
|
2022-05-31 21:16:10 +00:00
|
|
|
|
}
|
|
|
|
|
name = name.replace(/录入|输入|详情|详细|面板|数据|[0-9]|\.|\+/g, "").trim()
|
2022-04-14 20:53:22 +00:00
|
|
|
|
}
|
2022-04-29 21:54:41 +00:00
|
|
|
|
|
2022-05-28 21:18:13 +00:00
|
|
|
|
if (mode === "card" && Common.isDisable(e, "char.char")) {
|
2022-05-22 13:10:10 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-28 21:18:13 +00:00
|
|
|
|
if (mode !== "card" && !e.isMaster) {
|
|
|
|
|
if (Common.isDisable(e, "char.profile")) {
|
|
|
|
|
// 面板开关关闭
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (e.isPrivate) {
|
|
|
|
|
if ((e.sub_type === "friend" && Cfg.get("profile.friend.status") === false) ||
|
|
|
|
|
(e.sub_type === "group" && Cfg.get("profile.stranger.status") === false)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
} else if (e.isGroup) {
|
|
|
|
|
let groupCfg = Cfg.get(`profile.groups.群${e.group_id}.status`);
|
|
|
|
|
if (groupCfg === false || (groupCfg !== true && Cfg.get(`profile.group.status`) === false)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2022-06-14 22:07:24 +00:00
|
|
|
|
let char = Character.get(name.trim());
|
2022-04-28 19:38:43 +00:00
|
|
|
|
|
2022-03-26 21:34:33 +00:00
|
|
|
|
if (!char) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2022-04-07 20:51:47 +00:00
|
|
|
|
|
2022-04-28 19:38:43 +00:00
|
|
|
|
|
2022-04-29 22:35:21 +00:00
|
|
|
|
if (mode === "profile" || mode === "dmg") {
|
2022-04-30 21:06:17 +00:00
|
|
|
|
return renderProfile(e, char, render, mode, { dmgIdx });
|
2022-05-31 21:16:10 +00:00
|
|
|
|
} else if (mode === "refresh" || mode === "input") {
|
2022-04-28 19:38:43 +00:00
|
|
|
|
e.avatar = char.id;
|
2022-05-31 21:16:10 +00:00
|
|
|
|
await getProfile(e, mode);
|
2022-04-28 19:38:43 +00:00
|
|
|
|
return true;
|
2022-04-14 20:53:22 +00:00
|
|
|
|
} else {
|
|
|
|
|
return renderAvatar(e, char.name, render);
|
|
|
|
|
}
|
2022-04-03 11:14:38 +00:00
|
|
|
|
}
|
2022-03-26 08:21:44 +00:00
|
|
|
|
|
2022-04-13 19:30:16 +00:00
|
|
|
|
let _pokeCharacter = false;
|
|
|
|
|
|
|
|
|
|
async function initPoke() {
|
|
|
|
|
if (!_pokeCharacter) {
|
|
|
|
|
_pokeCharacter = YunzaiApps.mysInfo.pokeCharacter;
|
|
|
|
|
}
|
|
|
|
|
YunzaiApps.mysInfo.pokeCharacter = async function (e, components) {
|
|
|
|
|
if (Cfg.isDisable('char.poke', true)) {
|
|
|
|
|
return await _pokeCharacter(e, components);
|
|
|
|
|
}
|
|
|
|
|
return await pokeCharacter(e, components);
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-03-26 08:21:44 +00:00
|
|
|
|
|
2022-04-03 11:14:38 +00:00
|
|
|
|
//#老婆
|
|
|
|
|
export async function wife(e, { render, User }) {
|
|
|
|
|
let msg = e.msg || "";
|
|
|
|
|
if (!msg) return false;
|
2022-03-26 08:21:44 +00:00
|
|
|
|
|
2022-04-09 21:33:21 +00:00
|
|
|
|
if (Cfg.isDisable(e, "char.wife")) {
|
2022-04-21 03:07:54 +00:00
|
|
|
|
return false;
|
2022-04-09 21:33:21 +00:00
|
|
|
|
}
|
2022-03-26 08:21:44 +00:00
|
|
|
|
|
2022-04-09 21:33:21 +00:00
|
|
|
|
let msgRet = (new RegExp(wifeReg)).exec(msg);
|
2022-04-03 11:14:38 +00:00
|
|
|
|
if (!msgRet) return false;
|
2022-03-27 20:58:02 +00:00
|
|
|
|
|
2022-04-03 11:14:38 +00:00
|
|
|
|
let target = msgRet[1],
|
|
|
|
|
action = msgRet[2] || "卡片",
|
|
|
|
|
actionParam = msgRet[3] || "";
|
2022-03-26 08:21:44 +00:00
|
|
|
|
|
2022-04-23 21:40:00 +00:00
|
|
|
|
if (!"设置,选择,挑选,指定".split(",").includes(action) && actionParam) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-03 11:14:38 +00:00
|
|
|
|
let targetCfg = lodash.find(relationMap, (cfg, key) => {
|
|
|
|
|
cfg.key = key;
|
|
|
|
|
return cfg.keyword.includes(target);
|
|
|
|
|
});
|
|
|
|
|
if (!targetCfg) return true;
|
2022-03-26 08:21:44 +00:00
|
|
|
|
|
2022-04-03 11:14:38 +00:00
|
|
|
|
let avatarList = [], avatar = {}, wifeList = [];
|
2022-03-30 20:10:10 +00:00
|
|
|
|
|
2022-04-01 18:26:05 +00:00
|
|
|
|
let MysApi = await e.getMysApi({
|
2022-03-30 20:10:10 +00:00
|
|
|
|
auth: "all",
|
2022-04-09 21:33:21 +00:00
|
|
|
|
targetType: Cfg.get("char.queryOther", true) ? "all" : "self",
|
2022-03-30 20:10:10 +00:00
|
|
|
|
cookieType: "all",
|
|
|
|
|
actionName: "查询信息"
|
2022-03-27 13:12:00 +00:00
|
|
|
|
});
|
2022-04-25 19:59:13 +00:00
|
|
|
|
|
|
|
|
|
if (!MysApi || !MysApi.selfUser) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2022-04-03 11:14:38 +00:00
|
|
|
|
let selfUser = MysApi.selfUser;
|
|
|
|
|
|
2022-04-25 19:59:13 +00:00
|
|
|
|
let selfMysUser = await selfUser.getMysUser();
|
2022-04-09 21:33:21 +00:00
|
|
|
|
let isSelf = true;
|
|
|
|
|
if (!selfMysUser || selfMysUser.uid !== MysApi.targetUser.uid) {
|
|
|
|
|
isSelf = false;
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-03 11:14:38 +00:00
|
|
|
|
switch (action) {
|
|
|
|
|
case "卡片":
|
|
|
|
|
case "照片":
|
|
|
|
|
case "相片":
|
|
|
|
|
case "图片":
|
|
|
|
|
case "写真":
|
|
|
|
|
// 展示老婆卡片
|
|
|
|
|
|
|
|
|
|
// 如果选择过,则进行展示
|
|
|
|
|
wifeList = await selfUser.getCfg(`wife.${targetCfg.key}`, []);
|
|
|
|
|
let renderType = action === "卡片" ? "card" : "photo";
|
|
|
|
|
// 存在设置
|
2022-04-09 21:33:21 +00:00
|
|
|
|
if (wifeList && wifeList.length > 0 && isSelf) {
|
2022-04-03 11:14:38 +00:00
|
|
|
|
if (wifeList[0] === "随机") {
|
|
|
|
|
// 如果选择为全部,则从列表中随机选择一个
|
|
|
|
|
avatarList = await getAvatarList(e, targetCfg.type, MysApi);
|
|
|
|
|
let avatar = lodash.sample(avatarList);
|
2022-04-03 22:14:54 +00:00
|
|
|
|
return renderAvatar(e, avatar, render, renderType);
|
2022-04-03 11:14:38 +00:00
|
|
|
|
} else {
|
|
|
|
|
// 如果指定过,则展示指定角色
|
2022-04-03 22:14:54 +00:00
|
|
|
|
return renderAvatar(e, lodash.sample(wifeList), render, renderType);
|
2022-04-03 11:14:38 +00:00
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// 如果未指定过,则从列表中排序并随机选择前5个
|
|
|
|
|
avatarList = await getAvatarList(e, targetCfg.type, MysApi);
|
2022-04-05 19:49:37 +00:00
|
|
|
|
if (avatarList && avatarList.length > 0) {
|
|
|
|
|
avatar = lodash.sample(avatarList.slice(0, 5));
|
|
|
|
|
return renderAvatar(e, avatar, render, renderType);
|
|
|
|
|
} else {
|
|
|
|
|
e.reply(`在当前米游社公开展示的角色中未能找到适合展示的角色..`);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2022-04-03 11:14:38 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case "设置":
|
|
|
|
|
case "选择":
|
|
|
|
|
case "挑选":
|
|
|
|
|
case "指定":
|
2022-04-09 21:33:21 +00:00
|
|
|
|
if (!isSelf) {
|
2022-04-03 11:14:38 +00:00
|
|
|
|
e.reply("只能指定自己的哦~");
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
// 选择老婆
|
2022-04-05 14:24:02 +00:00
|
|
|
|
actionParam = actionParam.replace(/,/g, ",");
|
2022-04-03 11:14:38 +00:00
|
|
|
|
wifeList = actionParam.split(",");
|
|
|
|
|
let addRet = [];
|
|
|
|
|
if (lodash.intersection(["全部", "任意", "随机", "全都要"], wifeList).length > 0) {
|
|
|
|
|
addRet = ['随机'];
|
|
|
|
|
} else {
|
|
|
|
|
wifeList = lodash.map(wifeList, (name) => {
|
|
|
|
|
let char = Character.get(name);
|
|
|
|
|
if (char) {
|
|
|
|
|
return char.name;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
wifeList = lodash.filter(lodash.uniq(wifeList), (d) => !!d);
|
|
|
|
|
avatarList = await getAvatarList(e, targetCfg.type, MysApi);
|
|
|
|
|
avatarList = lodash.map(avatarList, (avatar) => avatar.name);
|
|
|
|
|
avatarList = lodash.filter(avatarList, (d) => !!d);
|
|
|
|
|
addRet = lodash.intersection(avatarList, wifeList);
|
|
|
|
|
if (addRet.length === 0) {
|
2022-04-05 19:49:37 +00:00
|
|
|
|
e.reply(`在可选的${targetCfg.keyword[0]}列表中未能找到 ${actionParam} ~`);
|
|
|
|
|
if (!MysApi.isSelfCookie) {
|
|
|
|
|
e.reply("请确认已在米游社展示对应角色,也可以绑定Cookie以查询所有角色..");
|
|
|
|
|
}
|
2022-04-03 11:14:38 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
await selfUser.setCfg(`wife.${targetCfg.key}`, addRet);
|
|
|
|
|
e.reply(`${targetCfg.keyword[0]}已经设置:${addRet.join(",")}`);
|
|
|
|
|
return true;
|
|
|
|
|
break;
|
|
|
|
|
case "列表":
|
|
|
|
|
case "是":
|
|
|
|
|
case "是谁":
|
|
|
|
|
// 查看当前选择老婆
|
2022-04-09 21:33:21 +00:00
|
|
|
|
|
|
|
|
|
if (!isSelf) {
|
|
|
|
|
e.reply("只能查看自己的哦~");
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-03 11:14:38 +00:00
|
|
|
|
wifeList = await selfUser.getCfg(`wife.${targetCfg.key}`, []);
|
|
|
|
|
if (wifeList && wifeList.length > 0) {
|
|
|
|
|
e.reply(`你的${targetCfg.keyword[0]}是:${wifeList.join(",")}`);
|
|
|
|
|
} else {
|
|
|
|
|
e.reply(`尚未设置,回复#${targetCfg.keyword[0]}设置+角色名 来设置,如果设置多位请用逗号间隔`)
|
|
|
|
|
}
|
|
|
|
|
break;
|
2022-03-27 13:12:00 +00:00
|
|
|
|
}
|
2022-04-03 22:14:54 +00:00
|
|
|
|
return true;
|
2022-04-03 11:14:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-06-11 14:10:53 +00:00
|
|
|
|
/* 接管戳一戳面板,尚未完成 */
|
2022-04-13 19:30:16 +00:00
|
|
|
|
async function pokeCharacter(e, { render }) {
|
|
|
|
|
let MysApi = await e.getMysApi({
|
|
|
|
|
auth: "all",
|
|
|
|
|
targetType: Cfg.get("char.queryOther", true) ? "all" : "self",
|
|
|
|
|
cookieType: "all",
|
|
|
|
|
actionName: "查询信息"
|
|
|
|
|
});
|
|
|
|
|
let avatarList = await getAvatarList(e, false, MysApi);
|
|
|
|
|
let avatar = lodash.sample(avatarList);
|
|
|
|
|
return renderAvatar(e, avatar, render, 'card');
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-03 11:14:38 +00:00
|
|
|
|
async function getAvatarList(e, type, MysApi) {
|
2022-03-31 20:34:04 +00:00
|
|
|
|
let data = await MysApi.getCharacter();
|
2022-04-03 11:14:38 +00:00
|
|
|
|
if (!data) return false;
|
2022-03-27 13:12:00 +00:00
|
|
|
|
|
2022-03-30 20:10:10 +00:00
|
|
|
|
let avatars = data.avatars;
|
2022-03-27 13:12:00 +00:00
|
|
|
|
|
|
|
|
|
if (avatars.length <= 0) {
|
2022-04-03 11:14:38 +00:00
|
|
|
|
return false;
|
2022-03-27 13:12:00 +00:00
|
|
|
|
}
|
|
|
|
|
let list = [];
|
|
|
|
|
for (let val of avatars) {
|
2022-04-13 19:30:16 +00:00
|
|
|
|
if (type !== false) {
|
|
|
|
|
if (!genshin.wifeData[type].includes(Number(val.id))) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2022-03-27 13:12:00 +00:00
|
|
|
|
}
|
|
|
|
|
if (val.rarity > 5) {
|
|
|
|
|
val.rarity = 5;
|
|
|
|
|
}
|
|
|
|
|
list.push(val);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (list.length <= 0) {
|
2022-04-03 11:14:38 +00:00
|
|
|
|
return false;
|
2022-03-27 13:12:00 +00:00
|
|
|
|
}
|
2022-03-30 20:10:10 +00:00
|
|
|
|
let sortKey = "level,fetter,weapon_level,rarity,weapon_rarity,cons,weapon_affix_level";
|
|
|
|
|
list = lodash.orderBy(list, sortKey, lodash.repeat("desc,", sortKey.length).split(","));
|
2022-04-03 11:14:38 +00:00
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-13 19:30:16 +00:00
|
|
|
|
|
2022-04-03 11:14:38 +00:00
|
|
|
|
async function renderAvatar(e, avatar, render, renderType = "card") {
|
|
|
|
|
|
|
|
|
|
// 如果传递的是名字,则获取
|
|
|
|
|
if (typeof (avatar) === "string") {
|
|
|
|
|
let char = Character.get(avatar);
|
|
|
|
|
if (!char) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2022-04-10 05:36:31 +00:00
|
|
|
|
|
2022-04-03 11:14:38 +00:00
|
|
|
|
let MysApi = await e.getMysApi({
|
|
|
|
|
auth: "all",
|
2022-04-09 21:33:21 +00:00
|
|
|
|
targetType: Cfg.get("char.queryOther", true) ? "all" : "self",
|
2022-04-03 11:14:38 +00:00
|
|
|
|
cookieType: "all",
|
|
|
|
|
actionName: "查询信息"
|
|
|
|
|
});
|
|
|
|
|
if (!MysApi) return true;
|
|
|
|
|
|
|
|
|
|
let charData = await MysApi.getCharacter();
|
|
|
|
|
if (!charData) return true;
|
|
|
|
|
|
|
|
|
|
let avatars = charData.avatars;
|
|
|
|
|
let length = avatars.length;
|
2022-04-10 05:36:31 +00:00
|
|
|
|
char.checkAvatars(avatars);
|
2022-04-03 11:14:38 +00:00
|
|
|
|
avatars = lodash.keyBy(avatars, "id");
|
|
|
|
|
|
2022-04-10 05:36:31 +00:00
|
|
|
|
if (!avatars[char.id]) {
|
2022-04-03 11:14:38 +00:00
|
|
|
|
let name = lodash.truncate(e.sender.card, { length: 8 });
|
|
|
|
|
if (length > 8) {
|
|
|
|
|
e.reply([segment.at(e.user_id, name), `\n没有${e.msg}`]);
|
|
|
|
|
} else {
|
|
|
|
|
e.reply([segment.at(e.user_id, name), "\n请先在米游社展示该角色"]);
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2022-04-10 05:36:31 +00:00
|
|
|
|
avatar = avatars[char.id];
|
2022-04-03 11:14:38 +00:00
|
|
|
|
}
|
|
|
|
|
return await renderCard(e, avatar, render, renderType);
|
|
|
|
|
|
2022-03-30 20:10:10 +00:00
|
|
|
|
}
|
2022-03-27 13:12:00 +00:00
|
|
|
|
|
2022-03-30 20:10:10 +00:00
|
|
|
|
// 渲染角色卡片
|
2022-04-03 11:14:38 +00:00
|
|
|
|
async function renderCard(e, avatar, render, renderType = "card") {
|
|
|
|
|
let talent = await getTalent(e, avatar);
|
2022-03-30 20:10:10 +00:00
|
|
|
|
// 计算皇冠个数
|
|
|
|
|
let crownNum = lodash.filter(lodash.map(talent, (d) => d.level_original), (d) => d >= 10).length;
|
2022-03-27 13:12:00 +00:00
|
|
|
|
|
2022-06-04 23:03:18 +00:00
|
|
|
|
let uid = e.uid || (e.targetUser && e.targetUser.uid);
|
2022-03-27 13:12:00 +00:00
|
|
|
|
|
2022-04-10 05:36:31 +00:00
|
|
|
|
let char = Character.get(avatar);
|
2022-03-27 13:12:00 +00:00
|
|
|
|
|
2022-04-10 05:36:31 +00:00
|
|
|
|
if (!char) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2022-06-16 20:19:27 +00:00
|
|
|
|
let bg = char.getCardImg(Cfg.get("char.se", false));
|
2022-04-03 11:14:38 +00:00
|
|
|
|
|
|
|
|
|
if (renderType === "photo") {
|
|
|
|
|
e.reply(segment.image(process.cwd() + "/plugins/miao-plugin/resources/" + bg.img));
|
|
|
|
|
} else {
|
|
|
|
|
//渲染图像
|
2022-06-11 08:22:29 +00:00
|
|
|
|
let msgRes = await Common.render("character/card", {
|
2022-04-03 11:14:38 +00:00
|
|
|
|
save_id: uid,
|
2022-06-06 20:59:47 +00:00
|
|
|
|
uid,
|
2022-04-03 11:14:38 +00:00
|
|
|
|
talent,
|
|
|
|
|
crownNum,
|
|
|
|
|
talentMap: { a: "普攻", e: "战技", q: "爆发" },
|
2022-04-10 05:36:31 +00:00
|
|
|
|
bg,
|
2022-04-03 11:14:38 +00:00
|
|
|
|
...getCharacterData(avatar),
|
|
|
|
|
ds: char.getData("name,id,title,desc"),
|
2022-05-22 13:10:10 +00:00
|
|
|
|
}, { e, render, scale: 1.6 });
|
2022-06-11 08:22:29 +00:00
|
|
|
|
if (msgRes && msgRes.message_id) {
|
|
|
|
|
// 如果消息发送成功,就将message_id和图片路径存起来,1小时过期
|
2022-06-11 21:54:41 +00:00
|
|
|
|
await redis.set(`miao:original-picture:${msgRes.message_id}`, bg.img, { EX: 3600 });
|
2022-06-11 08:22:29 +00:00
|
|
|
|
}
|
|
|
|
|
return msgRes;
|
2022-03-27 13:12:00 +00:00
|
|
|
|
}
|
2022-04-03 11:14:38 +00:00
|
|
|
|
return true;
|
2022-03-26 21:34:33 +00:00
|
|
|
|
}
|
2022-03-26 08:21:44 +00:00
|
|
|
|
|
|
|
|
|
//获取角色技能数据
|
2022-04-03 11:14:38 +00:00
|
|
|
|
async function getTalent(e, avatars) {
|
|
|
|
|
|
|
|
|
|
let MysApi = await e.getMysApi({
|
|
|
|
|
auth: "all",
|
2022-04-09 21:33:21 +00:00
|
|
|
|
targetType: Cfg.get("char.queryOther", true) ? "all" : "self",
|
2022-04-03 11:14:38 +00:00
|
|
|
|
cookieType: "all",
|
|
|
|
|
actionName: "查询信息"
|
|
|
|
|
});
|
2022-04-05 19:49:37 +00:00
|
|
|
|
if (!MysApi && !MysApi.isSelfCookie) return {};
|
2022-03-26 08:21:44 +00:00
|
|
|
|
|
|
|
|
|
let skill = {};
|
2022-03-27 13:12:00 +00:00
|
|
|
|
|
2022-04-01 23:13:09 +00:00
|
|
|
|
let skillRes = await MysApi.getAvatar(avatars.id);
|
2022-03-30 20:10:10 +00:00
|
|
|
|
|
2022-04-03 11:14:38 +00:00
|
|
|
|
if (skillRes && skillRes.skill_list) {
|
2022-03-27 13:12:00 +00:00
|
|
|
|
skill.id = avatars.id;
|
2022-04-01 23:13:09 +00:00
|
|
|
|
let skill_list = lodash.orderBy(skillRes.skill_list, ["id"], ["asc"]);
|
2022-03-30 20:10:10 +00:00
|
|
|
|
|
2022-03-27 13:12:00 +00:00
|
|
|
|
for (let val of skill_list) {
|
|
|
|
|
val.level_original = val.level_current;
|
|
|
|
|
if (val.name.includes("普通攻击")) {
|
|
|
|
|
skill.a = val;
|
|
|
|
|
continue;
|
2022-03-26 08:21:44 +00:00
|
|
|
|
}
|
2022-03-27 13:12:00 +00:00
|
|
|
|
if (val.max_level >= 10 && !skill.e) {
|
|
|
|
|
skill.e = val;
|
|
|
|
|
continue;
|
2022-03-26 08:21:44 +00:00
|
|
|
|
}
|
2022-03-27 13:12:00 +00:00
|
|
|
|
if (val.max_level >= 10 && !skill.q) {
|
|
|
|
|
skill.q = val;
|
2022-04-03 11:14:38 +00:00
|
|
|
|
|
2022-03-27 13:12:00 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (avatars.actived_constellation_num >= 3) {
|
|
|
|
|
if (avatars.constellations[2].effect.includes(skill.e.name)) {
|
|
|
|
|
skill.e.level_current += 3;
|
|
|
|
|
} else if (avatars.constellations[2].effect.includes(skill.q.name)) {
|
|
|
|
|
skill.q.level_current += 3;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (avatars.actived_constellation_num >= 5) {
|
|
|
|
|
if (avatars.constellations[4].effect.includes(skill.e.name)) {
|
|
|
|
|
skill.e.level_current += 3;
|
|
|
|
|
} else if (avatars.constellations[4].effect.includes(skill.q.name)) {
|
|
|
|
|
skill.q.level_current += 3;
|
2022-03-26 08:21:44 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return skill;
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-11 14:10:53 +00:00
|
|
|
|
/*
|
|
|
|
|
* 自动更新面板数据
|
|
|
|
|
* */
|
2022-06-04 21:29:24 +00:00
|
|
|
|
async function autoRefresh(e) {
|
2022-06-04 23:03:18 +00:00
|
|
|
|
|
2022-06-06 20:59:47 +00:00
|
|
|
|
let uid = await getTargetUid(e);
|
|
|
|
|
if (!uid || e.isRefreshed) {
|
|
|
|
|
return false;
|
2022-06-04 23:03:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-06-04 21:29:24 +00:00
|
|
|
|
let refreshMark = await redis.get(`miao:profile-refresh-cd:${uid}`);
|
|
|
|
|
let inCd = await redis.get(`miao:role-all:${uid}`);
|
|
|
|
|
|
|
|
|
|
if (refreshMark || inCd) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await redis.set(`miao:profile-refresh-cd:${uid}`, "TRUE", { EX: 3600 * 12 });
|
2022-06-06 20:59:47 +00:00
|
|
|
|
e.isRefreshed = true;
|
2022-06-04 21:29:24 +00:00
|
|
|
|
|
|
|
|
|
// 数据更新
|
2022-06-04 23:03:18 +00:00
|
|
|
|
let data = await Profile.request(uid, e);
|
2022-06-04 21:29:24 +00:00
|
|
|
|
if (!data) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!data.chars) {
|
|
|
|
|
e.reply("请确认角色已在【游戏内】橱窗展示并开放了查看详情。设置完毕后请5分钟后使用 #面板更新 重新获取");
|
|
|
|
|
return false;
|
|
|
|
|
} else {
|
|
|
|
|
let ret = [];
|
|
|
|
|
lodash.forEach(data.chars, (ds) => {
|
|
|
|
|
let char = Character.get(ds.id);
|
|
|
|
|
if (char) {
|
|
|
|
|
ret.push(char.name);
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
if (ret.length === 0) {
|
|
|
|
|
e.reply("请确认角色已在【游戏内】橱窗展示并开放了查看详情。设置完毕后请5分钟后使用 #面板更新 重新获取")
|
|
|
|
|
return false;
|
|
|
|
|
} else {
|
2022-06-09 20:53:38 +00:00
|
|
|
|
// e.reply(`本次获取成功角色: ${ret.join(", ")} `)
|
2022-06-04 21:29:24 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2022-05-31 21:16:10 +00:00
|
|
|
|
export async function getProfile(e, mode = "refresh") {
|
2022-06-06 20:59:47 +00:00
|
|
|
|
let uid = await getTargetUid(e);
|
|
|
|
|
if (!uid) {
|
|
|
|
|
return true;
|
2022-04-14 20:53:22 +00:00
|
|
|
|
}
|
2022-06-04 23:03:18 +00:00
|
|
|
|
|
2022-05-31 21:16:10 +00:00
|
|
|
|
if (mode === "input") {
|
|
|
|
|
if (e.inputData.trim().length < 5) {
|
2022-06-04 21:29:24 +00:00
|
|
|
|
e.reply(`【输入示例】\n#录入夜兰面板 生命14450+25469, 攻击652+444, 防御548+144, 元素精通84, 暴击76.3, 爆伤194.2, 治疗0,充能112.3,元素伤害61.6,物伤0`)
|
2022-06-11 14:10:53 +00:00
|
|
|
|
return true;
|
|
|
|
|
//await profileHelp(e);
|
2022-05-31 21:16:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-06-11 14:10:53 +00:00
|
|
|
|
|
|
|
|
|
let ret = Profile.inputProfile(uid, e);
|
2022-05-31 21:16:10 +00:00
|
|
|
|
let char = Character.get(e.avatar);
|
2022-06-11 14:10:53 +00:00
|
|
|
|
if (lodash.isString(ret)) {
|
|
|
|
|
e.reply(ret);
|
|
|
|
|
return true;
|
|
|
|
|
} else if (ret) {
|
2022-05-31 21:16:10 +00:00
|
|
|
|
e.reply(`${char.name}信息手工录入完成,你可以使用 #角色名+面板 / #角色名+伤害 来查看详细角色面板属性了`)
|
|
|
|
|
} else {
|
|
|
|
|
e.reply(`${char.name}信息手工录入失败,请检查录入格式。回复 #角色面板帮助 可查看录入提示`);
|
2022-06-11 14:10:53 +00:00
|
|
|
|
e.reply(`【输入示例】\n#录入夜兰面板 生命14450+25469, 攻击652+444, 防御548+144, 元素精通84, 暴击76.3, 爆伤194.2, 治疗0,充能112.3,元素伤害61.6,物伤0`)
|
2022-05-31 21:16:10 +00:00
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 数据更新
|
2022-06-06 20:59:47 +00:00
|
|
|
|
let data = await Profile.request(uid, e);
|
2022-04-16 19:39:45 +00:00
|
|
|
|
if (!data) {
|
2022-04-16 09:40:30 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
2022-06-03 09:13:12 +00:00
|
|
|
|
|
2022-04-16 09:40:30 +00:00
|
|
|
|
if (!data.chars) {
|
2022-04-20 20:28:54 +00:00
|
|
|
|
e.reply("获取角色面板数据失败,请确认角色已在游戏内橱窗展示,并开放了查看详情。设置完毕后请5分钟后再进行请求~");
|
2022-04-15 22:05:31 +00:00
|
|
|
|
} else {
|
|
|
|
|
let ret = [];
|
|
|
|
|
lodash.forEach(data.chars, (ds) => {
|
|
|
|
|
let char = Character.get(ds.id);
|
|
|
|
|
if (char) {
|
|
|
|
|
ret.push(char.name);
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
if (ret.length === 0) {
|
2022-04-20 20:28:54 +00:00
|
|
|
|
e.reply("获取角色面板数据失败,未能请求到角色数据。请确认角色已在游戏内橱窗展示,并开放了查看详情。设置完毕后请5分钟后再进行请求~")
|
2022-04-15 22:05:31 +00:00
|
|
|
|
} else {
|
2022-06-04 21:29:24 +00:00
|
|
|
|
e.reply(`获取角色面板数据成功!本次获取成功角色: ${ret.join(", ")} 。\n你可以使用 #角色名+面板 来查看详细角色面板属性了。`)
|
2022-04-15 22:05:31 +00:00
|
|
|
|
}
|
2022-04-14 20:53:22 +00:00
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-11 14:10:53 +00:00
|
|
|
|
/*
|
|
|
|
|
* 获取角色数据
|
|
|
|
|
* */
|
2022-03-26 21:34:33 +00:00
|
|
|
|
function getCharacterData(avatars) {
|
2022-03-26 08:21:44 +00:00
|
|
|
|
let list = [];
|
|
|
|
|
let set = {};
|
|
|
|
|
let setArr = [];
|
|
|
|
|
let text1 = "";
|
|
|
|
|
let text2 = "";
|
|
|
|
|
|
|
|
|
|
let weapon = {
|
|
|
|
|
type: "weapon",
|
|
|
|
|
name: avatars.weapon.name,
|
|
|
|
|
showName: genshin.abbr[avatars.weapon.name] ? genshin.abbr[avatars.weapon.name] : avatars.weapon.name,
|
|
|
|
|
level: avatars.weapon.level,
|
|
|
|
|
affix_level: avatars.weapon.affix_level,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
for (let val of avatars.reliquaries) {
|
|
|
|
|
if (set[val.set.name]) {
|
|
|
|
|
set[val.set.name]++;
|
|
|
|
|
|
|
|
|
|
if (set[val.set.name] == 2) {
|
|
|
|
|
if (text1) {
|
|
|
|
|
text2 = "2件套:" + val.set.affixes[0].effect;
|
|
|
|
|
} else {
|
|
|
|
|
text1 = "2件套:" + val.set.affixes[0].effect;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (set[val.set.name] == 4) {
|
|
|
|
|
text2 = "4件套:" + val.set.name;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
set[val.set.name] = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
list.push({
|
|
|
|
|
type: "reliquaries",
|
|
|
|
|
name: val.name,
|
|
|
|
|
level: val.level,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (let val of Object.keys(set)) {
|
|
|
|
|
setArr.push({
|
|
|
|
|
name: val,
|
|
|
|
|
num: set[val],
|
|
|
|
|
showName: genshin.abbr[val] ? genshin.abbr[val] : val,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (avatars.reliquaries.length >= 2 && !text1) {
|
|
|
|
|
text1 = "无套装效果";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (avatars.id == "10000005") {
|
|
|
|
|
avatars.name = "空";
|
|
|
|
|
} else if (avatars.id == "10000007") {
|
|
|
|
|
avatars.name = "荧";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let reliquaries = list[0];
|
|
|
|
|
return {
|
|
|
|
|
name: avatars.name,
|
|
|
|
|
showName: genshin.abbr[avatars.name] ? genshin.abbr[avatars.name] : avatars.name,
|
|
|
|
|
level: avatars.level,
|
|
|
|
|
fetter: avatars.fetter,
|
|
|
|
|
actived_constellation_num: avatars.actived_constellation_num,
|
|
|
|
|
weapon,
|
|
|
|
|
text1,
|
|
|
|
|
text2,
|
|
|
|
|
reliquaries,
|
|
|
|
|
set: setArr,
|
|
|
|
|
};
|
|
|
|
|
}
|
2022-04-14 20:53:22 +00:00
|
|
|
|
|
2022-04-15 14:33:51 +00:00
|
|
|
|
async function getAvatar(e, char, MysApi) {
|
|
|
|
|
|
|
|
|
|
let charData = await MysApi.getCharacter();
|
|
|
|
|
if (!charData) return true;
|
|
|
|
|
|
|
|
|
|
let avatars = charData.avatars;
|
|
|
|
|
let length = avatars.length;
|
|
|
|
|
char.checkAvatars(avatars);
|
|
|
|
|
avatars = lodash.keyBy(avatars, "id");
|
|
|
|
|
|
|
|
|
|
if (!avatars[char.id]) {
|
|
|
|
|
let name = lodash.truncate(e.sender.card, { length: 8 });
|
|
|
|
|
if (length > 8) {
|
|
|
|
|
e.reply([segment.at(e.user_id, name), `\n没有${e.msg}`]);
|
|
|
|
|
} else {
|
|
|
|
|
e.reply([segment.at(e.user_id, name), "\n请先在米游社展示该角色"]);
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return avatars[char.id];
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-06 20:59:47 +00:00
|
|
|
|
async function getTargetUid(e) {
|
|
|
|
|
let uidReg = /[1-9][0-9]{8}/;
|
|
|
|
|
|
|
|
|
|
if (e.uid && uidReg.test(e.uid)) {
|
|
|
|
|
return e.uid;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let uidRet = uidReg.exec(e.msg);
|
|
|
|
|
if (uidRet) {
|
|
|
|
|
return uidRet[0]
|
|
|
|
|
}
|
2022-06-11 21:54:41 +00:00
|
|
|
|
let uid = false;
|
2022-06-15 21:09:39 +00:00
|
|
|
|
let getUid = async function (qq) {
|
|
|
|
|
if (NoteCookie && NoteCookie[qq]) {
|
|
|
|
|
let nc = NoteCookie[qq];
|
|
|
|
|
if (nc.uid && uidReg.test(nc.uid)) {
|
|
|
|
|
return nc.uid;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
uid = await redis.get(`genshin:id-uid:${qq}`) || await redis.get(`genshin:uid:${qq}`);
|
|
|
|
|
if (uid && uidReg.test(uid)) {
|
|
|
|
|
return uid;
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-06-06 20:59:47 +00:00
|
|
|
|
|
2022-06-15 21:09:39 +00:00
|
|
|
|
if (e.at && e.at != BotConfig.account.qq) {
|
|
|
|
|
uid = await getUid(e.at);
|
|
|
|
|
if (uid) {
|
|
|
|
|
return uid;
|
2022-06-14 22:07:24 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2022-06-15 21:09:39 +00:00
|
|
|
|
|
|
|
|
|
uid = await getUid(e.user_id);
|
|
|
|
|
if (uid) {
|
2022-06-14 22:07:24 +00:00
|
|
|
|
return uid;
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-11 21:54:41 +00:00
|
|
|
|
try {
|
|
|
|
|
let MysApi = await e.getMysApi({
|
|
|
|
|
auth: "all",
|
|
|
|
|
targetType: "all",
|
|
|
|
|
cookieType: "all"
|
|
|
|
|
});
|
2022-06-06 20:59:47 +00:00
|
|
|
|
|
2022-06-11 21:54:41 +00:00
|
|
|
|
if (!MysApi || !e.targetUser) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uid = e.targetUser.uid;
|
|
|
|
|
if (!uid || !uidReg.test(uid)) {
|
|
|
|
|
e.reply("请先发送【#绑定+你的UID】来绑定查询目标")
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2022-06-14 22:07:24 +00:00
|
|
|
|
} catch (err) {
|
|
|
|
|
console.log(err);
|
2022-06-06 20:59:47 +00:00
|
|
|
|
}
|
2022-06-14 22:07:24 +00:00
|
|
|
|
return uid || false;
|
2022-06-06 20:59:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-04-30 21:06:17 +00:00
|
|
|
|
export async function renderProfile(e, char, render, mode = "profile", params = {}) {
|
2022-04-20 20:28:54 +00:00
|
|
|
|
|
2022-06-14 22:07:24 +00:00
|
|
|
|
let selfUser = await e.checkAuth({
|
|
|
|
|
auth: "self"
|
2022-06-06 20:59:47 +00:00
|
|
|
|
})
|
|
|
|
|
|
2022-04-20 20:28:54 +00:00
|
|
|
|
if (['荧', '空', '主角', '旅行者'].includes(char.name)) {
|
|
|
|
|
e.reply("暂不支持主角的面板信息查看");
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-04 21:29:24 +00:00
|
|
|
|
let refresh = async () => {
|
|
|
|
|
let refreshRet = await autoRefresh(e);
|
|
|
|
|
if (refreshRet) {
|
|
|
|
|
await renderProfile(e, char, render, mode, params);
|
|
|
|
|
}
|
|
|
|
|
return refreshRet;
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-06 20:59:47 +00:00
|
|
|
|
let uid = await getTargetUid(e);
|
|
|
|
|
if (!uid) {
|
2022-04-28 19:38:43 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
2022-04-14 20:53:22 +00:00
|
|
|
|
|
2022-06-14 22:07:24 +00:00
|
|
|
|
let profile = await Profile.get(uid, char.id);
|
2022-04-14 20:53:22 +00:00
|
|
|
|
if (!profile) {
|
2022-06-04 21:29:24 +00:00
|
|
|
|
if (await refresh()) {
|
|
|
|
|
return true;
|
|
|
|
|
} else {
|
2022-06-04 22:51:20 +00:00
|
|
|
|
e.reply(`请确认${char.name}已展示在【游戏内】的角色展柜中,并打开了“显示角色详情”。然后请使用 #更新面板\n命令来获取${char.name}的面板详情`);
|
2022-06-04 21:29:24 +00:00
|
|
|
|
}
|
2022-06-14 22:07:24 +00:00
|
|
|
|
//await profileHelp(e);
|
2022-04-16 20:23:19 +00:00
|
|
|
|
return true;
|
2022-06-14 22:14:58 +00:00
|
|
|
|
} else if (!['enka', 'input2', 'miao', 'miao-pre'].includes(profile.dataSource)) {
|
2022-06-04 21:29:24 +00:00
|
|
|
|
if (!await refresh()) {
|
|
|
|
|
e.reply(`由于数据格式升级,请重新获取面板信息后查看`);
|
|
|
|
|
}
|
|
|
|
|
return true;
|
2022-04-14 20:53:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let a = profile.attr;
|
|
|
|
|
let c = Format.comma,
|
|
|
|
|
p = Format.pct;
|
|
|
|
|
let attr = {
|
|
|
|
|
hp: c(a.hp),
|
|
|
|
|
hpPlus: c(a.hp - a.hpBase),
|
|
|
|
|
atk: c(a.atk),
|
|
|
|
|
atkPlus: c(a.atk - a.atkBase),
|
|
|
|
|
def: c(a.def),
|
|
|
|
|
defPlus: c(a.def - a.defBase),
|
|
|
|
|
cRate: p(a.cRate),
|
|
|
|
|
cDmg: p(a.cDmg),
|
|
|
|
|
mastery: c(a.mastery),
|
|
|
|
|
recharge: p(a.recharge),
|
2022-04-15 22:24:25 +00:00
|
|
|
|
dmgBonus: p(Math.max(a.dmgBonus * 1 || 0, a.phyBonus * 1 || 0))
|
2022-04-14 20:53:22 +00:00
|
|
|
|
};
|
|
|
|
|
|
2022-04-17 11:03:44 +00:00
|
|
|
|
let reliquaries = [], totalMark = 0, totalMaxMark = 0;
|
|
|
|
|
|
2022-06-09 20:53:38 +00:00
|
|
|
|
let newScore = Reliquaries2.getArtisMark(char.name, profile.artis);
|
2022-06-04 21:29:24 +00:00
|
|
|
|
|
2022-06-09 20:53:38 +00:00
|
|
|
|
lodash.forEach(profile.artis, (arti, idx) => {
|
|
|
|
|
idx = idx.replace("arti", "");
|
2022-06-04 21:29:24 +00:00
|
|
|
|
let ds = arti;
|
2022-06-09 20:53:38 +00:00
|
|
|
|
let mark = isNewScore ? newScore[idx] : Reliquaries.getMark(char.name, arti.attrs);
|
2022-06-04 21:29:24 +00:00
|
|
|
|
let maxMark = Reliquaries.getMaxMark(char.name, arti.main[0] || "");
|
|
|
|
|
totalMark += mark;
|
|
|
|
|
totalMaxMark += maxMark;
|
|
|
|
|
ds.mark = c(mark, 1);
|
2022-06-09 20:53:38 +00:00
|
|
|
|
ds.markType = isNewScore ? Reliquaries2.getMarkScore(mark) : Reliquaries.getMarkScore(mark, maxMark);
|
2022-06-04 21:29:24 +00:00
|
|
|
|
ds.main = Profile.formatArti(arti.main);
|
|
|
|
|
ds.attrs = Profile.formatArti(arti.attrs);
|
|
|
|
|
reliquaries.push(ds);
|
2022-04-23 21:16:37 +00:00
|
|
|
|
});
|
|
|
|
|
|
2022-06-09 20:53:38 +00:00
|
|
|
|
let markScore, usefulMark;
|
|
|
|
|
if (isNewScore) {
|
|
|
|
|
let charCfg = Reliquaries2.getCharCfg(char.name);
|
|
|
|
|
usefulMark = charCfg.titleWeight;
|
|
|
|
|
markScore = Reliquaries2.getMarkScore(totalMark / 5);
|
|
|
|
|
} else {
|
|
|
|
|
let usefulData = Reliquaries.getUseful(char.name);
|
|
|
|
|
usefulMark = usefulData.mark;
|
|
|
|
|
markScore = Reliquaries.getMarkScore(totalMark, totalMaxMark);
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-14 20:53:22 +00:00
|
|
|
|
|
2022-04-24 18:50:17 +00:00
|
|
|
|
let enemyLv = await selfUser.getCfg(`char.enemyLv`, 91);
|
2022-04-23 21:16:37 +00:00
|
|
|
|
let dmgMsg = [], dmgData = [];
|
2022-04-30 21:06:17 +00:00
|
|
|
|
let dmgCalc = await Calc.calcData({
|
|
|
|
|
profile,
|
|
|
|
|
char,
|
|
|
|
|
enemyLv,
|
|
|
|
|
mode,
|
|
|
|
|
...params
|
|
|
|
|
});
|
2022-04-23 21:16:37 +00:00
|
|
|
|
if (dmgCalc && dmgCalc.ret) {
|
|
|
|
|
lodash.forEach(dmgCalc.ret, (ds) => {
|
2022-04-24 02:48:51 +00:00
|
|
|
|
ds.dmg = Format.comma(ds.dmg, 0);
|
|
|
|
|
ds.avg = Format.comma(ds.avg, 0);
|
2022-04-23 21:16:37 +00:00
|
|
|
|
dmgData.push(ds);
|
|
|
|
|
})
|
2022-04-29 22:35:21 +00:00
|
|
|
|
lodash.forEach(dmgCalc.msg, (msg) => {
|
|
|
|
|
msg.replace(":", ":");
|
|
|
|
|
dmgMsg.push(msg.split(":"))
|
|
|
|
|
})
|
2022-04-23 21:16:37 +00:00
|
|
|
|
}
|
2022-04-17 11:03:44 +00:00
|
|
|
|
|
2022-04-30 21:06:17 +00:00
|
|
|
|
if (mode === "dmg") {
|
|
|
|
|
let basic = dmgCalc.dmgCfg.basicRet;
|
|
|
|
|
lodash.forEach(dmgCalc.dmgRet, (row) => {
|
|
|
|
|
lodash.forEach(row, (ds) => {
|
|
|
|
|
ds.val = (ds.avg > basic.avg ? "+" : "") + Format.comma(ds.avg - basic.avg);
|
|
|
|
|
ds.dmg = Format.comma(ds.dmg, 0);
|
|
|
|
|
ds.avg = Format.comma(ds.avg, 0);
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
});
|
|
|
|
|
basic.dmg = Format.comma(basic.dmg);
|
|
|
|
|
basic.avg = Format.comma(basic.avg);
|
|
|
|
|
}
|
2022-05-22 13:10:10 +00:00
|
|
|
|
//渲染图像
|
|
|
|
|
return await Common.render("character/detail", {
|
2022-04-14 20:53:22 +00:00
|
|
|
|
save_id: uid,
|
|
|
|
|
uid: uid,
|
|
|
|
|
data: profile,
|
|
|
|
|
attr,
|
2022-04-15 14:33:51 +00:00
|
|
|
|
cons: char.cons,
|
|
|
|
|
name: char.name,
|
|
|
|
|
elem: char.elem,
|
2022-04-23 21:16:37 +00:00
|
|
|
|
dmgData,
|
|
|
|
|
dmgMsg,
|
2022-04-30 21:06:17 +00:00
|
|
|
|
dmgRet: dmgCalc.dmgRet,
|
|
|
|
|
dmgCfg: dmgCalc.dmgCfg,
|
2022-04-15 14:33:51 +00:00
|
|
|
|
reliquaries,
|
2022-04-24 18:50:17 +00:00
|
|
|
|
enemyLv,
|
2022-05-19 02:34:21 +00:00
|
|
|
|
enemyName: dmgCalc.enemyName || "小宝",
|
2022-04-17 11:03:44 +00:00
|
|
|
|
totalMark: c(totalMark, 1),
|
2022-06-09 20:53:38 +00:00
|
|
|
|
markScore,
|
2022-04-17 11:03:44 +00:00
|
|
|
|
usefulMark,
|
2022-04-14 20:53:22 +00:00
|
|
|
|
talentMap: { a: "普攻", e: "战技", q: "爆发" },
|
2022-05-22 13:10:10 +00:00
|
|
|
|
bodyClass: `char-${char.name}`,
|
2022-04-29 22:35:21 +00:00
|
|
|
|
mode,
|
2022-05-22 13:10:10 +00:00
|
|
|
|
}, { e, render, scale: 1.6 });
|
2022-04-24 19:22:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-04-29 21:54:41 +00:00
|
|
|
|
/* #敌人等级 */
|
2022-04-24 19:22:27 +00:00
|
|
|
|
export async function enemyLv(e) {
|
|
|
|
|
let selfUser = await e.checkAuth({
|
|
|
|
|
auth: "self"
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
if (!selfUser || !e.msg) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2022-04-29 21:54:41 +00:00
|
|
|
|
let ret = /(敌人|怪物)等级\s*(\d{1,3})\s*$/.exec(e.msg);
|
|
|
|
|
if (ret && ret[2]) {
|
|
|
|
|
let lv = ret[2] * 1;
|
2022-04-24 19:22:27 +00:00
|
|
|
|
|
|
|
|
|
await selfUser.setCfg("char.enemyLv", lv);
|
|
|
|
|
|
|
|
|
|
lv = await selfUser.getCfg("char.enemyLv", 91);
|
|
|
|
|
e.reply(`敌人等级已经设置为${lv}`);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
|
2022-04-28 20:50:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-06-11 14:10:53 +00:00
|
|
|
|
/*
|
|
|
|
|
* 圣遗物列表
|
|
|
|
|
* */
|
2022-04-28 20:50:58 +00:00
|
|
|
|
export async function getArtis(e, { render }) {
|
|
|
|
|
|
2022-06-06 20:59:47 +00:00
|
|
|
|
let uid = await getTargetUid(e);
|
|
|
|
|
if (!uid) {
|
|
|
|
|
return true;
|
2022-06-04 21:29:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-04-28 20:50:58 +00:00
|
|
|
|
let artis = [],
|
|
|
|
|
profiles = Profile.getAll(uid) || {};
|
|
|
|
|
|
|
|
|
|
if (!profiles || profiles.length === 0) {
|
|
|
|
|
e.reply("暂无角色圣遗物详情");
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lodash.forEach(profiles || [], (ds) => {
|
|
|
|
|
let name = ds.name;
|
2022-06-09 20:53:38 +00:00
|
|
|
|
if (!name || name === "空" || name === "荧") {
|
2022-04-28 20:50:58 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
2022-06-15 21:09:39 +00:00
|
|
|
|
|
|
|
|
|
|
2022-06-16 20:19:27 +00:00
|
|
|
|
let usefulMark;
|
2022-06-15 21:09:39 +00:00
|
|
|
|
if (isNewScore) {
|
|
|
|
|
let charCfg = Reliquaries2.getCharCfg(name);
|
|
|
|
|
usefulMark = charCfg.titleWeight;
|
|
|
|
|
} else {
|
|
|
|
|
let usefulData = Reliquaries.getUseful(name);
|
|
|
|
|
usefulMark = usefulData.mark;
|
|
|
|
|
}
|
2022-06-09 20:53:38 +00:00
|
|
|
|
|
2022-04-28 20:50:58 +00:00
|
|
|
|
/* 处理圣遗物 */
|
|
|
|
|
if (ds.artis) {
|
2022-06-09 20:53:38 +00:00
|
|
|
|
let newScore = Reliquaries2.getArtisMark(name, ds.artis);
|
|
|
|
|
|
|
|
|
|
lodash.forEach(ds.artis, (arti, idx) => {
|
2022-06-03 09:13:12 +00:00
|
|
|
|
if (!arti.name) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2022-06-09 20:53:38 +00:00
|
|
|
|
idx = idx.replace("arti", "");
|
|
|
|
|
let mark = isNewScore ? newScore[idx] : Reliquaries.getMark(name, arti.attrs);
|
2022-04-28 20:50:58 +00:00
|
|
|
|
let maxMark = Reliquaries.getMaxMark(name, arti.main[0] || "");
|
|
|
|
|
arti.mark = Format.comma(mark, 1);
|
|
|
|
|
arti._mark = mark;
|
2022-06-09 20:53:38 +00:00
|
|
|
|
arti.markType = isNewScore ? Reliquaries2.getMarkScore(mark) : Reliquaries.getMarkScore(mark, maxMark);
|
2022-04-28 20:50:58 +00:00
|
|
|
|
arti.main = Profile.formatArti(arti.main);
|
|
|
|
|
arti.attrs = Profile.formatArti(arti.attrs);
|
|
|
|
|
arti.usefulMark = usefulMark;
|
|
|
|
|
arti.avatar = name;
|
|
|
|
|
artis.push(arti);
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2022-04-29 21:54:41 +00:00
|
|
|
|
if (artis.length === 0) {
|
|
|
|
|
e.reply("请先获取角色面板数据后再查看圣遗物列表...");
|
|
|
|
|
await profileHelp(e);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2022-04-28 20:50:58 +00:00
|
|
|
|
artis = lodash.sortBy(artis, "_mark");
|
|
|
|
|
artis = artis.reverse();
|
|
|
|
|
artis = artis.slice(0, 20);
|
|
|
|
|
|
2022-05-22 13:10:10 +00:00
|
|
|
|
//渲染图像
|
|
|
|
|
return await Common.render("character/artis", {
|
2022-04-28 20:50:58 +00:00
|
|
|
|
save_id: uid,
|
|
|
|
|
uid: uid,
|
|
|
|
|
artis,
|
2022-05-22 13:10:10 +00:00
|
|
|
|
}, { e, render, scale: 1.4 });
|
2022-04-28 20:50:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-06-11 14:10:53 +00:00
|
|
|
|
/*
|
|
|
|
|
* 获取面板列表
|
|
|
|
|
* */
|
2022-04-28 20:50:58 +00:00
|
|
|
|
export async function getProfileAll(e) {
|
2022-06-04 23:03:18 +00:00
|
|
|
|
|
2022-06-06 20:59:47 +00:00
|
|
|
|
let uid = await getTargetUid(e);
|
|
|
|
|
if (!uid) {
|
2022-04-28 20:50:58 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
2022-06-04 23:03:18 +00:00
|
|
|
|
|
2022-04-28 20:50:58 +00:00
|
|
|
|
let profiles = Profile.getAll(uid) || {};
|
2022-04-29 21:54:41 +00:00
|
|
|
|
|
|
|
|
|
let chars = [];
|
|
|
|
|
lodash.forEach(profiles || [], (ds) => {
|
2022-06-14 22:14:58 +00:00
|
|
|
|
if (!['enka', 'input2', 'miao-pre', 'miao'].includes(ds.dataSource)) {
|
2022-06-04 21:29:24 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
2022-04-29 21:54:41 +00:00
|
|
|
|
ds.name && chars.push(ds.name)
|
|
|
|
|
});
|
|
|
|
|
|
2022-06-04 22:36:37 +00:00
|
|
|
|
|
2022-04-29 21:54:41 +00:00
|
|
|
|
if (chars.length === 0) {
|
2022-06-04 22:36:37 +00:00
|
|
|
|
if (await autoRefresh(e)) {
|
|
|
|
|
await getProfileAll(e);
|
|
|
|
|
return true;
|
|
|
|
|
} else {
|
|
|
|
|
e.reply("尚未获取任何角色数据");
|
|
|
|
|
await profileHelp(e);
|
|
|
|
|
}
|
2022-04-29 21:54:41 +00:00
|
|
|
|
return true;
|
2022-04-28 20:50:58 +00:00
|
|
|
|
}
|
2022-06-04 21:29:24 +00:00
|
|
|
|
|
2022-06-14 22:07:24 +00:00
|
|
|
|
e.reply(`uid${uid} 已获取面板角色: ` + chars.join(", "));
|
2022-04-29 21:54:41 +00:00
|
|
|
|
|
2022-04-28 20:50:58 +00:00
|
|
|
|
return true;
|
2022-04-29 21:54:41 +00:00
|
|
|
|
}
|
2022-04-28 20:50:58 +00:00
|
|
|
|
|
2022-04-29 21:54:41 +00:00
|
|
|
|
export async function profileHelp(e) {
|
|
|
|
|
e.reply(segment.image(`file://${process.cwd()}/plugins/miao-plugin/resources/character/imgs/help.jpg`))
|
|
|
|
|
return true;
|
2022-06-11 08:22:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 获取角色卡片的原图 */
|
|
|
|
|
export async function getOriginalPicture(e) {
|
|
|
|
|
if (!e.hasReply) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// 引用的消息不是自己的消息
|
|
|
|
|
if (e.source.user_id !== e.self_id) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// 引用的消息不是纯图片
|
|
|
|
|
if (!/^\[图片]$/.test(e.source.message)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// 获取原消息
|
|
|
|
|
let source;
|
|
|
|
|
if (e.isGroup) {
|
|
|
|
|
source = (await e.group.getChatHistory(e.source.seq, 1)).pop();
|
|
|
|
|
} else {
|
|
|
|
|
source = (await e.friend.getChatHistory(e.source.time, 1)).pop();
|
|
|
|
|
}
|
|
|
|
|
if (source) {
|
|
|
|
|
let imgPath = await redis.get(`miao:original-picture:${source.message_id}`);
|
|
|
|
|
if (imgPath) {
|
|
|
|
|
e.reply([segment.image(process.cwd() + "/plugins/miao-plugin/resources/" + imgPath)]);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
e.reply("消息太过久远了,俺也忘了原图是啥了,下次早点来吧~");
|
|
|
|
|
return true;
|
|
|
|
|
}
|