diff --git a/README.md b/README.md index f11f1d6..cc0d2e0 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,9 @@ [![release](https://github.com/oneclickvirt/ecs/actions/workflows/main.yaml/badge.svg)](https://github.com/oneclickvirt/ecs/actions/workflows/main.yaml) [![Hits](https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.com%2Foneclickvirt%2Fecs&count_bg=%2357DEFF&title_bg=%23000000&icon=cliqz.svg&icon_color=%23E7E7E7&title=hits&edge_flat=false)](https://www.spiritlhl.net/) -融合怪测评脚本 - GO 重构版本 -由于未正式发版,如有问题请 [issues](https://github.com/oneclickvirt/ecs/issues) 反馈。 +融合怪测评项目 - GO 重构版本 + +如有问题请 [issues](https://github.com/oneclickvirt/ecs/issues) 反馈。 Go 版本:[https://github.com/oneclickvirt/ecs](https://github.com/oneclickvirt/ecs) diff --git a/README_EN.md b/README_EN.md index 4f1c2a0..5b9aa41 100644 --- a/README_EN.md +++ b/README_EN.md @@ -2,7 +2,9 @@ [![release](https://github.com/oneclickvirt/ecs/actions/workflows/main.yaml/badge.svg)](https://github.com/oneclickvirt/ecs/actions/workflows/main.yaml) [![Hits](https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.com%2Foneclickvirt%2Fecs&count_bg=%2357DEFF&title_bg=%23000000&icon=cliqz.svg&icon_color=%23E7E7E7&title=hits&edge_flat=false)](https://www.spiritlhl.net/) -Fusion Monster Evaluation Script - GO Refactored Version - Since it has not been officially released, please report any issues via issues. +Fusion Monster Evaluation Script - GO Refactored Version + +Please report any issues via issues. Go version:[https://github.com/oneclickvirt/ecs](https://github.com/oneclickvirt/ecs) diff --git a/goecs.go b/goecs.go index b8da516..5b55b77 100644 --- a/goecs.go +++ b/goecs.go @@ -39,7 +39,7 @@ import ( ) var ( - ecsVersion = "v0.0.89" + ecsVersion = "v0.1.01" menuMode bool onlyChinaTest bool input, choice string diff --git a/utils/utils.go b/utils/utils.go index 69350f5..edb3e1b 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -245,8 +245,8 @@ func PrintAndCapture(f func(), tempOutput, output string) string { // UploadText 上传文本内容到指定URL func UploadText(absPath string) (string, string, error) { - primaryURL := "http://hpaste.spiritlhl.net/api/upload" - backupURL := "https://paste.spiritlhl.net/api/upload" + primaryURL := "http://hpaste.spiritlhl.net/api/UL/upload" + backupURL := "https://paste.spiritlhl.net/api/UL/upload" token := network.SecurityUploadToken client := req.C().SetTimeout(6 * time.Second) client.R(). @@ -259,47 +259,42 @@ func UploadText(absPath string) (string, string, error) { } defer file.Close() upload := func(url string) (string, string, error) { - // 重新打开文件,以确保我们总是从文件开头读取 file, err := os.Open(absPath) if err != nil { return "", "", fmt.Errorf("failed to re-open file for %s: %w", url, err) } defer file.Close() - - // 读取文件内容 content, err := io.ReadAll(file) if err != nil { return "", "", fmt.Errorf("failed to read file content for %s: %w", url, err) } resp, err := client.R(). SetHeader("Authorization", token). - SetHeader("Format", "RANDOM"). - SetHeader("Max-Views", "0"). - SetHeader("UploadText", "true"). - SetHeader("Content-Type", "multipart/form-data"). - SetHeader("No-JSON", "true"). - SetFileBytes("file", "goecs.txt", content). + SetFileBytes("file", filepath.Base(absPath), content). Post(url) if err != nil { return "", "", fmt.Errorf("failed to make request to %s: %w", url, err) } - if resp.StatusCode >= 200 && resp.StatusCode <= 299 { - http_url := strings.ReplaceAll(resp.String(), "https://paste.spiritlhl.net/", "http://hpaste.spiritlhl.net/") - https_url := strings.ReplaceAll(resp.String(), "http://hpaste.spiritlhl.net/", "https://paste.spiritlhl.net/") - return http_url, https_url, nil - } else { - return "", "", fmt.Errorf("upload failed for %s with status code: %d", url, resp.StatusCode) + if resp.StatusCode >= 200 && resp.StatusCode <= 299 && resp.String() != "" { + fileID := strings.TrimSpace(resp.String()) + if strings.Contains(fileID, "show") { + fileID = fileID[strings.LastIndex(fileID, "/")+1:] + } + httpURL := fmt.Sprintf("http://hpaste.spiritlhl.net/#/show/%s", fileID) + httpsURL := fmt.Sprintf("https://paste.spiritlhl.net/#/show/%s", fileID) + return httpURL, httpsURL, nil } + return "", "", fmt.Errorf("upload failed for %s with status code: %d", url, resp.StatusCode) } - http_url, https_url, err := upload(primaryURL) + httpURL, httpsURL, err := upload(primaryURL) if err == nil { - return http_url, https_url, nil + return httpURL, httpsURL, nil } - http_url, https_url, err = upload(backupURL) + httpURL, httpsURL, err = upload(backupURL) if err != nil { return "", "", fmt.Errorf("failed to upload to both primary and backup URLs: %w", err) } - return http_url, https_url, nil + return httpURL, httpsURL, nil } // ProcessAndUpload 创建结果文件并上传文件