Added notification when there are no entries
parent
449dfeca8c
commit
6ba78dddcc
|
@ -4,6 +4,7 @@ import (
|
|||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"log"
|
||||
"time"
|
||||
|
||||
"maunium.net/go/mautrix"
|
||||
"maunium.net/go/mautrix/event"
|
||||
|
@ -65,14 +66,15 @@ func SendMessage(today string, nextDay string) {
|
|||
nextDayRepresentation = representation
|
||||
}
|
||||
|
||||
if len(todayRepresentation) == 0 && len(nextDayRepresentation) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
var msg string
|
||||
|
||||
dt := time.Now()
|
||||
|
||||
if len(todayRepresentation) == 0 && len(nextDayRepresentation) == 0 { // no entries
|
||||
msg += "<b>✅ Vertretung - Keine Einträge vorhanden</b>"
|
||||
} else {
|
||||
if len(todayRepresentation) > 0 {
|
||||
msg += "<b>Vertretung - Heute</b>"
|
||||
msg += "<b>⚠️ Vertretung - Heute</b>"
|
||||
|
||||
for _, entity := range todayRepresentation {
|
||||
msg += "<br>Stunde: <b>" + entity.Hour + "</b>"
|
||||
|
@ -87,7 +89,7 @@ func SendMessage(today string, nextDay string) {
|
|||
}
|
||||
|
||||
if len(nextDayRepresentation) > 0 {
|
||||
msg += "<br><b>Vertretung - Nächster Tag</b>"
|
||||
msg += "<br><b>⚠️ Vertretung - Nächster Tag</b>"
|
||||
|
||||
for _, entity := range nextDayRepresentation {
|
||||
msg += "<br>Stunde: <b>" + entity.Hour + "</b>"
|
||||
|
@ -100,6 +102,9 @@ func SendMessage(today string, nextDay string) {
|
|||
msg += "<br>"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
msg += "<br>" + dt.Format("02.01.2006 15:04:05")
|
||||
|
||||
botmsg := format.RenderMarkdown(msg, false, true)
|
||||
|
||||
|
|
Loading…
Reference in New Issue