Add element filter for ProfileStat.stat (#800)

This commit is contained in:
ZM.J 2024-09-20 19:10:25 +08:00 committed by GitHub
parent b157db4b28
commit 3324eaa436
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 30 additions and 1 deletions

View File

@ -73,7 +73,7 @@ app.reg({
name: '面板练度统计', name: '面板练度统计',
fn: ProfileStat.stat, fn: ProfileStat.stat,
rule: /^#(星铁|原神)?(面板|喵喵)?练度统计$/, rule: /^#(星铁|原神)?(面板|喵喵)?练度统计$/,
yzRule: /^#*(我的)*(武器|角色|练度|五|四|5|4|星)+(汇总|统计|列表)(force|五|四|5|4|星)*[ |0-9]*$/, yzRule: /^#*(我的)*(风|岩|雷|草|水|火|冰)*(武器|角色|练度|五|四|5|4|星)+(汇总|统计|列表)(force|五|四|5|4|星)*[ |0-9]*$/,
yzCheck: () => Cfg.get('profileStat', false) yzCheck: () => Cfg.get('profileStat', false)
}, },

View File

@ -78,6 +78,35 @@ const ProfileStat = {
avatarRet = lodash.filter(avatarRet, ds => ds.star === starFilter) avatarRet = lodash.filter(avatarRet, ds => ds.star === starFilter)
} }
// elementFilter: 检测是否有元素筛选
let elementFilter = []
let chineseToEnglishElements = {}
if (e.isSr) {
// 先给星铁的元素筛选留空
} else {
chineseToEnglishElements = {
'风': 'anemo',
'岩': 'geo',
'雷': 'electro',
'草': 'dendro',
'水': 'hydro',
'火': 'pyro',
'冰': 'cryo'
}
}
for (let [k, v] of Object.entries(chineseToEnglishElements)) {
// 如果后续需支持星铁,这里可能也要用到正则判断
// e.g. 物(理)? 量(子)? 虚(数)?
if (msg.includes(k)) {
elementFilter.push(v)
}
}
if (elementFilter.length > 0) {
avatarRet = lodash.filter(avatarRet, ds =>
elementFilter.some(elem => ds.elem.includes(elem))
)
}
let now = moment(new Date()) let now = moment(new Date())
if (now.hour() < 4) { if (now.hour() < 4) {
now = now.add(-1, 'days') now = now.add(-1, 'days')