diff --git a/main b/main index 3480257..c044ee9 100755 Binary files a/main and b/main differ diff --git a/matrix-bot/matrix-bot.go b/matrix-bot/matrix-bot.go index 1b36bb9..eb41d15 100755 --- a/matrix-bot/matrix-bot.go +++ b/matrix-bot/matrix-bot.go @@ -4,6 +4,7 @@ import ( "encoding/base64" "encoding/json" "log" + "time" "maunium.net/go/mautrix" "maunium.net/go/mautrix/event" @@ -65,41 +66,45 @@ func SendMessage(today string, nextDay string) { nextDayRepresentation = representation } - if len(todayRepresentation) == 0 && len(nextDayRepresentation) == 0 { - return - } - var msg string - if len(todayRepresentation) > 0 { - msg += "Vertretung - Heute" + dt := time.Now() - for _, entity := range todayRepresentation { - msg += "
Stunde: " + entity.Hour + "" - msg += "
Klasse: " + entity.Class + "" - msg += "
Vertreter: " + entity.Representative + "" - msg += "
Lehrer: " + entity.Teacher + "" - msg += "
Fach: " + entity.Subject + "" - msg += "
Raum: " + entity.Room + "" - msg += "
Hinweis: " + entity.Note + "" - msg += "
" + if len(todayRepresentation) == 0 && len(nextDayRepresentation) == 0 { // no entries + msg += "✅ Vertretung - Keine Einträge vorhanden" + } else { + if len(todayRepresentation) > 0 { + msg += "⚠️ Vertretung - Heute" + + for _, entity := range todayRepresentation { + msg += "
Stunde: " + entity.Hour + "" + msg += "
Klasse: " + entity.Class + "" + msg += "
Vertreter: " + entity.Representative + "" + msg += "
Lehrer: " + entity.Teacher + "" + msg += "
Fach: " + entity.Subject + "" + msg += "
Raum: " + entity.Room + "" + msg += "
Hinweis: " + entity.Note + "" + msg += "
" + } + } + + if len(nextDayRepresentation) > 0 { + msg += "
⚠️ Vertretung - Nächster Tag" + + for _, entity := range nextDayRepresentation { + msg += "
Stunde: " + entity.Hour + "" + msg += "
Klasse: " + entity.Class + "" + msg += "
Vertreter: " + entity.Representative + "" + msg += "
Lehrer: " + entity.Teacher + "" + msg += "
Fach: " + entity.Subject + "" + msg += "
Raum: " + entity.Room + "" + msg += "
Hinweis: " + entity.Note + "" + msg += "
" + } } } - if len(nextDayRepresentation) > 0 { - msg += "
Vertretung - Nächster Tag" - - for _, entity := range nextDayRepresentation { - msg += "
Stunde: " + entity.Hour + "" - msg += "
Klasse: " + entity.Class + "" - msg += "
Vertreter: " + entity.Representative + "" - msg += "
Lehrer: " + entity.Teacher + "" - msg += "
Fach: " + entity.Subject + "" - msg += "
Raum: " + entity.Room + "" - msg += "
Hinweis: " + entity.Note + "" - msg += "
" - } - } + msg += "
" + dt.Format("02.01.2006 15:04:05") botmsg := format.RenderMarkdown(msg, false, true)