fix: *刷新排名 误重置原神排名问题,星铁排名伤害与面板不一致问题。新增*重置排名,*群最强xx

This commit is contained in:
Aluxes 2024-01-28 05:59:31 +08:00
parent 95049d23d9
commit eecaefabe1
5 changed files with 17 additions and 17 deletions

View File

@ -36,17 +36,17 @@ app.reg({
groupProfile: { groupProfile: {
name: '群内最强', name: '群内最强',
fn: groupRank, fn: groupRank,
rule: /^#(群|群内)?(排名|排行)?(最强|最高|最高分|最牛|第一|极限)+.+/ rule: /^#(星铁|原神)?(群|群内)?(排名|排行)?(最强|最高|最高分|最牛|第一|极限)+.+/
}, },
resetRank: { resetRank: {
name: '重置排名', name: '重置排名',
fn: resetRank, fn: resetRank,
rule: /^#(重置|重设)(.*)(排名|排行)$/ rule: /^#(星铁|原神)?(重置|重设)(.*)(排名|排行)$/
}, },
refreshRank: { refreshRank: {
name: '重置排名', name: '刷新排名',
fn: refreshRank, fn: refreshRank,
rule: /^#(星铁|原神)?(刷新|更新|重新加载)(群内|群|全部)*(排名|排行)$/ rule: /^#(星铁|原神)?(刷新|更新|重新加载)(群内|群|全部)*(排名|排行)$/
}, },
@ -60,7 +60,7 @@ app.reg({
rankList: { rankList: {
name: '面板排名榜', name: '面板排名榜',
fn: groupRank, fn: groupRank,
rule: /^#(群|群内)?.+(排名|排行)(榜)?$/ rule: /^#(星铁|原神)?(群|群内)?.+(排名|排行)(榜)?$/
}, },
artisList: { artisList: {
@ -80,7 +80,7 @@ app.reg({
talentStat: { talentStat: {
name: '天赋统计', name: '天赋统计',
fn: ProfileStat.stat, fn: ProfileStat.stat,
rule: /^#*(我的)*(今日|今天|明日|明天|周.*)?(五|四|5|4|星)?(技能|天赋)+(汇总|统计|列表)?[ |0-9]*$/, rule: /^#*(我的)*(今日|今天|明日|明天|周.*)?(五|四|5|4|星)?(技能|天赋)+(汇总|统计|列表)?[ |0-9]*$/
}, },
avatarList: { avatarList: {

View File

@ -18,7 +18,7 @@ export async function groupRank (e) {
if (!type || (!groupId && type !== 'super')) { if (!type || (!groupId && type !== 'super')) {
return false return false
} }
let mode = /(分|圣遗物|评分|ACE)/.test(msg) ? 'mark' : 'dmg' let mode = /(分|圣遗物|遗器|评分|ACE)/.test(msg) ? 'mark' : 'dmg'
mode = /(词条)/.test(msg) ? 'valid' : mode mode = /(词条)/.test(msg) ? 'valid' : mode
mode = /(双爆)/.test(msg) ? 'crit' : mode mode = /(双爆)/.test(msg) ? 'crit' : mode
let name = msg.replace(/(#|星铁|最强|最高分|第一|词条|双爆|极限|最高|最多|最牛|圣遗物|评分|群内|群|排名|排行|面板|面版|详情|榜)/g, '') let name = msg.replace(/(#|星铁|最强|最高分|第一|词条|双爆|极限|最高|最多|最牛|圣遗物|评分|群内|群|排名|排行|面板|面版|详情|榜)/g, '')
@ -81,7 +81,7 @@ export async function groupRank (e) {
if (uids.length > 0) { if (uids.length > 0) {
return renderCharRankList({ e, uids, char, mode, groupId }) return renderCharRankList({ e, uids, char, mode, groupId })
} else { } else {
if (e.isSr){ if (e.isSr) {
e.reply('暂无排名:请通过【*面板】查看角色面板以更新排名信息...') e.reply('暂无排名:请通过【*面板】查看角色面板以更新排名信息...')
} else { } else {
e.reply('暂无排名:请通过【#面板】查看角色面板以更新排名信息...') e.reply('暂无排名:请通过【#面板】查看角色面板以更新排名信息...')
@ -101,6 +101,7 @@ export async function resetRank (e) {
e.reply('只有管理员可重置排名') e.reply('只有管理员可重置排名')
return true return true
} }
let game = e.isSr ? 'sr' : 'gs'
let msg = e.original_msg || e.msg let msg = e.original_msg || e.msg
let name = msg.replace(/(#|重置|重设|排名|排行|群|群内|面板|详情|面版)/g, '').trim() let name = msg.replace(/(#|重置|重设|排名|排行|群|群内|面板|详情|面版)/g, '').trim()
let charId = '' let charId = ''
@ -114,7 +115,7 @@ export async function resetRank (e) {
charId = char.id charId = char.id
charName = char.name charName = char.name
} }
await ProfileRank.resetRank(groupId, charId) await ProfileRank.resetRank(groupId, charId, game)
e.reply(`本群${charName}排名已重置...`) e.reply(`本群${charName}排名已重置...`)
} }
@ -134,7 +135,7 @@ export async function refreshRank (e) {
} }
e.reply('面板数据刷新中,等待时间可能较长,请耐心等待...') e.reply('面板数据刷新中,等待时间可能较长,请耐心等待...')
let game = e.isSr ? 'sr' : 'gs' let game = e.isSr ? 'sr' : 'gs'
await ProfileRank.resetRank(groupId) await ProfileRank.resetRank({ groupId, game })
let uidMap = await ProfileRank.getUserUidMap(e, game) let uidMap = await ProfileRank.getUserUidMap(e, game)
let count = 0 let count = 0
for (let uid in uidMap) { for (let uid in uidMap) {
@ -206,7 +207,7 @@ async function renderCharRankList ({ e, uids, char, mode, groupId }) {
} }
title = title.length > 10 ? title.replace(/伤害$/, '') : title title = title.length > 10 ? title.replace(/伤害$/, '') : title
tmp.dmg = { tmp.dmg = {
title: title, title,
avg: Format.comma(dmg.avg, 1) avg: Format.comma(dmg.avg, 1)
} }
} }

View File

@ -81,7 +81,7 @@ class Character extends Base {
get sName () { get sName () {
let name = this.name let name = this.name
let abbr = this.abbr let abbr = this.abbr
return name.length <= 4 ? name : (abbr || name) return name.length < 4 ? name : (abbr || name)
} }
// 是否是旅行者 // 是否是旅行者

View File

@ -69,10 +69,10 @@ export default class ProfileRank {
* @param charId * @param charId
* @returns {Promise<void>} * @returns {Promise<void>}
*/ */
static async resetRank (groupId, charId = '') { static async resetRank (groupId, charId = '', game = 'gs') {
let keys = await redis.keys(`miao:rank:${groupId}:*`) let keys = await redis.keys(`miao:rank:${groupId}:*`)
for (let key of keys) { for (let key of keys) {
let charRet = /^miao:rank:\d+:(?:mark|dmg|crit|valid):(\d{8})$/.exec(key) let charRet = game === 'gs' ? /^miao:rank:\d+:(?:mark|dmg|crit|valid):(\d{8})$/.exec(key) : /^miao:rank:\d+:(?:mark|dmg|crit|valid):(\d{4})$/.exec(key)
if (charRet) { if (charRet) {
if (charId === '' || charId * 1 === charRet[1] * 1) { if (charId === '' || charId * 1 === charRet[1] * 1) {
await redis.del(key) await redis.del(key)
@ -398,7 +398,8 @@ export default class ProfileRank {
} }
} }
if (type === 'dmg' && profile.hasDmg) { if (type === 'dmg' && profile.hasDmg) {
let dmg = await profile.calcDmg({ mode: 'single' }) let enemyLv = profile.game === 'gs' ? 91 : 80
let dmg = await profile.calcDmg({ enemyLv, mode: 'single' })
if (dmg && dmg.avg) { if (dmg && dmg.avg) {
return { return {
score: dmg.avg, score: dmg.avg,
@ -408,6 +409,4 @@ export default class ProfileRank {
} }
return false return false
} }
} }

View File

@ -213,7 +213,7 @@ let ArtisMark = {
mark: Format.comma(totalMark, 1), mark: Format.comma(totalMark, 1),
_mark: artis.mark, _mark: artis.mark,
markClass: artis.markClass, markClass: artis.markClass,
...Data.getData(setData, 'sets,names,imgs'), ...Data.getData(setData, 'sets,names,imgs')
} }
if (withDetail) { if (withDetail) {
ret.charWeight = lodash.mapValues(charCfg.attrs, ds => ds.weight) ret.charWeight = lodash.mapValues(charCfg.attrs, ds => ds.weight)