diff --git a/matrix.go b/matrix.go index b9806c1..299da37 100644 --- a/matrix.go +++ b/matrix.go @@ -188,17 +188,28 @@ func initMatrix() { }) go func() { - for range time.Tick(time.Second * 6) { + for range time.Tick(time.Second * 2) { log.Printf("Scanning for queued messages...") - for _, msg := range MatrixOut { - _, err := client.SendMessageEvent(context.Background(), id.RoomID(configuration.matrix.room_id), event.EventMessage, format.RenderMarkdown(msg.text, true, false)) + if len(MatrixOut) > 0 { + text := "" + for i, msg := range MatrixOut { + text += msg.text + if i != len(MatrixOut) { + text += "\n" + } + } + MatrixOut = []MatrixMessage{} + _, err := client.SendMessageEvent(context.Background(), + id.RoomID(configuration.matrix.room_id), + event.EventMessage, + format.RenderMarkdown(text, true, false), + ) if err != nil { log.Printf("[Matrix] ERROR : %s", err) continue } - log.Print("[Matrix] Sent queued message successfully.") + log.Print("[Matrix] Sent queued message(s) successfully.") } - MatrixOut = []MatrixMessage{} } }()