fix: 在 blPlus 和 ssPlusN 函数中添加对排行榜为空的检查,确保用户输入有效的目标排名偏移量

This commit is contained in:
lixiangwuxian
2025-05-04 00:07:36 +08:00
parent e99e836101
commit c05f3f11bf
2 changed files with 18 additions and 0 deletions

View File

@@ -117,6 +117,15 @@ func blPlus(msg model.Message) (reply *model.Reply) {
if targetRank < 0 {
targetRank = 1
}
if len(leaderboard) == 0 {
resultStr.WriteString("\n")
resultStr.WriteString("请输入一个有效的目标排名偏移量(现在太大了)")
return &model.Reply{
ReplyMsg: resultStr.String(),
ReferOriginMsg: true,
FromMsg: msg,
}
}
for _, player := range leaderboard {
if player.CountryRank == targetRank {
targetPlayer = player