From 578531cb13e38e549add60acfebf6efb3e513758 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=AF=BB=E6=AC=A2?= Date: Fri, 18 Apr 2025 11:28:40 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E8=87=AA=E5=8A=A8=E6=B7=BB=E5=8A=A0htt?= =?UTF-8?q?p=E5=89=8D=E7=BC=80=E5=88=B0baseUrl=E4=BB=A5=E7=A1=AE=E4=BF=9DU?= =?UTF-8?q?RL=E6=A0=BC=E5=BC=8F=E6=AD=A3=E7=A1=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/client.go b/client.go index dbc32d5..06ea81a 100644 --- a/client.go +++ b/client.go @@ -13,6 +13,7 @@ import ( "gitee.ltd/lxh/xybot/user" "github.com/go-resty/resty/v2" "slices" + "strings" ) type Client struct { @@ -43,6 +44,10 @@ func NewClient(wxId, baseUrl string, debug bool) (cli *Client, err error) { err = errors.New("baseUrl 不得为空,格式为: http://10.0.0.11:9001") return } + // 如果URL没有以http://或https://开头,自动添加http:// + if !strings.HasPrefix(baseUrl, "http://") && !strings.HasPrefix(baseUrl, "https://") { + baseUrl = "http://" + baseUrl + } // 设置一下机器人微信Id的值 core.WxId = wxId