From 12e280b38c1ed563dc557c3c69f74cf28d02bfb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E8=8A=B1=E8=8A=B1=E8=8A=B1=E5=84=BF?= <860563585bxy@gmail.com> Date: Thu, 25 Jan 2024 00:56:49 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BA=91=E5=B4=BD=E5=90=8D=E4=BB=8Epackage?= =?UTF-8?q?=E8=AF=BB=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/genshin/model/base.js | 20 +++++++++++++++---- plugins/genshin/model/exportLog.js | 13 ++++++++++-- .../html/mysNews-list/mysNews-list.html | 2 +- .../StarRail/html/mysNews/mysNews.html | 2 +- .../resources/html/admin/userAdmin.html | 2 +- plugins/genshin/resources/html/deck/deck.html | 2 +- .../resources/html/deckCard/deckCard.html | 2 +- .../resources/html/deckList/deckList.html | 2 +- .../resources/html/layout/genshin.html | 2 +- .../html/mysNews-list/mysNews-list.html | 2 +- .../resources/html/mysNews/mysNews.html | 2 +- .../genshin/resources/html/payLog/payLog.html | 2 +- 12 files changed, 37 insertions(+), 16 deletions(-) diff --git a/plugins/genshin/model/base.js b/plugins/genshin/model/base.js index adfa651..ac398a5 100644 --- a/plugins/genshin/model/base.js +++ b/plugins/genshin/model/base.js @@ -1,22 +1,23 @@ import fs from 'node:fs' import _ from 'lodash' +import cfg from '../../../lib/config/config.js' import { Common, Version } from '#miao' import { Character } from '#miao.models' export default class base { - constructor (e = {}) { + constructor(e = {}) { this.e = e this.userId = e?.user_id this.model = 'genshin' this._path = process.cwd().replace(/\\/g, '/') } - get prefix () { + get prefix() { return `Yz:genshin:${this.model}:` } // 统一封装渲染 - async renderImg (tpl, data, cfg = {}) { + async renderImg(tpl, data, cfg = {}) { return Common.render('genshin', `html/${tpl}`, data, { ...cfg, e: this.e @@ -29,12 +30,23 @@ export default class base { * @param tplFile 模板html路径 * @param pluResPath 插件资源路径 */ - get screenData () { + get screenData() { const layoutPath = process.cwd() + '/plugins/genshin/resources/html/layout/' + let yunzaiName = cfg.package.name + if (yunzaiName == 'miao-yunzai') { + yunzaiName = 'Miao-Yunzai' + } else if (yunzaiName == 'yunzai') { + yunzaiName = 'Yunzai-Bot' + } else if (yunzaiName == 'trss-yunzai') { + yunzaiName = 'TRSS-Yunzai' + } else { + yunzaiName = _.capitalize(yunzaiName) + } let data = { saveId: this.userId, cwd: this._path, yzVersion: `v${Version.yunzai}`, + yzName: yunzaiName, genshinLayout: layoutPath + 'genshin.html', defaultLayout: layoutPath + 'default.html' } diff --git a/plugins/genshin/model/exportLog.js b/plugins/genshin/model/exportLog.js index db047d6..8f49534 100644 --- a/plugins/genshin/model/exportLog.js +++ b/plugins/genshin/model/exportLog.js @@ -63,14 +63,23 @@ export default class ExportLog extends base { if (!this.uid) return false let list = this.getAllList().list - + let yunzaiName = cfg.package.name + if (yunzaiName == 'miao-yunzai') { + yunzaiName = 'Miao-Yunzai' + } else if (yunzaiName == 'yunzai') { + yunzaiName = 'Yunzai-Bot' + } else if (yunzaiName == 'trss-yunzai') { + yunzaiName = 'TRSS-Yunzai' + } else { + yunzaiName = _.capitalize(yunzaiName) + } let data = { info: { uid: this.uid, lang: list[0].lang, export_time: moment().format('YYYY-MM-DD HH:mm:ss'), export_timestamp: moment().format('X'), - export_app: 'Miao-Yunzai', + export_app: yunzaiName, export_app_version: cfg.package.version, }, list diff --git a/plugins/genshin/resources/StarRail/html/mysNews-list/mysNews-list.html b/plugins/genshin/resources/StarRail/html/mysNews-list/mysNews-list.html index 03473b2..b041c1b 100644 --- a/plugins/genshin/resources/StarRail/html/mysNews-list/mysNews-list.html +++ b/plugins/genshin/resources/StarRail/html/mysNews-list/mysNews-list.html @@ -42,7 +42,7 @@ - + diff --git a/plugins/genshin/resources/StarRail/html/mysNews/mysNews.html b/plugins/genshin/resources/StarRail/html/mysNews/mysNews.html index 6e61134..608aefb 100644 --- a/plugins/genshin/resources/StarRail/html/mysNews/mysNews.html +++ b/plugins/genshin/resources/StarRail/html/mysNews/mysNews.html @@ -120,7 +120,7 @@ - + diff --git a/plugins/genshin/resources/html/admin/userAdmin.html b/plugins/genshin/resources/html/admin/userAdmin.html index a4ef497..fe34f90 100644 --- a/plugins/genshin/resources/html/admin/userAdmin.html +++ b/plugins/genshin/resources/html/admin/userAdmin.html @@ -77,7 +77,7 @@
  • #删除无效用户: 删除当前所有请求失效的用户的CK数据,暂不会删除公共CK
  • - + diff --git a/plugins/genshin/resources/html/deck/deck.html b/plugins/genshin/resources/html/deck/deck.html index 97758ae..dd71ba0 100644 --- a/plugins/genshin/resources/html/deck/deck.html +++ b/plugins/genshin/resources/html/deck/deck.html @@ -77,7 +77,7 @@ - + diff --git a/plugins/genshin/resources/html/deckCard/deckCard.html b/plugins/genshin/resources/html/deckCard/deckCard.html index b769726..09e66d1 100644 --- a/plugins/genshin/resources/html/deckCard/deckCard.html +++ b/plugins/genshin/resources/html/deckCard/deckCard.html @@ -115,7 +115,7 @@ {{/if}} - + diff --git a/plugins/genshin/resources/html/deckList/deckList.html b/plugins/genshin/resources/html/deckList/deckList.html index d21b4a1..f077bc4 100644 --- a/plugins/genshin/resources/html/deckList/deckList.html +++ b/plugins/genshin/resources/html/deckList/deckList.html @@ -50,7 +50,7 @@ {{/each}} - + diff --git a/plugins/genshin/resources/html/layout/genshin.html b/plugins/genshin/resources/html/layout/genshin.html index 1833472..8cb510e 100644 --- a/plugins/genshin/resources/html/layout/genshin.html +++ b/plugins/genshin/resources/html/layout/genshin.html @@ -18,7 +18,7 @@
    {{block 'main'}}{{/block}} - +
    diff --git a/plugins/genshin/resources/html/mysNews-list/mysNews-list.html b/plugins/genshin/resources/html/mysNews-list/mysNews-list.html index 03473b2..b041c1b 100644 --- a/plugins/genshin/resources/html/mysNews-list/mysNews-list.html +++ b/plugins/genshin/resources/html/mysNews-list/mysNews-list.html @@ -42,7 +42,7 @@ - + diff --git a/plugins/genshin/resources/html/mysNews/mysNews.html b/plugins/genshin/resources/html/mysNews/mysNews.html index 22e3827..56d2a02 100644 --- a/plugins/genshin/resources/html/mysNews/mysNews.html +++ b/plugins/genshin/resources/html/mysNews/mysNews.html @@ -120,7 +120,7 @@ - + diff --git a/plugins/genshin/resources/html/payLog/payLog.html b/plugins/genshin/resources/html/payLog/payLog.html index 9d2db9e..153fddc 100644 --- a/plugins/genshin/resources/html/payLog/payLog.html +++ b/plugins/genshin/resources/html/payLog/payLog.html @@ -52,7 +52,7 @@
    详细统计
    - + From a5cb607c98348446d0404deb8b6393fa9695c9cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E8=8A=B1=E8=8A=B1=E8=8A=B1=E5=84=BF?= <860563585bxy@gmail.com> Date: Thu, 25 Jan 2024 12:31:37 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E8=AE=A1=E7=AE=97=E5=AE=9D=E7=AE=B1?= =?UTF-8?q?=E6=80=BB=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/genshin/defSet/role/index.yaml | 3 -- plugins/genshin/model/roleIndex.js | 63 ++++++++++++++------------ 2 files changed, 34 insertions(+), 32 deletions(-) diff --git a/plugins/genshin/defSet/role/index.yaml b/plugins/genshin/defSet/role/index.yaml index 735fedc..f29021a 100644 --- a/plugins/genshin/defSet/role/index.yaml +++ b/plugins/genshin/defSet/role/index.yaml @@ -7,9 +7,6 @@ avatar: 77 # 等级 level: 60 -# 总宝箱 -all_chest: 6044 - # 奇馈宝箱 magic_chest: 221 diff --git a/plugins/genshin/model/roleIndex.js b/plugins/genshin/model/roleIndex.js index 590edb5..7284a99 100644 --- a/plugins/genshin/model/roleIndex.js +++ b/plugins/genshin/model/roleIndex.js @@ -10,7 +10,7 @@ let dsz = '待实装' let imgFile = {} export default class RoleIndex extends base { - constructor (e) { + constructor(e) { super(e) this.model = 'roleIndex' this.other = gsCfg.getdefSet('role', 'other') @@ -29,17 +29,22 @@ export default class RoleIndex extends base { 枫丹: 9 } + this.all_chest = 0 + lodash.forEach(this.lable, (v, i) => { + if (i.includes('_chest')) this.all_chest += v + }) + this.areaName = lodash.invert(this.area) this.headIndexStyle = `` } - static async get (e) { + static async get(e) { let roleIndex = new RoleIndex(e) return await roleIndex.getIndex() } - async getIndex () { + async getIndex() { let ApiData = { index: '', spiralAbyss: { schedule_type: 1 }, @@ -63,7 +68,7 @@ export default class RoleIndex extends base { return data } - dealData (data) { + dealData(data) { let [resIndex, resAbyss, resDetail, basicInfo] = data let avatars = resDetail.avatars || [] @@ -117,11 +122,11 @@ export default class RoleIndex extends base { let percentage = lodash.round( ((stats.precious_chest_number + - stats.luxurious_chest_number + - stats.exquisite_chest_number + - stats.common_chest_number + - stats.magic_chest_number) / - this.lable.all_chest) * + stats.luxurious_chest_number + + stats.exquisite_chest_number + + stats.common_chest_number + + stats.magic_chest_number) / + this.all_chest) * 100, 1 ) @@ -150,7 +155,7 @@ export default class RoleIndex extends base { stats.exquisite_chest_number + stats.common_chest_number + stats.magic_chest_number, - extra: this.lable.all_chest + extra: this.all_chest }, { @@ -240,7 +245,7 @@ export default class RoleIndex extends base { } // 处理深渊数据 - abyssAll (roleArr, resAbyss) { + abyssAll(roleArr, resAbyss) { let abyss = {} if (roleArr.length <= 0) { @@ -327,14 +332,14 @@ export default class RoleIndex extends base { } } - dayCount (num) { + dayCount(num) { let daysDifference = Math.floor((new Date() - new Date('2020-09-15')) / (1000 * 60 * 60 * 24)) + 1 let days = Math.floor(num) let msg = '活跃天数:' + days + `/${daysDifference}天` return msg } - async roleCard () { + async roleCard() { this.model = 'roleCard' let res = await MysInfo.get(this.e, 'index') @@ -343,7 +348,7 @@ export default class RoleIndex extends base { return this.roleCardData(res.data) } - roleCardData (res) { + roleCardData(res) { this.initFile() let stats = res.stats @@ -430,7 +435,7 @@ export default class RoleIndex extends base { } } - async roleExplore () { + async roleExplore() { this.model = 'roleExplore' let ApiData = { index: '', @@ -446,18 +451,18 @@ export default class RoleIndex extends base { return this.roleExploreData(ret) } - async roleExploreData (res) { + async roleExploreData(res) { let [resIndex, basicInfo] = res let stats = resIndex.stats let percentage = lodash.round( ((stats.precious_chest_number + - stats.luxurious_chest_number + - stats.exquisite_chest_number + - stats.common_chest_number + - stats.magic_chest_number) * + stats.luxurious_chest_number + + stats.exquisite_chest_number + + stats.common_chest_number + + stats.magic_chest_number) * 100) / - this.lable.all_chest, + this.all_chest, 2 ) @@ -465,12 +470,12 @@ export default class RoleIndex extends base { percentage < 60 ? 'D' : (percentage < 70 - ? 'C' - : percentage < 80 - ? 'B' - : percentage < 90 - ? 'A' - : 'S') + `[${percentage}%]` + ? 'C' + : percentage < 80 + ? 'B' + : percentage < 90 + ? 'A' + : 'S') + `[${percentage}%]` let daysDifference = Math.floor((new Date() - new Date('2020-09-15')) / (1000 * 60 * 60 * 24)) + 1 @@ -492,7 +497,7 @@ export default class RoleIndex extends base { stats.exquisite_chest_number + stats.common_chest_number + stats.magic_chest_number, - extra: this.lable.all_chest + extra: this.all_chest }, { lable: '宝箱获取率', @@ -621,7 +626,7 @@ export default class RoleIndex extends base { } } - initFile () { + initFile() { if (imgFile['刻晴']) return imgFile let path = './plugins/genshin/resources/img/gacha/' let character = fs.readdirSync(path + 'character/') From 4bb8efabe4af2693a52fc3608995da51969231c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E8=8A=B1=E8=8A=B1=E8=8A=B1=E5=84=BF?= <860563585bxy@gmail.com> Date: Sat, 27 Jan 2024 17:53:32 +0800 Subject: [PATCH 3/3] =?UTF-8?q?add=EF=BC=9A=E6=98=9F=E7=90=BC=E9=A2=84?= =?UTF-8?q?=E4=BC=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/genshin/apps/mysNews.js | 11 +++++++---- plugins/genshin/model/mysNews.js | 20 ++++++++------------ 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/plugins/genshin/apps/mysNews.js b/plugins/genshin/apps/mysNews.js index 2570e9e..ee073bc 100644 --- a/plugins/genshin/apps/mysNews.js +++ b/plugins/genshin/apps/mysNews.js @@ -27,8 +27,8 @@ export class mysNews extends plugin { fnc: 'mysUrl' }, { - reg: '^#*原(石|神)(预估|盘点)$', - fnc: 'ysEstimate' + reg: '^#*原(石|神)|星(琼|铁)(预估|盘点)$', + fnc: 'mysEstimate' }, { reg: '^#*(星铁|原神|崩坏三|崩三|绝区零|崩坏二|崩二|崩坏学园二|未定|未定事件簿)?(开启|关闭)(公告|资讯)推送$', @@ -84,8 +84,11 @@ export class mysNews extends plugin { await this.reply(data) } - async ysEstimate() { - let data = await new MysNews(this.e).ysEstimate() + async mysEstimate() { + let args = ['版本原石', 218945821] + if (/星(琼|铁)/.test(this.e.msg)) + args = ['可获取星琼', 73779489] + let data = await new MysNews(this.e).mysEstimate(...args) if (!data) return await this.reply(data) } diff --git a/plugins/genshin/model/mysNews.js b/plugins/genshin/model/mysNews.js index 5cfe32b..04320ea 100644 --- a/plugins/genshin/model/mysNews.js +++ b/plugins/genshin/model/mysNews.js @@ -93,6 +93,9 @@ export default class MysNews extends base { case 'searchPosts': host = 'https://bbs-api.miyoushe.com/post/wapi/searchPosts?' break + case 'userInstantSearchPosts': + host = 'https://bbs-api.miyoushe.com/painter/api/user_instant/search/list?' + break // 帖子详情 case 'getPostFull': host += 'post/wapi/getPostFull?' @@ -243,21 +246,14 @@ export default class MysNews extends base { return this.replyMsg(img, `${param.data.post.subject}`) } - async ysEstimate() { - let msg = '版本原石盘点' - let res = await this.postData('searchPosts', { gids: 2, size: 20, keyword: msg }) - if (res?.data?.posts.length <= 0) { + async mysEstimate(keyword, uid) { + let res = await this.postData('userInstantSearchPosts', { keyword, uid, size: 20, offset: 0, sort_type: 2 }) + let postList = res?.data?.list + if (postList.length <= 0) { await this.e.reply('暂无数据') return false } - let postId = '' - for (let post of res.data.posts) { - if (post.user.uid == '218945821') { - postId = post.post.post_id - break - } - } - + let postId = postList[0].post.post.post_id if (!postId) { await this.e.reply('暂无数据') return false