all repos — paprika @ 56b0b38f6ae1a7d53905f9f0cf3cf7c9aaf6055e

go rewrite of taigabot

Refactor to use strings.Builder
Anirudh Oppiliappan x@icyphox.sh
Wed, 29 Dec 2021 17:47:50 +0530
commit

56b0b38f6ae1a7d53905f9f0cf3cf7c9aaf6055e

parent

de9cbf945776c1c92379b2eb8d837c21fa2d37bb

1 files changed, 6 insertions(+), 8 deletions(-)

jump to
M plugins/tell.goplugins/tell.go

@@ -133,16 +133,14 @@ })

// Formatted tells in a slice, for joining into a string // later. - tellsFmtd := []string{} + tellsFmtd := strings.Builder{} for _, tell := range tells { - tellsFmtd = append( - tellsFmtd, - fmt.Sprintf( - "%s sent you a message %s: %s", - tell.From, humanize.Time(tell.Time), tell.Message, - ), + s := fmt.Sprintf( + "%s sent you a message %s: %s\n", + tell.From, humanize.Time(tell.Time), tell.Message, ) + tellsFmtd.WriteString(s) } - return strings.Join(tellsFmtd, "\n"), &IsPrivateNotice{To: tells[0].To} + return tellsFmtd.String(), &IsPrivateNotice{To: tells[0].To} } }