Skip to content

Commit b2a05f1

Browse files
committed
feat: shrink repeated patterns
1 parent b32ed86 commit b2a05f1

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

chat/init.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ func AskCustom[T any](grp int64, f func(int, string) T) []T {
4747
}
4848

4949
func Sanitize(msg string) string {
50+
_, msg, _ = strings.Cut(msg, "\n")
51+
msg = strings.TrimSpace(msg)
5052
i := strings.LastIndex(msg, "】")
5153
if i > 0 {
5254
if i+len("】") >= len(msg) {
@@ -65,5 +67,5 @@ func Sanitize(msg string) string {
6567
if s, n := findRepeatedPattern(msg, 10); n > 0 {
6668
return s
6769
}
68-
return msg
70+
return strings.TrimSpace(msg)
6971
}

0 commit comments

Comments
 (0)