From cf2093095e769cdfac7fd83adc61d7ff6e958c0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?William=20Herg=C3=A8s?= Date: Mon, 4 Aug 2025 13:21:32 +0200 Subject: refactor(xp): use own trim function for next gokord update --- exp/functions.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'exp') diff --git a/exp/functions.go b/exp/functions.go index 119b6a8..026eb34 100644 --- a/exp/functions.go +++ b/exp/functions.go @@ -4,7 +4,9 @@ import ( "fmt" "github.com/anhgelus/gokord" "math" + "regexp" "slices" + "strings" "time" ) @@ -57,3 +59,15 @@ func TimeStampNDaysBefore(n uint) string { } return fmt.Sprintf("%d-%d-%d", y, m, d) } + +func TrimMessage(s string) string { + not := regexp.MustCompile("[^a-zA-Z0-9éèêàùûç,;:!.?]") + ping := regexp.MustCompile("<(@&?|#)[0-9]{18}>") + link := regexp.MustCompile("https?://[a-zA-Z0-9.]+[.][a-z]+.*") + + s = ping.ReplaceAllLiteralString(s, "") + s = link.ReplaceAllLiteralString(s, "") + s = not.ReplaceAllLiteralString(s, "") + + return strings.Trim(s, " ") +} -- cgit v1.2.3