!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'
},
{
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)
}

View File

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

View File

@ -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'
}

View File

@ -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

View File

@ -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

View File

@ -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 = `<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)
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 || []
@ -121,7 +126,7 @@ export default class RoleIndex extends base {
stats.exquisite_chest_number +
stats.common_chest_number +
stats.magic_chest_number) /
this.lable.all_chest) *
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,7 +451,7 @@ export default class RoleIndex extends base {
return this.roleExploreData(ret)
}
async roleExploreData (res) {
async roleExploreData(res) {
let [resIndex, basicInfo] = res
let stats = resIndex.stats
@ -457,7 +462,7 @@ export default class RoleIndex extends base {
stats.common_chest_number +
stats.magic_chest_number) *
100) /
this.lable.all_chest,
this.all_chest,
2
)
@ -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/')

View File

@ -42,7 +42,7 @@
</div>
</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>
</body>

View File

@ -120,7 +120,7 @@
</div>
</div>
</div>
<!-- <div class="logo">Created By Miao-Yunzai</div> -->
<!-- <div class="logo">Created By {{yzName}}</div> -->
</div>
</body>
<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>
</ul>
</div>
<div class="copyright">Created By Miao-Yunzai</div>
<div class="copyright">Created By {{yzName}}</div>
</div>
</body>
</html>

View File

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

View File

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

View File

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

View File

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

View File

@ -42,7 +42,7 @@
</div>
</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>
</body>

View File

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

View File

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