all repos — paprika @ 71cfeda6d9cd5ffdbf819ae6f6862f1a02b2f82d

go rewrite of taigabot

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

71cfeda6d9cd5ffdbf819ae6f6862f1a02b2f82d

parent

f3575d038b3da006531180a877148dfe3895c4ff

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} } }