Skip to content

Commit

Permalink
Add element filter for ProfileStat.stat (#800)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZM-J authored Sep 20, 2024
1 parent b157db4 commit 3324eaa
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion apps/profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ app.reg({
name: '面板练度统计',
fn: ProfileStat.stat,
rule: /^#(星铁|原神)?(面板|喵喵)?练度统计$/,
yzRule: /^#*(我的)*(武器|角色|练度|五|四|5|4|星)+(汇总|统计|列表)(force|五|四|5|4|星)*[ |0-9]*$/,
yzRule: /^#*(我的)*(风|岩|雷|草|水|火|冰)*(武器|角色|练度|五|四|5|4|星)+(汇总|统计|列表)(force|五|四|5|4|星)*[ |0-9]*$/,
yzCheck: () => Cfg.get('profileStat', false)
},

Expand Down
29 changes: 29 additions & 0 deletions apps/profile/ProfileStat.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,35 @@ const ProfileStat = {
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())
if (now.hour() < 4) {
now = now.add(-1, 'days')
Expand Down

0 comments on commit 3324eaa

Please sign in to comment.