feat(workers): 添加调试打印语句并优化GetHisMsg函数返回逻辑

This commit is contained in:
liyp 2024-08-31 19:39:19 +08:00
parent 9b2c187566
commit c8b6c5ea20
2 changed files with 15 additions and 4 deletions

View file

@ -88,6 +88,7 @@ func (a *AI) GetMsg() string {
if len(matches) > 0 { if len(matches) > 0 {
msgId = matches[1] msgId = matches[1]
println("msgId:", msgId)
} else { } else {
msgId = "" msgId = ""
log.Println("未找到回复消息") log.Println("未找到回复消息")

View file

@ -139,7 +139,12 @@ func (s *StdAns) GetHisMsg(id string) string {
} }
// fmt.Println("响应返回:", body) // 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 { func (s *StdAns) SendMsg(msg string) bool {
@ -203,8 +208,13 @@ func (s *StdAns) GetImage(file string) string {
fmt.Println("解析JSON失败:", err) fmt.Println("解析JSON失败:", err)
return "" 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
} }