mirror of
https://github.com/yoimiya-kokomi/miao-plugin.git
synced 2024-11-16 04:35:42 +00:00
新增#上传深渊数据
命令
新增角色 应达、萍儿 的角色配置及图片
This commit is contained in:
parent
e93628fb8c
commit
1c2b6b3d3e
@ -1,3 +1,11 @@
|
||||
# 1.8.4
|
||||
|
||||
* 新增`#上传深渊数据`命令
|
||||
* 可上传自己角色的深渊挑战数据及角色列表,不会上传其他信息
|
||||
* 上传数据用于`#角色持有率 #深渊出场率`等统计,可使统计更加及时准确
|
||||
* 数据统计及服务来自SG团队胡桃API
|
||||
* 新增角色 派蒙、瑶瑶、白术、伐难、应达、散兵、女士、萍儿 的角色配置及图片
|
||||
|
||||
# 1.8.3
|
||||
|
||||
* `#刻晴` 角色卡片功能升级
|
||||
|
74
apps/stat.js
74
apps/stat.js
@ -3,9 +3,8 @@
|
||||
*
|
||||
* */
|
||||
import { HutaoApi, Character } from "../components/models.js";
|
||||
import { Cfg } from "../components/index.js";
|
||||
import { Cfg, Data } from "../components/index.js";
|
||||
import lodash from "lodash";
|
||||
import { segment } from "oicq";
|
||||
import fs from "fs";
|
||||
import Common from "../components/Common.js";
|
||||
|
||||
@ -193,7 +192,6 @@ async function getTalentData(e, isUpdate = false) {
|
||||
|
||||
export async function abyssTeam(e, { render }) {
|
||||
|
||||
|
||||
let MysApi = await e.getMysApi({
|
||||
auth: "cookie", // 所有用户均可查询
|
||||
targetType: "self", // 被查询用户可以是任意用户
|
||||
@ -225,7 +223,6 @@ export async function abyssTeam(e, { render }) {
|
||||
avatarRet[avatar.id] = Math.min(avatar.level, avatar.weapon_level) * 100 + Math.max(avatar.a_original, avatar.e_original, avatar.q_original) * 1000
|
||||
});
|
||||
|
||||
|
||||
let getTeamCfg = (str) => {
|
||||
let teams = str.split(",");
|
||||
teams.sort();
|
||||
@ -386,3 +383,72 @@ export async function abyssTeam(e, { render }) {
|
||||
avatars: avatarMap,
|
||||
}, { e, render, scale: 1.5 });
|
||||
}
|
||||
|
||||
export async function uploadData(e) {
|
||||
let MysApi = await e.getMysApi({
|
||||
auth: "cookie",
|
||||
targetType: "self",
|
||||
cookieType: "self",
|
||||
action: "获取信息"
|
||||
});
|
||||
if (!MysApi) return;
|
||||
let ret = {};
|
||||
let uid = e.selfUser.uid;
|
||||
try {
|
||||
let resDetail = await MysApi.getCharacter();
|
||||
let resAbyss = await MysApi.getSpiralAbyss(1);
|
||||
if (!resDetail || !resAbyss || !resDetail.avatars || resDetail.avatars.length <= 3) {
|
||||
e.reply("角色信息获取失败");
|
||||
return true;
|
||||
}
|
||||
let playerAvatars = [];
|
||||
lodash.forEach(resDetail.avatars || [], (avatar) => {
|
||||
let tmp = Data.getData(avatar, "id,level,activedConstellationNum:actived_constellation_num")
|
||||
tmp.weapon = Data.getData(avatar.weapon, "id,level,affixLevel:affix_level");
|
||||
let setMap = {};
|
||||
lodash.forEach(avatar.reliquaries, (ds) => {
|
||||
setMap[ds.set.id] = setMap[ds.set.id] || 0;
|
||||
setMap[ds.set.id]++;
|
||||
})
|
||||
let reliquarySets = [];
|
||||
lodash.forEach(setMap, (count, id) => {
|
||||
reliquarySets.push({ id: id * 1, count })
|
||||
});
|
||||
tmp.reliquarySets = reliquarySets;
|
||||
playerAvatars.push(tmp);
|
||||
})
|
||||
let playerSpiralAbyssesLevels = [];
|
||||
let getBattleData = function (ds) {
|
||||
let avatars = [];
|
||||
lodash.forEach(ds.avatars, (a) => {
|
||||
avatars.push(a.id);
|
||||
})
|
||||
return {
|
||||
battleIndex: ds.index - 1 || 0,
|
||||
avatarIds: avatars
|
||||
}
|
||||
}
|
||||
lodash.forEach(resAbyss.floors || [], (floor) => {
|
||||
lodash.forEach(floor.levels || [], (level) => {
|
||||
playerSpiralAbyssesLevels.push({
|
||||
floorIndex: floor.index,
|
||||
levelIndex: level.index,
|
||||
star: level.star,
|
||||
battles: [getBattleData(level.battles[0] || {}), getBattleData(level.battles[1] || {})]
|
||||
})
|
||||
})
|
||||
});
|
||||
ret = await HutaoApi.upload({
|
||||
uid: uid.toString(),
|
||||
playerAvatars,
|
||||
playerSpiralAbyssesLevels
|
||||
});
|
||||
} catch (err) {
|
||||
}
|
||||
if (ret && ret.retcode === 0) {
|
||||
e.reply(`uid:${uid}本次深渊记录上传成功\n多谢支持,喵~`);
|
||||
} else {
|
||||
e.reply(`${ret.message || "上传失败"},请稍后重试...`);
|
||||
}
|
||||
return true;
|
||||
}
|
@ -14,13 +14,13 @@ let Data = {
|
||||
nowPath = rootPath;
|
||||
pathList.forEach((name, idx) => {
|
||||
name = name.trim();
|
||||
if (!includeFile && idx <= pathList.length - 1) {
|
||||
// if (!includeFile && idx <= pathList.length - 1) {
|
||||
nowPath += name + "/";
|
||||
if (name) {
|
||||
if (!fs.existsSync(nowPath)) {
|
||||
fs.mkdirSync(nowPath);
|
||||
}
|
||||
}
|
||||
// }
|
||||
}
|
||||
})
|
||||
},
|
||||
@ -50,8 +50,10 @@ let Data = {
|
||||
}
|
||||
|
||||
// 检查并创建目录
|
||||
Data.createDir(path, true);
|
||||
return fs.writeFileSync(`${path}/${file}`, JSON.stringify(data, null, space));
|
||||
Data.createDir(_path, path, true);
|
||||
console.log(data);
|
||||
delete data._res;
|
||||
return fs.writeFileSync(`${_path}/${path}/${file}`, JSON.stringify(data, null, space));
|
||||
},
|
||||
|
||||
async importModule(path, file, rootPath = _path) {
|
||||
|
@ -5,6 +5,7 @@
|
||||
* */
|
||||
|
||||
import fetch from "node-fetch";
|
||||
import lodash from "lodash";
|
||||
|
||||
const host = "http://49.232.91.210:88/miaoPlugin/hutaoApi";
|
||||
|
||||
@ -15,17 +16,18 @@ function getApi(api) {
|
||||
}
|
||||
|
||||
let HutaoApi = {
|
||||
async req(url, data) {
|
||||
async req(url, param = {}) {
|
||||
let cacheData = await redis.get(`hutao:${url}`);
|
||||
if (cacheData) {
|
||||
if (cacheData && param.method !== "POST") {
|
||||
return JSON.parse(cacheData)
|
||||
}
|
||||
|
||||
let response = await fetch(getApi(`${url}`), {
|
||||
method: "GET",
|
||||
...param,
|
||||
method: param.method || "GET",
|
||||
});
|
||||
let retData = await response.json();
|
||||
if (retData && retData.data) {
|
||||
if (retData && retData.data && param.method !== "POST") {
|
||||
let d = new Date();
|
||||
retData.lastUpdate = `${d.toLocaleDateString()} ${d.toTimeString().substr(0, 5)}`;
|
||||
await redis.set(`hutao:${url}`, JSON.stringify(retData), { EX: 3600 });
|
||||
@ -44,6 +46,17 @@ let HutaoApi = {
|
||||
|
||||
async getAbyssTeam() {
|
||||
return await HutaoApi.req("/Statistics/TeamCombination");
|
||||
},
|
||||
|
||||
async upload(data) {
|
||||
let body = JSON.stringify(data);
|
||||
return await HutaoApi.req("/Record/Upload", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
'Content-Type': 'text/json; charset=utf-8',
|
||||
},
|
||||
body
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -23,7 +23,9 @@ export const customCharacters = {
|
||||
nvshi: ["女士", "炽热的炎之魔女", "炎之魔女"],
|
||||
baizhu: ["白术", "长生"],
|
||||
yaoyao: ["瑶瑶", "遥遥", "遥遥无期"],
|
||||
fanan: ["伐难", "水夜叉"]
|
||||
fanan: ["伐难", "水夜叉"],
|
||||
yingda: ["应达", "火夜叉", "火鼠大将"],
|
||||
ping: ["萍姥姥", "歌尘浪市真君", "歌尘浪市", "萍儿"]
|
||||
}
|
||||
|
||||
/*
|
||||
@ -32,7 +34,7 @@ export const customCharacters = {
|
||||
* */
|
||||
export const wifeData = {
|
||||
// 老婆&女朋友:成女、少女
|
||||
girlfriend: "伐难, 女士",
|
||||
girlfriend: "伐难, 女士, 萍姥姥",
|
||||
|
||||
// 老公&男朋友:成男、少男
|
||||
boyfriend: "散兵, 白术",
|
||||
|
8
index.js
8
index.js
@ -12,7 +12,7 @@ export {
|
||||
|
||||
import { wifeReg } from "./apps/character.js";
|
||||
|
||||
import { consStat, abyssPct, abyssTeam } from "./apps/stat.js";
|
||||
import { consStat, abyssPct, abyssTeam, uploadData } from "./apps/stat.js";
|
||||
import { wiki, calendar } from "./apps/wiki.js";
|
||||
import { help, versionInfo } from "./apps/help.js";
|
||||
import lodash from "lodash";
|
||||
@ -32,7 +32,8 @@ export {
|
||||
help,
|
||||
versionInfo,
|
||||
calendar,
|
||||
profileCfg
|
||||
profileCfg,
|
||||
uploadData
|
||||
};
|
||||
|
||||
|
||||
@ -102,6 +103,9 @@ let rule = {
|
||||
reg: "^(#|喵喵)+(日历|日历列表)$",
|
||||
describe: "【#日历】 活动日历",
|
||||
},
|
||||
uploadData: {
|
||||
reg: "^#上传深渊数据$"
|
||||
},
|
||||
...adminRule
|
||||
};
|
||||
|
||||
|
@ -107,6 +107,10 @@ export const helpList = [{
|
||||
icon: 86,
|
||||
title: "#签到",
|
||||
desc: "米游社原神签到"
|
||||
}, {
|
||||
icon: 77,
|
||||
title: "#上传深渊数据",
|
||||
desc: "上传您的深渊数据用于数据统计"
|
||||
}]
|
||||
}, {
|
||||
group: "其他查询指令",
|
||||
|
@ -21,8 +21,9 @@
|
||||
<div class="cont-title">深渊出场率统计</div>
|
||||
<div class="cont-body">
|
||||
<ul class="cont-msg">
|
||||
<li>数据来自<strong>胡桃API</strong>,为Snap Genshin用户自主上传的角色池信息,感谢SG团队</li>
|
||||
<li>百分比基于全部上传用户的数据进行统计,结果供参考</li>
|
||||
<li>数据来自SG团队<strong>胡桃API</strong>,为Snap Genshin / Miao-Plugin 用户自主上传的角色池信息</li>
|
||||
<li>您可以通过<strong>#上传深渊数据</strong>命令来上传挑战记录,来帮助我们统计的更加及时准确</li>
|
||||
<li>上传命令<strong>仅会上传您的角色列表及当期深渊挑战数据</strong>,不会上传其他额外信息</li>
|
||||
<li>由于是用户自主上传,数据可能有一定滞后。出场率会在深渊开启后一段时间逐步稳定</li>
|
||||
<li>数据最后更新时间:{{lastUpdate}}</li>
|
||||
</ul>
|
||||
|
@ -16,10 +16,11 @@
|
||||
<div class="cont-title">深渊配队说明</div>
|
||||
<div class="cont-body">
|
||||
<ul class="cont-msg">
|
||||
<li>根据<strong>当前账号的角色练度</strong>及本期深渊出场数据,推荐较匹配的配队方案</li>
|
||||
<li>若当前记录可用配队方案少于4组时,会使用未持有角色的方案进行补充</li>
|
||||
<li>深渊出场数据来自<strong>胡桃API</strong>,为SnapGenshin用户自主上传的深渊挑战记录,感谢SG团队</li>
|
||||
<li>深渊出场数据来自SG团队<strong>胡桃API</strong>,为Snap Genshin / Miao-Plugin 用户自主上传的角色池信息</li>
|
||||
<li>您可以通过<strong>#上传深渊数据</strong>命令来上传角色记录,来帮助我们获取更多组队信息。</li>
|
||||
<li>上传命令<strong>仅会上传您的角色列表及当期深渊挑战数据</strong>,不会上传其他额外信息</li>
|
||||
<li>月初及月中深渊刚刷新后挑战数据可能不足,请等待几天之后数据会逐步稳定</li>
|
||||
<li>若当前记录可用配队方案少于4组时,会使用未持有角色的方案进行补充</li>
|
||||
<li>配队列表<strong>仅供参考</strong>,可根据账号实际情况及个人倾向进行灵活调整</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
@ -29,9 +29,11 @@ return (num * 100).toFixed(2);
|
||||
<div class="cont-title">角色持有率说明</div>
|
||||
<div class="cont-body">
|
||||
<ul class="cont-msg">
|
||||
<li>数据来自<strong>胡桃API</strong>,为Snap Genshin用户自主上传的角色池信息,感谢SG团队</li>
|
||||
<li>数据来自SG团队<strong>胡桃API</strong>,为Snap Genshin / Miao-Plugin 用户自主上传的角色池信息</li>
|
||||
<li>百分比基于全部上传用户的数据进行统计,能够一定程度上反映角色持有情况,结果供参考</li>
|
||||
<li>由于是用户自主上传,数据可能有一定滞后。新角色的持有率会在卡池结束后的一段时间逐步稳定</li>
|
||||
<li>您可以通过<strong>#上传深渊数据</strong>命令来上传角色记录,来帮助我们统计的更加全面</li>
|
||||
<li>上传命令<strong>仅会上传您的角色列表及当期深渊挑战数据</strong>,不会上传其他额外信息</li>
|
||||
<li>由于是用户自主上传,数据可能有一定滞后。新角色的持有率会在卡池结束后一段时间逐步稳定</li>
|
||||
<li>数据最后更新时间:{{lastUpdate}}</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user