mirror of
https://github.com/yoimiya-kokomi/miao-plugin.git
synced 2024-11-16 04:35:42 +00:00
为#面板更新
命令增加uid合法性校验
`#角色持有率`、`#深渊出场率` 页面细节样式调整
This commit is contained in:
parent
3da44d7009
commit
e503488a7e
@ -1,3 +1,8 @@
|
||||
# 1.7.2
|
||||
|
||||
* 为`#面板更新`命令增加uid合法性校验
|
||||
* `#角色持有率`、`#深渊出场率` 页面细节样式调整
|
||||
|
||||
# 1.7.1
|
||||
|
||||
* `#更新面板` 功能fix
|
||||
|
@ -390,7 +390,7 @@ async function renderCard(e, avatar, render, renderType = "card") {
|
||||
//渲染图像
|
||||
return await Common.render("character/card", {
|
||||
save_id: uid,
|
||||
uid: uid,
|
||||
uid,
|
||||
talent,
|
||||
crownNum,
|
||||
talentMap: { a: "普攻", e: "战技", q: "爆发" },
|
||||
@ -458,21 +458,12 @@ async function getTalent(e, avatars) {
|
||||
|
||||
|
||||
async function autoRefresh(e) {
|
||||
let MysApi = await e.getMysApi({
|
||||
auth: "all",
|
||||
targetType: "all",
|
||||
cookieType: "all",
|
||||
actionName: "更新角色信息"
|
||||
});
|
||||
|
||||
if (!MysApi || !e.targetUser) {
|
||||
return;
|
||||
let uid = await getTargetUid(e);
|
||||
if (!uid || e.isRefreshed) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let uid = e.uid || e.targetUser.uid;
|
||||
if (!uid) {
|
||||
return true;
|
||||
}
|
||||
let refreshMark = await redis.get(`miao:profile-refresh-cd:${uid}`);
|
||||
let inCd = await redis.get(`miao:role-all:${uid}`);
|
||||
|
||||
@ -481,6 +472,7 @@ async function autoRefresh(e) {
|
||||
}
|
||||
|
||||
await redis.set(`miao:profile-refresh-cd:${uid}`, "TRUE", { EX: 3600 * 12 });
|
||||
e.isRefreshed = true;
|
||||
|
||||
// 数据更新
|
||||
let data = await Profile.request(uid, e);
|
||||
@ -512,15 +504,10 @@ async function autoRefresh(e) {
|
||||
|
||||
|
||||
export async function getProfile(e, mode = "refresh") {
|
||||
let MysApi = await e.getMysApi({
|
||||
auth: "all",
|
||||
targetType: "all",
|
||||
cookieType: "all",
|
||||
actionName: "更新角色信息"
|
||||
});
|
||||
|
||||
if (!MysApi || !e.targetUser) {
|
||||
return false;
|
||||
let uid = await getTargetUid(e);
|
||||
console.log('uid', uid)
|
||||
if (!uid) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (mode === "input") {
|
||||
@ -542,7 +529,7 @@ export async function getProfile(e, mode = "refresh") {
|
||||
}
|
||||
|
||||
// 数据更新
|
||||
let data = await Profile.request(e.uid || e.targetUser.uid, e);
|
||||
let data = await Profile.request(uid, e);
|
||||
if (!data) {
|
||||
return true;
|
||||
}
|
||||
@ -664,8 +651,46 @@ async function getAvatar(e, char, MysApi) {
|
||||
return avatars[char.id];
|
||||
}
|
||||
|
||||
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]
|
||||
}
|
||||
|
||||
let MysApi = await e.getMysApi({
|
||||
auth: "all",
|
||||
targetType: "all",
|
||||
cookieType: "all"
|
||||
});
|
||||
|
||||
if (!MysApi || !e.targetUser) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let uid = e.targetUser.uid;
|
||||
if (!uid || !uidReg.test(uid)) {
|
||||
e.reply("请先发送【#绑定+你的UID】来绑定查询目标")
|
||||
return false;
|
||||
}
|
||||
|
||||
return uid;
|
||||
}
|
||||
|
||||
export async function renderProfile(e, char, render, mode = "profile", params = {}) {
|
||||
|
||||
let MysApi = await e.getMysApi({
|
||||
auth: "all",
|
||||
targetType: "all",
|
||||
cookieType: "all"
|
||||
})
|
||||
let { selfUser } = MysApi;
|
||||
|
||||
if (['荧', '空', '主角', '旅行者'].includes(char.name)) {
|
||||
e.reply("暂不支持主角的面板信息查看");
|
||||
return true;
|
||||
@ -679,19 +704,11 @@ export async function renderProfile(e, char, render, mode = "profile", params =
|
||||
return refreshRet;
|
||||
}
|
||||
|
||||
let MysApi = await e.getMysApi({
|
||||
auth: "all",
|
||||
targetType: "all",
|
||||
cookieType: "all",
|
||||
actionName: "查询角色天赋命座等信息"
|
||||
});
|
||||
if (!MysApi || !e.targetUser) {
|
||||
let uid = await getTargetUid(e);
|
||||
if (!uid) {
|
||||
return true;
|
||||
}
|
||||
|
||||
let selfUser = e.selfUser,
|
||||
uid = e.uid || e.targetUser.uid;
|
||||
|
||||
let profile = Profile.get(uid, char.id);
|
||||
if (!profile) {
|
||||
if (await refresh()) {
|
||||
@ -843,13 +860,11 @@ export async function getArtis(e, { render }) {
|
||||
return true;
|
||||
}
|
||||
|
||||
let uidRet = /[0-9]{9}/.exec(e.msg);
|
||||
if (uidRet) {
|
||||
e.uid = uidRet[0];
|
||||
let uid = await getTargetUid(e);
|
||||
if (!uid) {
|
||||
return true;
|
||||
}
|
||||
|
||||
let uid = e.uid || e.targetUser.uid;
|
||||
|
||||
let artis = [],
|
||||
profiles = Profile.getAll(uid) || {};
|
||||
|
||||
@ -903,19 +918,12 @@ export async function getArtis(e, { render }) {
|
||||
}
|
||||
|
||||
export async function getProfileAll(e) {
|
||||
let MysApi = await e.getMysApi({
|
||||
auth: "all",
|
||||
targetType: "all",
|
||||
cookieType: "all",
|
||||
actionName: "查询角色天赋命座等信息"
|
||||
});
|
||||
|
||||
if (!MysApi || !e.targetUser) {
|
||||
let uid = await getTargetUid(e);
|
||||
if (!uid) {
|
||||
return true;
|
||||
}
|
||||
|
||||
let uid = e.targetUser.uid;
|
||||
|
||||
let profiles = Profile.getAll(uid) || {};
|
||||
|
||||
let chars = [];
|
||||
|
@ -58,6 +58,7 @@ export async function consStat(e, { render }) {
|
||||
} else {
|
||||
data.cons = ds.rate
|
||||
}
|
||||
data.cons = lodash.sortBy(data.cons, ['id'])
|
||||
|
||||
|
||||
ret.push(data);
|
||||
@ -123,7 +124,7 @@ export async function abyssPct(e, { render }) {
|
||||
if (char) {
|
||||
avatars.push({
|
||||
name: char.name,
|
||||
star: char.rarity,
|
||||
star: char.star,
|
||||
value: ds.value * 8
|
||||
})
|
||||
}
|
||||
|
@ -30,6 +30,9 @@ function sleep(ms) {
|
||||
|
||||
let Profile = {
|
||||
async request(uid, e) {
|
||||
if (uid.toString().length !== 9) {
|
||||
return false;
|
||||
}
|
||||
let profileApi = config.profileApi || function (uid) {
|
||||
return `https://enka.shinshin.moe/u/${uid}/__data.json`
|
||||
};
|
||||
@ -39,7 +42,7 @@ let Profile = {
|
||||
e.reply("请求过快,请稍后重试..");
|
||||
return false;
|
||||
} else if (inCd === 'pending') {
|
||||
e.reply("距上次请求刷新成功间隔小于5分钟,请稍后重试..");
|
||||
e.reply("#ref距上次请求刷新成功间隔小于5分钟,请稍后重试..");
|
||||
return false;
|
||||
}
|
||||
await redis.set(`miao:role-all:${uid}`, 'loading', { EX: 20 });
|
||||
|
@ -6,8 +6,6 @@ import _Data from "../Data.js";
|
||||
import moment from "moment";
|
||||
|
||||
moment.locale("zh-cn");
|
||||
|
||||
|
||||
let _path = process.cwd();
|
||||
let relis = _Data.readJSON(`${_path}/plugins/miao-plugin/resources/meta/reliquaries/`, "data.json") || {};
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
2
index.js
2
index.js
@ -61,7 +61,7 @@ let rule = {
|
||||
describe: "【#角色】#老公 #老婆 查询",
|
||||
},
|
||||
consStat: {
|
||||
reg: "^#(喵喵)?角色(持有|持有率|命座|命之座|.命)(分布|统计)?$",
|
||||
reg: "^#(喵喵)?角色(持有|持有率|命座|命之座|.命)(分布|统计|持有|持有率)?$",
|
||||
describe: "【#统计】 #角色持有率 #角色5命统计",
|
||||
},
|
||||
abyssPct: {
|
||||
|
@ -8,9 +8,7 @@ export const details = [{
|
||||
|
||||
}, {
|
||||
title: "Q协同单段伤害",
|
||||
shwoDetail: true,
|
||||
dmg: ({ talent, attr, calc, cons }, { basic }) => {
|
||||
console.log('hp', attr.hp, calc(attr.hp), talent.q['玄掷玲珑伤害'] / 3)
|
||||
return basic(calc(attr.hp) * (talent.q['玄掷玲珑伤害'] / 3 / 100), 'q')
|
||||
}
|
||||
}];
|
||||
|
Loading…
Reference in New Issue
Block a user