fix: 在 blPlus 和 ssPlusN 函数中优化未找到目标排名玩家的提示信息,确保用户获得清晰的反馈

This commit is contained in:
lixiangwuxian 2025-05-04 23:17:39 +08:00
parent bd7d6566f7
commit 5bb07950f6
2 changed files with 24 additions and 2 deletions

View File

@ -126,19 +126,30 @@ func blPlus(msg model.Message) (reply *model.Reply) {
}
if len(leaderboard) == 0 {
resultStr.WriteString("\n")
resultStr.WriteString("请输入一个有效的目标排名偏移量(现在太大了)")
resultStr.WriteString("未找到目标排名的玩家,请尝试更小的目标排名偏移量")
return &model.Reply{
ReplyMsg: resultStr.String(),
ReferOriginMsg: true,
FromMsg: msg,
}
}
var foundTargetPlayer bool
for _, player := range leaderboard {
if player.CountryRank == targetRank {
targetPlayer = player
foundTargetPlayer = true
break
}
}
if !foundTargetPlayer {
resultStr.WriteString("\n")
resultStr.WriteString("未找到目标排名的玩家,请尝试更小的目标排名偏移量")
return &model.Reply{
ReplyMsg: resultStr.String(),
ReferOriginMsg: true,
FromMsg: msg,
}
}
resultStr.WriteString("\n")
if isPlus {
resultStr.WriteString(fmt.Sprintf("您只需要再打出%.2fpp就能超越 %s达到%s区第%d名。", targetPlayer.PP-userInfo.PP, targetPlayer.Name, userInfo.Country, targetPlayer.CountryRank))

View File

@ -124,19 +124,30 @@ func ssPlusN(msg model.Message) (reply *model.Reply) {
}
if len(leaderboard.Players) == 0 {
resultStr.WriteString("\n")
resultStr.WriteString("请输入一个有效的目标排名偏移量(现在太大了)")
resultStr.WriteString("未找到目标排名的玩家,请尝试更小的目标排名偏移量")
return &model.Reply{
ReplyMsg: resultStr.String(),
ReferOriginMsg: true,
FromMsg: msg,
}
}
var foundTargetPlayer bool
for _, player := range leaderboard.Players {
if player.CountryRank == targetRank {
targetPlayer = player
foundTargetPlayer = true
break
}
}
if !foundTargetPlayer {
resultStr.WriteString("\n")
resultStr.WriteString("未找到目标排名的玩家,请尝试更小的目标排名偏移量")
return &model.Reply{
ReplyMsg: resultStr.String(),
ReferOriginMsg: true,
FromMsg: msg,
}
}
resultStr.WriteString("\n")
if isPlus {
resultStr.WriteString(fmt.Sprintf("您只需要再打出%.2fpp就能超越%s达到%s区第%d名。", targetPlayer.PP-userInfo.PP, targetPlayer.Name, userInfo.Country, targetPlayer.CountryRank))