From 50e91680bb711ef35e2975e96e41f0d7ad7afa76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=AF=BB=E6=AC=A2?= Date: Thu, 6 Jun 2024 14:18:18 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E9=80=BB=E8=BE=91=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin/plugins/command/kfc.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/plugin/plugins/command/kfc.go b/plugin/plugins/command/kfc.go index 56a111f..fa049f5 100644 --- a/plugin/plugins/command/kfc.go +++ b/plugin/plugins/command/kfc.go @@ -4,6 +4,7 @@ import ( "github.com/go-resty/resty/v2" "go-wechat/utils" "log" + "net/http" ) // KfcCrazyThursdayCmd @@ -33,8 +34,9 @@ func kfcApi1() string { res := resty.New() resp, err := res.R(). Post("https://api.jixs.cc/api/wenan-fkxqs/index.php") - if err != nil { - log.Panicf("KFC接口1文案获取失败: %s", err.Error()) + if err != nil || resp.StatusCode() != http.StatusOK { + log.Printf("KFC接口1文案获取失败: %v", err) + return "" } log.Printf("KFC接口1文案获取结果: %s", resp.String()) return resp.String() @@ -58,8 +60,9 @@ func kfcApi2() string { resp, err := res.R(). SetResult(&resData). Post("https://api.jixs.cc/api/wenan-fkxqs/index.php") - if err != nil { - log.Panicf("KFC接口2文案获取失败: %s", err.Error()) + if err != nil || resp.StatusCode() != http.StatusOK { + log.Printf("KFC接口2文案获取失败: %v", err) + return "" } log.Printf("KFC接口2文案获取结果: %s", resp.String()) if resData.Data.Msg != "" { @@ -84,8 +87,9 @@ func kfcApi3() string { resp, err := res.R(). SetResult(&resData). Post("https://api.pearktrue.cn/api/kfc") - if err != nil { - log.Panicf("KFC接口3文案获取失败: %s", err.Error()) + if err != nil || resp.StatusCode() != http.StatusOK { + log.Printf("KFC接口3文案获取失败: %v", err) + return "" } log.Printf("KFC接口3文案获取结果: %s", resp.String()) if resData.Text != "" {