miao-plugin/apps/profile/ProfileStat.js

47 lines
1.2 KiB
JavaScript
Raw Normal View History

import { Cfg, Common } from '../../components/index.js'
import { MysApi, Player } from '../../models/index.js'
2022-08-06 22:36:05 +00:00
export async function profileStat (e) {
let isMatch = /^#(面板|喵喵|角色|武器|天赋|技能|圣遗物)练度统计?$/.test(e.original_msg || e.msg || '')
if (!Cfg.get('profileStat', false) && !isMatch) {
return false
2023-02-08 20:55:54 +00:00
}
2022-08-06 22:36:05 +00:00
2023-02-08 20:55:54 +00:00
// 缓存时间,单位小时
2022-08-06 22:36:05 +00:00
let msg = e.msg.replace('#', '').trim()
if (msg === '角色统计' || msg === '武器统计') {
// 暂时避让一下抽卡分析的关键词
return false
}
2023-02-10 14:01:18 +00:00
let isAvatarList = !/练度统计/.test(msg)
2023-02-08 20:55:54 +00:00
let mys = await MysApi.init(e)
if (!mys || !mys.uid) return false
const uid = mys.uid
let player = Player.create(e)
await player.refreshMysInfo()
2023-02-10 14:01:18 +00:00
let avatarRet = await player.refreshAndGetAvatarData({
rank: true,
retType: 'array',
sort: true
2022-08-06 22:36:05 +00:00
})
let talentNotice = ''
2022-08-06 22:36:05 +00:00
2023-02-10 14:01:18 +00:00
return await Common.render(isAvatarList ? 'character/avatar-list' : 'character/profile-stat', {
2022-08-06 22:36:05 +00:00
save_id: uid,
uid,
info: player.info || {},
2023-02-10 14:01:18 +00:00
isStat: !isAvatarList,
talentLvMap: '0,1,1,1,2,2,3,3,3,4,5'.split(','),
2022-08-06 22:36:05 +00:00
avatars: avatarRet,
isSelf: e.isSelf,
talentNotice
}, { e, scale: 1.4 })
2022-08-06 22:36:05 +00:00
}