!142 云崽名从package读取&计算宝箱总数&add:星琼预估

Merge pull request !142 from 小花花花儿/master
This commit is contained in:
Kokomi 2024-01-30 20:06:59 +00:00 committed by Gitee
commit 4cc582cc40
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
16 changed files with 86 additions and 64 deletions

View File

@ -27,8 +27,8 @@ export class mysNews extends plugin {
fnc: 'mysUrl' fnc: 'mysUrl'
}, },
{ {
reg: '^#*原(石|神)(预估|盘点)$', reg: '^#*原(石|神)|星(琼|铁)(预估|盘点)$',
fnc: 'ysEstimate' fnc: 'mysEstimate'
}, },
{ {
reg: '^#*(星铁|原神|崩坏三|崩三|绝区零|崩坏二|崩二|崩坏学园二|未定|未定事件簿)?(开启|关闭)(公告|资讯)推送$', reg: '^#*(星铁|原神|崩坏三|崩三|绝区零|崩坏二|崩二|崩坏学园二|未定|未定事件簿)?(开启|关闭)(公告|资讯)推送$',
@ -84,8 +84,11 @@ export class mysNews extends plugin {
await this.reply(data) await this.reply(data)
} }
async ysEstimate() { async mysEstimate() {
let data = await new MysNews(this.e).ysEstimate() let args = ['版本原石', 218945821]
if (/星(琼|铁)/.test(this.e.msg))
args = ['可获取星琼', 73779489]
let data = await new MysNews(this.e).mysEstimate(...args)
if (!data) return if (!data) return
await this.reply(data) await this.reply(data)
} }

View File

@ -7,9 +7,6 @@ avatar: 79
# 等级 # 等级
level: 60 level: 60
# 总宝箱
all_chest: 6044
# 奇馈宝箱 # 奇馈宝箱
magic_chest: 221 magic_chest: 221

View File

@ -1,22 +1,23 @@
import fs from 'node:fs' import fs from 'node:fs'
import _ from 'lodash' import _ from 'lodash'
import cfg from '../../../lib/config/config.js'
import { Common, Version } from '#miao' import { Common, Version } from '#miao'
import { Character } from '#miao.models' import { Character } from '#miao.models'
export default class base { export default class base {
constructor (e = {}) { constructor(e = {}) {
this.e = e this.e = e
this.userId = e?.user_id this.userId = e?.user_id
this.model = 'genshin' this.model = 'genshin'
this._path = process.cwd().replace(/\\/g, '/') this._path = process.cwd().replace(/\\/g, '/')
} }
get prefix () { get prefix() {
return `Yz:genshin:${this.model}:` return `Yz:genshin:${this.model}:`
} }
// 统一封装渲染 // 统一封装渲染
async renderImg (tpl, data, cfg = {}) { async renderImg(tpl, data, cfg = {}) {
return Common.render('genshin', `html/${tpl}`, data, { return Common.render('genshin', `html/${tpl}`, data, {
...cfg, ...cfg,
e: this.e e: this.e
@ -29,12 +30,23 @@ export default class base {
* @param tplFile 模板html路径 * @param tplFile 模板html路径
* @param pluResPath 插件资源路径 * @param pluResPath 插件资源路径
*/ */
get screenData () { get screenData() {
const layoutPath = process.cwd() + '/plugins/genshin/resources/html/layout/' 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 = { let data = {
saveId: this.userId, saveId: this.userId,
cwd: this._path, cwd: this._path,
yzVersion: `v${Version.yunzai}`, yzVersion: `v${Version.yunzai}`,
yzName: yunzaiName,
genshinLayout: layoutPath + 'genshin.html', genshinLayout: layoutPath + 'genshin.html',
defaultLayout: layoutPath + 'default.html' defaultLayout: layoutPath + 'default.html'
} }

View File

@ -63,14 +63,23 @@ export default class ExportLog extends base {
if (!this.uid) return false if (!this.uid) return false
let list = this.getAllList().list 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 = { let data = {
info: { info: {
uid: this.uid, uid: this.uid,
lang: list[0].lang, lang: list[0].lang,
export_time: moment().format('YYYY-MM-DD HH:mm:ss'), export_time: moment().format('YYYY-MM-DD HH:mm:ss'),
export_timestamp: moment().format('X'), export_timestamp: moment().format('X'),
export_app: 'Miao-Yunzai', export_app: yunzaiName,
export_app_version: cfg.package.version, export_app_version: cfg.package.version,
}, },
list list

View File

@ -93,6 +93,9 @@ export default class MysNews extends base {
case 'searchPosts': case 'searchPosts':
host = 'https://bbs-api.miyoushe.com/post/wapi/searchPosts?' host = 'https://bbs-api.miyoushe.com/post/wapi/searchPosts?'
break break
case 'userInstantSearchPosts':
host = 'https://bbs-api.miyoushe.com/painter/api/user_instant/search/list?'
break
// 帖子详情 // 帖子详情
case 'getPostFull': case 'getPostFull':
host += 'post/wapi/getPostFull?' host += 'post/wapi/getPostFull?'
@ -243,21 +246,14 @@ export default class MysNews extends base {
return this.replyMsg(img, `${param.data.post.subject}`) return this.replyMsg(img, `${param.data.post.subject}`)
} }
async ysEstimate() { async mysEstimate(keyword, uid) {
let msg = '版本原石盘点' let res = await this.postData('userInstantSearchPosts', { keyword, uid, size: 20, offset: 0, sort_type: 2 })
let res = await this.postData('searchPosts', { gids: 2, size: 20, keyword: msg }) let postList = res?.data?.list
if (res?.data?.posts.length <= 0) { if (postList.length <= 0) {
await this.e.reply('暂无数据') await this.e.reply('暂无数据')
return false return false
} }
let postId = '' let postId = postList[0].post.post.post_id
for (let post of res.data.posts) {
if (post.user.uid == '218945821') {
postId = post.post.post_id
break
}
}
if (!postId) { if (!postId) {
await this.e.reply('暂无数据') await this.e.reply('暂无数据')
return false return false

View File

@ -10,7 +10,7 @@ let dsz = '待实装'
let imgFile = {} let imgFile = {}
export default class RoleIndex extends base { export default class RoleIndex extends base {
constructor (e) { constructor(e) {
super(e) super(e)
this.model = 'roleIndex' this.model = 'roleIndex'
this.other = gsCfg.getdefSet('role', 'other') this.other = gsCfg.getdefSet('role', 'other')
@ -29,17 +29,22 @@ export default class RoleIndex extends base {
枫丹: 9 枫丹: 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.areaName = lodash.invert(this.area)
this.headIndexStyle = `<style> .head_box { background: url(${this.screenData.pluResPath}img/roleIndex/namecard/${lodash.random(1, 8)}.png) #f5f5f5; background-position-x: 30px; background-repeat: no-repeat; border-radius: 15px; font-family: tttgbnumber; padding: 10px 20px; position: relative; background-size: auto 101%; }</style>` this.headIndexStyle = `<style> .head_box { background: url(${this.screenData.pluResPath}img/roleIndex/namecard/${lodash.random(1, 8)}.png) #f5f5f5; background-position-x: 30px; background-repeat: no-repeat; border-radius: 15px; font-family: tttgbnumber; padding: 10px 20px; position: relative; background-size: auto 101%; }</style>`
} }
static async get (e) { static async get(e) {
let roleIndex = new RoleIndex(e) let roleIndex = new RoleIndex(e)
return await roleIndex.getIndex() return await roleIndex.getIndex()
} }
async getIndex () { async getIndex() {
let ApiData = { let ApiData = {
index: '', index: '',
spiralAbyss: { schedule_type: 1 }, spiralAbyss: { schedule_type: 1 },
@ -63,7 +68,7 @@ export default class RoleIndex extends base {
return data return data
} }
dealData (data) { dealData(data) {
let [resIndex, resAbyss, resDetail, basicInfo] = data let [resIndex, resAbyss, resDetail, basicInfo] = data
let avatars = resDetail.avatars || [] let avatars = resDetail.avatars || []
@ -117,11 +122,11 @@ export default class RoleIndex extends base {
let percentage = lodash.round( let percentage = lodash.round(
((stats.precious_chest_number + ((stats.precious_chest_number +
stats.luxurious_chest_number + stats.luxurious_chest_number +
stats.exquisite_chest_number + stats.exquisite_chest_number +
stats.common_chest_number + stats.common_chest_number +
stats.magic_chest_number) / stats.magic_chest_number) /
this.lable.all_chest) * this.all_chest) *
100, 100,
1 1
) )
@ -150,7 +155,7 @@ export default class RoleIndex extends base {
stats.exquisite_chest_number + stats.exquisite_chest_number +
stats.common_chest_number + stats.common_chest_number +
stats.magic_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 = {} let abyss = {}
if (roleArr.length <= 0) { 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 daysDifference = Math.floor((new Date() - new Date('2020-09-15')) / (1000 * 60 * 60 * 24)) + 1
let days = Math.floor(num) let days = Math.floor(num)
let msg = '活跃天数:' + days + `/${daysDifference}` let msg = '活跃天数:' + days + `/${daysDifference}`
return msg return msg
} }
async roleCard () { async roleCard() {
this.model = 'roleCard' this.model = 'roleCard'
let res = await MysInfo.get(this.e, 'index') let res = await MysInfo.get(this.e, 'index')
@ -343,7 +348,7 @@ export default class RoleIndex extends base {
return this.roleCardData(res.data) return this.roleCardData(res.data)
} }
roleCardData (res) { roleCardData(res) {
this.initFile() this.initFile()
let stats = res.stats let stats = res.stats
@ -430,7 +435,7 @@ export default class RoleIndex extends base {
} }
} }
async roleExplore () { async roleExplore() {
this.model = 'roleExplore' this.model = 'roleExplore'
let ApiData = { let ApiData = {
index: '', index: '',
@ -446,18 +451,18 @@ export default class RoleIndex extends base {
return this.roleExploreData(ret) return this.roleExploreData(ret)
} }
async roleExploreData (res) { async roleExploreData(res) {
let [resIndex, basicInfo] = res let [resIndex, basicInfo] = res
let stats = resIndex.stats let stats = resIndex.stats
let percentage = lodash.round( let percentage = lodash.round(
((stats.precious_chest_number + ((stats.precious_chest_number +
stats.luxurious_chest_number + stats.luxurious_chest_number +
stats.exquisite_chest_number + stats.exquisite_chest_number +
stats.common_chest_number + stats.common_chest_number +
stats.magic_chest_number) * stats.magic_chest_number) *
100) / 100) /
this.lable.all_chest, this.all_chest,
2 2
) )
@ -465,12 +470,12 @@ export default class RoleIndex extends base {
percentage < 60 percentage < 60
? 'D' ? 'D'
: (percentage < 70 : (percentage < 70
? 'C' ? 'C'
: percentage < 80 : percentage < 80
? 'B' ? 'B'
: percentage < 90 : percentage < 90
? 'A' ? 'A'
: 'S') + `[${percentage}%]` : 'S') + `[${percentage}%]`
let daysDifference = Math.floor((new Date() - new Date('2020-09-15')) / (1000 * 60 * 60 * 24)) + 1 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.exquisite_chest_number +
stats.common_chest_number + stats.common_chest_number +
stats.magic_chest_number, stats.magic_chest_number,
extra: this.lable.all_chest extra: this.all_chest
}, },
{ {
lable: '宝箱获取率', lable: '宝箱获取率',
@ -621,7 +626,7 @@ export default class RoleIndex extends base {
} }
} }
initFile () { initFile() {
if (imgFile['刻晴']) return imgFile if (imgFile['刻晴']) return imgFile
let path = './plugins/genshin/resources/img/gacha/' let path = './plugins/genshin/resources/img/gacha/'
let character = fs.readdirSync(path + 'character/') let character = fs.readdirSync(path + 'character/')

View File

@ -42,7 +42,7 @@
</div> </div>
</div> </div>
<div class="logo">详情内容使用【#{{game}}{{typeName}}】加上序号查看,如【#{{game}}{{typeName}}2】</div> <div class="logo">详情内容使用【#{{game}}{{typeName}}】加上序号查看,如【#{{game}}{{typeName}}2】</div>
<div class="logo">Created By Miao-Yunzai</div> <div class="logo">Created By {{yzName}}</div>
</div> </div>
</div> </div>
</body> </body>

View File

@ -120,7 +120,7 @@
</div> </div>
</div> </div>
</div> </div>
<!-- <div class="logo">Created By Miao-Yunzai</div> --> <!-- <div class="logo">Created By {{yzName}}</div> -->
</div> </div>
</body> </body>
<script type="text/javascript" src="{{pluResPath.replace('StarRail/', '')}}script/qrcode.min.js"></script> <script type="text/javascript" src="{{pluResPath.replace('StarRail/', '')}}script/qrcode.min.js"></script>

View File

@ -77,7 +77,7 @@
<li><span>#删除无效用户</span>: 删除当前所有请求失效的用户的CK数据暂不会删除公共CK</li> <li><span>#删除无效用户</span>: 删除当前所有请求失效的用户的CK数据暂不会删除公共CK</li>
</ul> </ul>
</div> </div>
<div class="copyright">Created By Miao-Yunzai</div> <div class="copyright">Created By {{yzName}}</div>
</div> </div>
</body> </body>
</html> </html>

View File

@ -77,7 +77,7 @@
</div> </div>
</div> </div>
<div class="logo">Created By Miao-Yunzai</div> <div class="logo">Created By {{yzName}}</div>
</div> </div>
</body> </body>

View File

@ -115,7 +115,7 @@
<div class="logo">左下角为使用次数,仅展示已有行动牌</div> <div class="logo">左下角为使用次数,仅展示已有行动牌</div>
</div> </div>
{{/if}} {{/if}}
<div class="logo">Created By Miao-Yunzai</div> <div class="logo">Created By {{yzName}}</div>
</div> </div>
</body> </body>

View File

@ -50,7 +50,7 @@
</div> </div>
</div> </div>
{{/each}} {{/each}}
<div class="logo">Created By Miao-Yunzai</div> <div class="logo">Created By {{yzName}}</div>
</div> </div>
</body> </body>

View File

@ -18,7 +18,7 @@
<body class="body_box"> <body class="body_box">
<div class="container" id="container"> <div class="container" id="container">
{{block 'main'}}{{/block}} {{block 'main'}}{{/block}}
<div class="logo">Created By Miao-Yunzai {{yzVersion}}</div> <div class="logo">Created By {{yzName}} {{yzVersion}}</div>
</div> </div>
</body> </body>
</html> </html>

View File

@ -42,7 +42,7 @@
</div> </div>
</div> </div>
<div class="logo">详情内容使用【#{{game}}{{typeName}}】加上序号查看,如【#{{game}}{{typeName}}2】</div> <div class="logo">详情内容使用【#{{game}}{{typeName}}】加上序号查看,如【#{{game}}{{typeName}}2】</div>
<div class="logo">Created By Miao-Yunzai</div> <div class="logo">Created By {{yzName}}</div>
</div> </div>
</div> </div>
</body> </body>

View File

@ -120,7 +120,7 @@
</div> </div>
</div> </div>
</div> </div>
<!-- <div class="logo">Created By Miao-Yunzai</div> --> <!-- <div class="logo">Created By {{yzName}}</div> -->
</div> </div>
</body> </body>
<script type="text/javascript" src="{{pluResPath}}script/qrcode.min.js"></script> <script type="text/javascript" src="{{pluResPath}}script/qrcode.min.js"></script>

View File

@ -52,7 +52,7 @@
<div class="tab_lable">详细统计</div> <div class="tab_lable">详细统计</div>
<div id="chartContainer2"></div> <div id="chartContainer2"></div>
</div> </div>
<div class="logo">Created By Miao-Yunzai & seven-plugin</div> <div class="logo">Created By {{yzName}} & seven-plugin</div>
</div> </div>
</body> </body>