From 3c6e7f264ae00a7bfde54d35c2289bcd857f1354 Mon Sep 17 00:00:00 2001 From: yoimiya-kokomi <592981798@qq.com> Date: Fri, 8 Jul 2022 07:02:25 +0800 Subject: [PATCH] =?UTF-8?q?`#=E4=B8=8A=E4=BC=A0=E6=B7=B1=E6=B8=8A=E6=95=B0?= =?UTF-8?q?=E6=8D=AE`=E5=91=BD=E4=BB=A4=E4=BC=9A=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E6=9C=80=E5=BC=BA=E4=B8=80=E5=87=BB=E5=8F=8A=E6=89=BF=E5=8F=97?= =?UTF-8?q?=E4=BC=A4=E5=AE=B3=E7=9A=84=E6=8E=92=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 6 +++ apps/character/avatar-card.js | 27 -------------- apps/stat.js | 69 ++++++++++++++--------------------- components/Data.js | 2 +- components/models/HutaoApi.js | 11 ++++++ 5 files changed, 45 insertions(+), 70 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fe100615..e4e72ee1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# 1.8.6 + +* `#上传深渊数据`命令会返回最强一击及承受伤害的排名 + * 需要有当期深渊挑战记录才会展示排名信息 + * 当前为文字展示,后期会改为图像模式 + # 1.8.5 * 支持戳一戳返回喵喵版角色卡片 diff --git a/apps/character/avatar-card.js b/apps/character/avatar-card.js index c0d392b9..19a8dc8f 100644 --- a/apps/character/avatar-card.js +++ b/apps/character/avatar-card.js @@ -143,33 +143,6 @@ async function getTalent(e, avatars) { } -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); - } -} - -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'); -} - - /* * 获取角色数据 * */ diff --git a/apps/stat.js b/apps/stat.js index d3361ec9..4ba510d8 100644 --- a/apps/stat.js +++ b/apps/stat.js @@ -397,56 +397,41 @@ export async function uploadData(e) { try { let resDetail = await MysApi.getCharacter(); let resAbyss = await MysApi.getSpiralAbyss(1); + //Data.writeJson('/test-data', 'abyss.json', resAbyss); 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 + delete resDetail._res; + delete resAbyss._res; + ret = await HutaoApi.uploadData({ + uid, + resDetail, + resAbyss }); } catch (err) { + // console.log(err); } if (ret && ret.retcode === 0) { - e.reply(`uid:${uid}本次深渊记录上传成功\n多谢支持,喵~`); + let msg = [`uid:${uid}本次深渊记录上传成功,多谢支持,喵~`]; + if (ret.data) { + let addMsg = function (title, ds) { + if (!ds && !ds.avatarId && !ds.percent) { + return; + } + let char = Character.get(ds.avatarId); + title = `${title}:${char.name} ${(ds.value / 10000).toFixed(1)}W,`; + if (ds.percent < 0.2) { + msg.push(`${title}少于${(100 - ds.percent * 100).toFixed(1)}%的用户`) + } else { + msg.push(`${title}超过${(ds.percent * 100).toFixed(1)}%的用户`) + } + } + msg.push("本次深渊排行:"); + addMsg("最强一击", ret.data.damage || {}); + addMsg("承受伤害", ret.data.takeDamage || {}); + } + e.reply(msg.join("\n")) } else { e.reply(`${ret.message || "上传失败"},请稍后重试...`); } diff --git a/components/Data.js b/components/Data.js index a26466cc..e69307eb 100644 --- a/components/Data.js +++ b/components/Data.js @@ -50,7 +50,7 @@ let Data = { } // 检查并创建目录 - Data.createDir(_path, path, true); + Data.createDir(_path, path, false); console.log(data); delete data._res; return fs.writeFileSync(`${_path}/${path}/${file}`, JSON.stringify(data, null, space)); diff --git a/components/models/HutaoApi.js b/components/models/HutaoApi.js index 1e93870d..f0c819b8 100644 --- a/components/models/HutaoApi.js +++ b/components/models/HutaoApi.js @@ -57,6 +57,17 @@ let HutaoApi = { }, body }); + }, + + async uploadData(data = {}) { + let body = JSON.stringify(data); + return await HutaoApi.req("/Record/UploadData", { + method: "POST", + headers: { + 'Content-Type': 'text/json; charset=utf-8', + }, + body + }); } };