refactor: 修改 GetScore 函数以返回当前和历史玩家数据,优化 getMyBL 函数中的结果处理逻辑
This commit is contained in:
@@ -174,8 +174,10 @@ func getMyBL(msg model.Message) (reply *model.Reply) {
|
||||
)
|
||||
|
||||
userIdStr := strconv.Itoa(int(msg.UserId))
|
||||
var data *beatleader.PlayerDataLite
|
||||
var lastData *beatleader.PlayerDataLite
|
||||
for attempts < maxRetries {
|
||||
resultStr, err = beatleader.BLQuery.GetScore(userIdStr)
|
||||
data, lastData, err = beatleader.BLQuery.GetScore(userIdStr)
|
||||
if err == nil {
|
||||
break // 成功时退出循环
|
||||
}
|
||||
@@ -187,6 +189,11 @@ func getMyBL(msg model.Message) (reply *model.Reply) {
|
||||
if err != nil {
|
||||
resultStr = "获取您的分数时出现问题,请稍后重试。"
|
||||
}
|
||||
if lastData != nil {
|
||||
resultStr = data.LastDiffToString(*lastData)
|
||||
} else {
|
||||
resultStr = data.ToString()
|
||||
}
|
||||
|
||||
return &model.Reply{
|
||||
ReplyMsg: resultStr,
|
||||
|
||||
Reference in New Issue
Block a user