From 2334ba5efa1dfb3a6c758c092f2f764f19027b3c Mon Sep 17 00:00:00 2001 From: boydzheng Date: Sun, 8 Mar 2026 17:42:31 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E4=B8=8A=E4=BC=A0=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E6=94=B9=E7=94=A8=E7=BB=93=E6=9E=84=E5=8C=96?= =?UTF-8?q?=E8=BE=93=E5=87=BA=E5=B9=B6=E7=BB=9F=E4=B8=80=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/channels/qq/media.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/pkg/channels/qq/media.go b/pkg/channels/qq/media.go index 68d726f8c..2cd13dffe 100644 --- a/pkg/channels/qq/media.go +++ b/pkg/channels/qq/media.go @@ -15,6 +15,7 @@ import ( "sync" "time" + "github.com/sipeed/picoclaw/pkg/logger" "github.com/tencent-connect/botgo/dto" "github.com/tencent-connect/botgo/openapi" "golang.org/x/oauth2" @@ -160,14 +161,18 @@ func (c *Client) apiRequestWithRetry(ctx context.Context, accessToken, method, p // Fast-fail on non-retriable errors if strings.Contains(errMsg, "400") || strings.Contains(errMsg, "401") || - strings.Contains(errMsg, "Invalid") || strings.Contains(errMsg, "上传超时") || + strings.Contains(errMsg, "Invalid") || strings.Contains(errMsg, "upload timeout") || strings.Contains(errMsg, "timeout") || strings.Contains(errMsg, "Timeout") { return nil, lastErr } if attempt < uploadMaxRetries { delay := time.Duration(uploadBaseDelayMs*pow(2, attempt)) * time.Millisecond - fmt.Printf("[qqbot-api] Upload attempt %d failed, retrying in %v: %s\n", attempt+1, delay, truncate(errMsg, 100)) + logger.WarnCF("qq", "Upload attempt failed, retrying", map[string]any{ + "attempt": attempt + 1, + "delay": delay.String(), + "error": truncate(errMsg, 100), + }) select { case <-time.After(delay): @@ -235,7 +240,7 @@ func (c *Client) uploadC2CMedia( if fileData != "" { contentHash := computeFileHash(fileData) if cached, ok := c.getCachedFileInfo(contentHash, "c2c", openid, fileType); ok { - fmt.Println("[qqbot-api] uploadC2CMedia: using cached file_info (skip upload)") + logger.InfoC("qq", "uploadC2CMedia: using cached file_info (skip upload)") return &UploadMediaResponse{FileInfo: cached}, nil } }