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 }