Skip to content

Commit

Permalink
Merge 9802144 into 7888ca3
Browse files Browse the repository at this point in the history
  • Loading branch information
Hoshinonyaruko authored Oct 13, 2024
2 parents 7888ca3 + 9802144 commit 859214c
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 9 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/cross_compile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ jobs:
go build -ldflags="-s -w" -o output/gensokyo-${{ matrix.os }}-${{ matrix.goarch }}
fi
- name: Compress executable files with UPX (except for gensokyo-android-arm64 and macOS)
- name: Compress executable files with UPX (except for gensokyo-android-arm64 and darwin)
run: |
sudo apt-get update
sudo apt-get install -y upx
Expand All @@ -109,7 +109,7 @@ jobs:
else
FILENAME="output/gensokyo-${{ matrix.os }}-${{ matrix.goarch }}"
fi
if [[ "${{ matrix.os }}" == "android" && "${{ matrix.goarch }}" == "arm64" ]] || [[ "${{ matrix.os }}" == "macos" ]]; then
if [[ "${{ matrix.os }}" == "android" && "${{ matrix.goarch }}" == "arm64" ]] || [[ "${{ matrix.os }}" == "darwin" ]]; then
echo "Skipping UPX compression for $FILENAME"
else
upx --best --lzma "$FILENAME"
Expand All @@ -126,7 +126,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Download all artifacts
uses: actions/download-artifact@v2
uses: actions/download-artifact@v3
with:
path: output

Expand Down
62 changes: 56 additions & 6 deletions handlers/message_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -571,11 +571,36 @@ func parseMessageContent(paramsMessage callapi.ParamsContent, message callapi.Ac

case "voice", "record":
fileContent, _ := segmentMap["data"].(map[string]interface{})["file"].(string)
foundItems["record"] = append(foundItems["record"], fileContent)

// 检查是否为 Base64 语音文件
if strings.HasPrefix(fileContent, "base64://") {
cleanContent := strings.TrimPrefix(fileContent, "base64://")
foundItems["base64_record"] = append(foundItems["base64_record"], cleanContent)
} else if strings.HasPrefix(fileContent, "http://") {
// HTTP 语音文件
cleanContent := strings.TrimPrefix(fileContent, "http://")
foundItems["url_record"] = append(foundItems["url_record"], cleanContent)
} else if strings.HasPrefix(fileContent, "https://") {
// HTTPS 语音文件
cleanContent := strings.TrimPrefix(fileContent, "https://")
foundItems["url_records"] = append(foundItems["url_records"], cleanContent)
} else if strings.HasPrefix(fileContent, "file://") {
// 本地文件,根据系统区分前缀
var cleanContent string
if runtime.GOOS == "windows" {
cleanContent = strings.TrimPrefix(fileContent, "file:///")
} else {
cleanContent = strings.TrimPrefix(fileContent, "file://")
}
foundItems["local_record"] = append(foundItems["local_record"], cleanContent)
} else {
// 无法识别的类型,直接存储
foundItems["unknown_record"] = append(foundItems["unknown_record"], fileContent)
}

case "at":
qqNumber, _ := segmentMap["data"].(map[string]interface{})["qq"].(string)
foundItems["at"] = append(foundItems["at"], qqNumber)
messageText += "[CQ:at,qq=" + qqNumber + "]"

case "avatar":
qqNumber, _ := segmentMap["data"].(map[string]interface{})["qq"].(string)
Expand All @@ -585,7 +610,7 @@ func parseMessageContent(paramsMessage callapi.ParamsContent, message callapi.Ac
} else {
avatarCQCode, _ = GetAvatarCQCode(paramsMessage.GroupID.(string), qqNumber)
}
foundItems["avatar"] = append(foundItems["avatar"], avatarCQCode)
messageText += avatarCQCode

case "markdown":
mdContent, ok := segmentMap["data"].(map[string]interface{})["data"]
Expand Down Expand Up @@ -678,11 +703,36 @@ func parseMessageContent(paramsMessage callapi.ParamsContent, message callapi.Ac

case "voice", "record":
fileContent, _ := message["data"].(map[string]interface{})["file"].(string)
foundItems["record"] = append(foundItems["record"], fileContent)

// 检查是否为 Base64 语音文件
if strings.HasPrefix(fileContent, "base64://") {
cleanContent := strings.TrimPrefix(fileContent, "base64://")
foundItems["base64_record"] = append(foundItems["base64_record"], cleanContent)
} else if strings.HasPrefix(fileContent, "http://") {
// HTTP 语音文件
cleanContent := strings.TrimPrefix(fileContent, "http://")
foundItems["url_record"] = append(foundItems["url_record"], cleanContent)
} else if strings.HasPrefix(fileContent, "https://") {
// HTTPS 语音文件
cleanContent := strings.TrimPrefix(fileContent, "https://")
foundItems["url_records"] = append(foundItems["url_records"], cleanContent)
} else if strings.HasPrefix(fileContent, "file://") {
// 本地文件,根据系统区分前缀
var cleanContent string
if runtime.GOOS == "windows" {
cleanContent = strings.TrimPrefix(fileContent, "file:///")
} else {
cleanContent = strings.TrimPrefix(fileContent, "file://")
}
foundItems["local_record"] = append(foundItems["local_record"], cleanContent)
} else {
// 无法识别的类型,直接存储
foundItems["unknown_record"] = append(foundItems["unknown_record"], fileContent)
}

case "at":
qqNumber, _ := message["data"].(map[string]interface{})["qq"].(string)
foundItems["at"] = append(foundItems["at"], qqNumber)
messageText += "[CQ:at,qq=" + qqNumber + "]"

case "avatar":
qqNumber, _ := message["data"].(map[string]interface{})["qq"].(string)
Expand All @@ -692,7 +742,7 @@ func parseMessageContent(paramsMessage callapi.ParamsContent, message callapi.Ac
} else {
avatarCQCode, _ = GetAvatarCQCode(paramsMessage.GroupID.(string), qqNumber)
}
foundItems["avatar"] = append(foundItems["avatar"], avatarCQCode)
messageText += avatarCQCode

case "markdown":
mdContent, ok := message["data"].(map[string]interface{})["data"]
Expand Down

0 comments on commit 859214c

Please sign in to comment.