From c8b6c5ea2089a03d1141fcba24130bed4254cb0f Mon Sep 17 00:00:00 2001 From: liyp Date: Sat, 31 Aug 2024 19:39:19 +0800 Subject: [PATCH] =?UTF-8?q?feat(workers):=20=E6=B7=BB=E5=8A=A0=E8=B0=83?= =?UTF-8?q?=E8=AF=95=E6=89=93=E5=8D=B0=E8=AF=AD=E5=8F=A5=E5=B9=B6=E4=BC=98?= =?UTF-8?q?=E5=8C=96GetHisMsg=E5=87=BD=E6=95=B0=E8=BF=94=E5=9B=9E=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- workers/ai.go | 1 + workers/core.go | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/workers/ai.go b/workers/ai.go index 5ea7575..5d46d0f 100644 --- a/workers/ai.go +++ b/workers/ai.go @@ -88,6 +88,7 @@ func (a *AI) GetMsg() string { if len(matches) > 0 { msgId = matches[1] + println("msgId:", msgId) } else { msgId = "" log.Println("未找到回复消息") diff --git a/workers/core.go b/workers/core.go index d5065b9..d8a825e 100644 --- a/workers/core.go +++ b/workers/core.go @@ -139,7 +139,12 @@ func (s *StdAns) GetHisMsg(id string) string { } // fmt.Println("响应返回:", body) - return data["data"].(map[string]interface{})["raw_message"].(string) + raw_message, ok := data["data"].(map[string]interface{})["raw_message"].(string) + if !ok { + return "" + } else { + return raw_message + } } func (s *StdAns) SendMsg(msg string) bool { @@ -203,8 +208,13 @@ func (s *StdAns) GetImage(file string) string { fmt.Println("解析JSON失败:", err) return "" } - path := data["data"].(map[string]interface{})["file"].(string) + fmt.Println("url:", url) + path, ok := data["data"].(map[string]interface{})["file"].(string) + if !ok { + return "" + } else { + // fmt.Println("响应返回:", body) + return path + } - // fmt.Println("响应返回:", body) - return path }