Skip to content

Commit 3a6aa14

Browse files
luqmanarifinazaky
authored andcommitted
Fix excess newline in split messages (#2)
* fix newline in new message * fix spacing * fix indent * fix as what zaky wrote literally
1 parent ed68c6a commit 3a6aa14

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

bot/common.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@ func generateUpcomingContestsMessage(clistService *clist.Service, startFrom, sta
2121
buffer.WriteString("\n")
2222
var res []string
2323
for _, contest := range contests {
24-
str := fmt.Sprintf("\n- %s. Starts at %s. Link: %s", contest.Name, contest.StartDate.In(tz).Format("Jan 2 15:04 MST"), contest.Link)
25-
if buffer.Len()+len(str) > limit {
24+
str := fmt.Sprintf("- %s. Starts at %s. Link: %s", contest.Name, contest.StartDate.In(tz).Format("Jan 2 15:04 MST"), contest.Link)
25+
if buffer.Len()+len(str)+1 > limit {
2626
res = append(res, buffer.String())
2727
buffer = *bytes.NewBufferString(str)
2828
} else {
29+
buffer.WriteString("\n")
2930
buffer.WriteString(str)
3031
}
3132
}

0 commit comments

Comments
 (0)