2023-02-10 19:40:55 +00:00
|
|
|
|
import { Cfg, Common } from '../../components/index.js'
|
2023-02-10 21:31:41 +00:00
|
|
|
|
import { MysApi, Player, Character } from '../../models/index.js'
|
2022-08-06 22:36:05 +00:00
|
|
|
|
|
2022-08-24 01:07:06 +00:00
|
|
|
|
export async function profileStat (e) {
|
2023-02-03 15:05:43 +00:00
|
|
|
|
let isMatch = /^#(面板|喵喵|角色|武器|天赋|技能|圣遗物)练度统计?$/.test(e.original_msg || e.msg || '')
|
2023-01-31 11:34:49 +00:00
|
|
|
|
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)
|
|
|
|
|
|
2023-02-10 19:40:55 +00:00
|
|
|
|
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
|
|
|
|
})
|
|
|
|
|
|
2023-02-11 07:24:44 +00:00
|
|
|
|
if (avatarRet.length === 0) {
|
|
|
|
|
e.reply(`暂未获得#${uid}角色数据,请绑定CK或 #更新面板`)
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let talentNotice = []
|
|
|
|
|
|
|
|
|
|
if (!mys.isSelfCookie) {
|
|
|
|
|
talentNotice.push('未绑定CK,信息可能展示不完全')
|
|
|
|
|
}
|
2022-08-06 22:36:05 +00:00
|
|
|
|
|
2023-02-10 21:31:41 +00:00
|
|
|
|
let faceChar = Character.get(player.face || avatarRet[0]?.id)
|
|
|
|
|
let face = {
|
|
|
|
|
banner: faceChar.imgs?.banner,
|
|
|
|
|
face: faceChar.imgs?.face,
|
|
|
|
|
name: player.name || `#${uid}`,
|
|
|
|
|
sign: player.sign,
|
|
|
|
|
level: player.level
|
|
|
|
|
}
|
|
|
|
|
|
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,
|
2023-02-10 21:31:41 +00:00
|
|
|
|
info: player.getInfo(),
|
2023-02-11 07:24:44 +00:00
|
|
|
|
updateTime: player.getUpdateTime(),
|
|
|
|
|
isSelfCookie: e.isSelfCookie,
|
2022-09-20 19:15:22 +00:00
|
|
|
|
talentLvMap: '0,1,1,1,2,2,3,3,3,4,5'.split(','),
|
2023-02-10 21:31:41 +00:00
|
|
|
|
face,
|
2022-08-06 22:36:05 +00:00
|
|
|
|
avatars: avatarRet,
|
2022-09-20 19:15:22 +00:00
|
|
|
|
talentNotice
|
2023-02-10 19:40:55 +00:00
|
|
|
|
}, { e, scale: 1.4 })
|
2022-08-06 22:36:05 +00:00
|
|
|
|
}
|