feat: implement GenFileNameFromMessage function for improved file naming

This commit is contained in:
krau
2025-03-22 09:33:50 +08:00
parent 635f00ac71
commit 19efab0665
6 changed files with 40 additions and 12 deletions

View File

@@ -3,6 +3,7 @@ package common
import (
"crypto/md5"
"encoding/hex"
"regexp"
)
func HashString(s string) string {
@@ -10,3 +11,16 @@ func HashString(s string) string {
hash.Write([]byte(s))
return hex.EncodeToString(hash.Sum(nil))
}
var TagRe = regexp.MustCompile(`(?:^|[\p{Zs}\s.,!?(){}[\]<>\"\',。!?():;、])#([\p{L}\d_]+)`)
func ExtractTagsFromText(text string) []string {
matches := TagRe.FindAllStringSubmatch(text, -1)
tags := make([]string, 0)
for _, match := range matches {
if len(match) > 1 {
tags = append(tags, match[1])
}
}
return tags
}