Compare commits

..

1 Commits

Author SHA1 Message Date
spiritlhl
920054c844 v0.1.01 更新上传分享的地址 2025-01-02 14:04:11 +08:00
4 changed files with 23 additions and 25 deletions

View File

@@ -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/) [![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 重构版本 融合怪测评项目 - GO 重构版本
由于未正式发版,如有问题请 [issues](https://github.com/oneclickvirt/ecs/issues) 反馈。
如有问题请 [issues](https://github.com/oneclickvirt/ecs/issues) 反馈。
Go 版本:[https://github.com/oneclickvirt/ecs](https://github.com/oneclickvirt/ecs) Go 版本:[https://github.com/oneclickvirt/ecs](https://github.com/oneclickvirt/ecs)

View File

@@ -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/) [![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) Go version[https://github.com/oneclickvirt/ecs](https://github.com/oneclickvirt/ecs)

View File

@@ -39,7 +39,7 @@ import (
) )
var ( var (
ecsVersion = "v0.0.89" ecsVersion = "v0.1.01"
menuMode bool menuMode bool
onlyChinaTest bool onlyChinaTest bool
input, choice string input, choice string

View File

@@ -245,8 +245,8 @@ func PrintAndCapture(f func(), tempOutput, output string) string {
// UploadText 上传文本内容到指定URL // UploadText 上传文本内容到指定URL
func UploadText(absPath string) (string, string, error) { func UploadText(absPath string) (string, string, error) {
primaryURL := "http://hpaste.spiritlhl.net/api/upload" primaryURL := "http://hpaste.spiritlhl.net/api/UL/upload"
backupURL := "https://paste.spiritlhl.net/api/upload" backupURL := "https://paste.spiritlhl.net/api/UL/upload"
token := network.SecurityUploadToken token := network.SecurityUploadToken
client := req.C().SetTimeout(6 * time.Second) client := req.C().SetTimeout(6 * time.Second)
client.R(). client.R().
@@ -259,47 +259,42 @@ func UploadText(absPath string) (string, string, error) {
} }
defer file.Close() defer file.Close()
upload := func(url string) (string, string, error) { upload := func(url string) (string, string, error) {
// 重新打开文件,以确保我们总是从文件开头读取
file, err := os.Open(absPath) file, err := os.Open(absPath)
if err != nil { if err != nil {
return "", "", fmt.Errorf("failed to re-open file for %s: %w", url, err) return "", "", fmt.Errorf("failed to re-open file for %s: %w", url, err)
} }
defer file.Close() defer file.Close()
// 读取文件内容
content, err := io.ReadAll(file) content, err := io.ReadAll(file)
if err != nil { if err != nil {
return "", "", fmt.Errorf("failed to read file content for %s: %w", url, err) return "", "", fmt.Errorf("failed to read file content for %s: %w", url, err)
} }
resp, err := client.R(). resp, err := client.R().
SetHeader("Authorization", token). SetHeader("Authorization", token).
SetHeader("Format", "RANDOM"). SetFileBytes("file", filepath.Base(absPath), content).
SetHeader("Max-Views", "0").
SetHeader("UploadText", "true").
SetHeader("Content-Type", "multipart/form-data").
SetHeader("No-JSON", "true").
SetFileBytes("file", "goecs.txt", content).
Post(url) Post(url)
if err != nil { if err != nil {
return "", "", fmt.Errorf("failed to make request to %s: %w", url, err) return "", "", fmt.Errorf("failed to make request to %s: %w", url, err)
} }
if resp.StatusCode >= 200 && resp.StatusCode <= 299 { if resp.StatusCode >= 200 && resp.StatusCode <= 299 && resp.String() != "" {
http_url := strings.ReplaceAll(resp.String(), "https://paste.spiritlhl.net/", "http://hpaste.spiritlhl.net/") fileID := strings.TrimSpace(resp.String())
https_url := strings.ReplaceAll(resp.String(), "http://hpaste.spiritlhl.net/", "https://paste.spiritlhl.net/") if strings.Contains(fileID, "show") {
return http_url, https_url, nil fileID = fileID[strings.LastIndex(fileID, "/")+1:]
} else { }
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) return "", "", fmt.Errorf("upload failed for %s with status code: %d", url, resp.StatusCode)
} }
} httpURL, httpsURL, err := upload(primaryURL)
http_url, https_url, err := upload(primaryURL)
if err == nil { 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 { if err != nil {
return "", "", fmt.Errorf("failed to upload to both primary and backup URLs: %w", err) 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 创建结果文件并上传文件 // ProcessAndUpload 创建结果文件并上传文件