From 6e5db14f522c44951d1b00a8f7b69e720c4e9577 Mon Sep 17 00:00:00 2001 From: David Florness Date: Tue, 29 Mar 2022 21:45:08 -0400 Subject: [PATCH] Use mautrix helper function to remove reply text --- main.go | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/main.go b/main.go index 3604f42..e7d04d2 100644 --- a/main.go +++ b/main.go @@ -9,7 +9,6 @@ import ( "os" "regexp" "strconv" - "strings" "time" _ "github.com/mattn/go-sqlite3" @@ -156,17 +155,12 @@ func getMsgResponse(client *mautrix.Client, evt *event.Event) *event.MessageEven } func getMSCs(body string) (mscs []uint) { - lines := strings.Split(body, "\n") - for _, line := range lines { - if len(line) == 0 || line[0] == '>' { - continue - } - matches := MSC_REGEX.FindAllStringSubmatch(line, -1) - for _, match := range matches { - // error can never happen because of %d in regex - msc, _ := strconv.Atoi(match[1]) - mscs = append(mscs, uint(msc)) - } + bodyNoReplies := event.TrimReplyFallbackText(body) + matches := MSC_REGEX.FindAllStringSubmatch(bodyNoReplies, -1) + for _, match := range matches { + // error can never happen because of %d in regex + msc, _ := strconv.Atoi(match[1]) + mscs = append(mscs, uint(msc)) } return mscs } -- 2.38.4