From 3fbaf1a9ef650b49c1ea80521640b23bddf33c58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=AF=BB=E6=AC=A2?= Date: Wed, 17 Jul 2024 08:36:34 +0800 Subject: [PATCH] =?UTF-8?q?:fire:=20=E7=A7=BB=E9=99=A4=E7=9F=AD=E9=93=BE?= =?UTF-8?q?=E6=8E=A5=E7=94=9F=E6=88=90=E4=BB=A3=E7=A0=81=EF=BC=8C=E7=96=91?= =?UTF-8?q?=E4=BC=BC=E4=BC=9A=E5=BC=95=E8=B5=B7=E5=B0=81=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/system.go | 1 - tasks/hottop/hottop.go | 5 +---- utils/urlc.go | 37 ------------------------------------- 3 files changed, 1 insertion(+), 42 deletions(-) delete mode 100644 utils/urlc.go diff --git a/config/system.go b/config/system.go index 5a27d6ab..d9475e42 100644 --- a/config/system.go +++ b/config/system.go @@ -4,7 +4,6 @@ package config type system struct { Domain string `json:"domain" yaml:"domain"` // 域名 AlApiToken string `json:"alApiToken" yaml:"alApiToken"` // AL API Token - UrlcApiToken string `json:"urlcApiToken" yaml:"urlcApiToken"` // urlc.cn API Token NewFriendNotify newFriendNotify `json:"newFriendNotify" yaml:"newFriendNotify"` // 新好友通知 DefaultRule defaultRule `json:"defaultRule" yaml:"defaultRule"` // 默认规则 } diff --git a/tasks/hottop/hottop.go b/tasks/hottop/hottop.go index 044e36b3..6de3175a 100644 --- a/tasks/hottop/hottop.go +++ b/tasks/hottop/hottop.go @@ -75,10 +75,7 @@ func getTopData() (data []string) { } d.Channel = "百度" newDatas = append(newDatas, d) - shortUrl := utils.GenShortUrl(d.Url) - if shortUrl != "" { - data = append(data, fmt.Sprintf("标题: %s\n热度: %s\n详情: %s", d.Title, d.Hot, shortUrl)) - } + data = append(data, fmt.Sprintf("标题: %s\n热度: %s\n详情: %s", d.Title, d.Hot, d.Url)) } // 保存新数据到数据库 if len(newDatas) > 0 { diff --git a/utils/urlc.go b/utils/urlc.go deleted file mode 100644 index cc578f63..00000000 --- a/utils/urlc.go +++ /dev/null @@ -1,37 +0,0 @@ -package utils - -import ( - "encoding/json" - "github.com/go-resty/resty/v2" - "go-wechat/config" - "go-wechat/model/dto" - "log" -) - -// GenShortUrl -// @description: 生成短链接 -// @param url -// @return shortUrl -func GenShortUrl(url string) (shortUrl string) { - // 组装参数 - param := map[string]any{ - "url": url, - } - pbs, _ := json.Marshal(param) - - var respData dto.ShortUrlResponse - res := resty.New() - resp, err := res.R(). - SetHeader("Content-Type", "application/json;chartset=utf-8"). - SetAuthScheme("Token"). - SetAuthToken(config.Conf.System.UrlcApiToken). - SetBody(string(pbs)). - Post("https://www.urlc.cn/api/url/add") - if err != nil { - log.Printf("短链接获取失败: %s", err.Error()) - return - } - log.Printf("短链接获取结果: %s", resp.String()) - _ = json.Unmarshal(resp.Body(), &respData) - return respData.Short -}