mirror of
https://github.com/krau/SaveAny-Bot.git
synced 2026-05-11 18:29:41 +08:00
feat: implement GenFileNameFromMessage function for improved file naming
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user