From 9e2b6b3162c7723db1c454174a9830d5a8eb3703 Mon Sep 17 00:00:00 2001 From: lixiangwuxian Date: Sat, 10 May 2025 14:59:24 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E6=9B=BF=E6=8D=A2=20getMyBL=20?= =?UTF-8?q?=E5=87=BD=E6=95=B0=E4=B8=BA=20getMyBLPic=EF=BC=8C=E4=BB=85?= =?UTF-8?q?=E7=94=9F=E6=88=90=E5=9B=BE=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- handler/beatleader/beatleader.go | 42 ++------------------------------ 1 file changed, 2 insertions(+), 40 deletions(-) diff --git a/handler/beatleader/beatleader.go b/handler/beatleader/beatleader.go index 6f4dbd2..8e87f24 100644 --- a/handler/beatleader/beatleader.go +++ b/handler/beatleader/beatleader.go @@ -18,9 +18,9 @@ import ( ) func init() { - handler.RegisterHandler("查bl", getMyBL, constants.LEVEL_USER) + handler.RegisterHandler("查bl", getMyBLPic, constants.LEVEL_USER) handler.RegisterHelpInform("查bl", "beatleader", "查bl 查看您的最新分数") - handler.RegisterHandler("查bl图", getMyBLPic, constants.LEVEL_USER) + // handler.RegisterHandler("查bl图", getMyBLPic, constants.LEVEL_USER) // handler.RegisterHelpInform("查bl图", "beatleader", "查bl图 查看您的最新分数截图") handler.RegisterHandler("绑定bl", bindBL, constants.LEVEL_USER) handler.RegisterHelpInform("绑定bl", "beatleader", "绑定bl 绑定您的beatleader账号") @@ -167,44 +167,6 @@ func blPlus(msg model.Message) (reply *model.Reply) { } } -func getMyBL(msg model.Message) (reply *model.Reply) { - var ( - resultStr string - err error - maxRetries = 3 // 最大重试次数 - attempts = 0 - ) - - userIdStr := strconv.Itoa(int(msg.UserId)) - var data *beatleader.PlayerDataLite - var lastData *beatleader.PlayerDataLite - for attempts < maxRetries { - data, lastData, err = beatleader.BLQuery.GetScore(userIdStr) - if err == nil { - break // 成功时退出循环 - } - attempts++ - log.Printf("获取分数时出错,第 %d 次重试: %v", attempts, err) - } - - // 如果所有尝试都失败,返回适当的错误消息 - if err != nil { - resultStr = "获取您的分数时出现问题,请稍后重试。" - } - - if lastData != nil { - resultStr = data.LastDiffToString(*lastData) - } else { - resultStr = data.LastDiffToString(*data) - } - - return &model.Reply{ - ReplyMsg: resultStr, - ReferOriginMsg: true, - FromMsg: msg, - } -} - func getMyBLPic(msg model.Message) (reply *model.Reply) { var ( resultStr string