diff --git a/workers/ai.go b/workers/ai.go index 0394a08..27159b9 100644 --- a/workers/ai.go +++ b/workers/ai.go @@ -96,20 +96,8 @@ func (a *AI) GetMsg() string { return "未找到回复消息" } file, picUrl, fileSizeStr := a.GetHisMsg(msgId) - println("file:", file, "picUrl:", picUrl, "fileSizeStr:", fileSizeStr) - // 正则表达式匹配 file 和 file_size 的值 - // re = regexp.MustCompile(`file=([^,]+),.*file_size=(\d+)`) - // matches = re.FindStringSubmatch(message) - // var file string - // var fileSizeStr string - // if len(matches) > 2 { - // file = matches[1] - // fileSizeStr = matches[2] - // } else { - // log.Println("未找到文件信息") - // return "未找到文件信息" - // } - // 将 fileSizeStr 转换为整数 + // println("file:", file, "picUrl:", picUrl, "fileSizeStr:", fileSizeStr) + if picUrl == "" { log.Println("未找到文件信息") return "未找到文件信息" diff --git a/workers/core.go b/workers/core.go index 1a2acec..ccff9de 100644 --- a/workers/core.go +++ b/workers/core.go @@ -138,18 +138,7 @@ func (s *StdAns) GetHisMsg(id string) (string, string, string) { return "", "", "" } if data["status"] == "ok" { - // "message": [ - // { - // "type": "image", - // "data": { - // "file": "NapCatOneBot-MsgFile-2-874769998-7483754018991870377-7409536985154972756", - // "sub_type": 1, - // "file_id": "NapCatOneBot-MsgFile-2-874769998-7483754018991870377-7409536985154972756", - // "url": "https://multimedia.nt.qq.com.cn/download?appid=1407&fileid=Cgk3OTQ1MDg5ODYSFL7bvc7L2hg8RHGXJQcDvMBVdYnBGOvXAyD_CiiUi5zw_KCIA1CAvaMB&spec=0&rkey=CAQSKAB6JWENi5LMzvLUe0XM_1cgokyjgML0etpRKmPhrFq1UBxRN8XOeWQ", - // "file_size": "60395" - // } - // } - // ], + message := data["data"].(map[string]interface{})["message"].([]interface{})[0].(map[string]interface{})["data"].(map[string]interface{}) return message["file"].(string), message["url"].(string), message["file_size"].(string) } else { diff --git a/workers/pkg.go b/workers/pkg.go index 29dcb45..7be8bb6 100644 --- a/workers/pkg.go +++ b/workers/pkg.go @@ -75,7 +75,7 @@ func (a *Pkg) GetMsg() string { } var searchMap map[string]interface{} var searchResult map[string]interface{} - if len(suggestions) == 1 { + if len(suggestions) == 1 || suggestions[0] == parms[1] { searchUrl := "https://aur.archlinux.org/rpc/v5/info/" + suggestions[0] _, body, errs = request.Get(searchUrl).End() @@ -148,6 +148,8 @@ func (a *Pkg) GetMsg() string { msg += OutOfDate last_update := time.Unix(int64(searchResult["LastModified"].(float64)), 0).Format("2006-01-02 15:04:05") msg += "更新时间:" + last_update + msg += "投票:" + fmt.Sprintf("%.0f", searchResult["NumVotes"].(float64)) + "\n" + msg += "AUR 链接:https://aur.archlinux.org/packages/" + searchResult["Name"].(string) + "\n" // fmt.Println(msg) return msg