From ffed568d0103af4f89faebeb1f9654cb32c8e801 Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 25 Feb 2022 17:16:36 +0100 Subject: [PATCH] updated school message format --- matrix-bot/matrix-bot.go | 8 +++++--- pages/school.go | 6 +++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/matrix-bot/matrix-bot.go b/matrix-bot/matrix-bot.go index 6e95cfb..cb555b8 100644 --- a/matrix-bot/matrix-bot.go +++ b/matrix-bot/matrix-bot.go @@ -1,6 +1,8 @@ package matrixbot import ( + "fmt" + "maunium.net/go/mautrix" "maunium.net/go/mautrix/event" "maunium.net/go/mautrix/format" @@ -8,7 +10,7 @@ import ( "roese.dev/matrix-development-lauge/modules/config" ) -func SendMessage(msg string) { +func SendMessage(header string, content string, url string) { cfg := config.Cfg.Bot client, err := mautrix.NewClient(cfg.HomeserverUrl, "", "") @@ -28,7 +30,7 @@ func SendMessage(msg string) { panic(err) } - content := format.RenderMarkdown(msg, false, true) + msg := format.RenderMarkdown(fmt.Sprintf("Thema: Radko-Stöckl-Schule - Aktuelles

%s

%s
%s", header, content, url), false, true) - client.SendMessageEvent(id.RoomID(cfg.RoomId), event.EventMessage, &content) + client.SendMessageEvent(id.RoomID(cfg.RoomId), event.EventMessage, &msg) } diff --git a/pages/school.go b/pages/school.go index a47df02..e17fc6b 100644 --- a/pages/school.go +++ b/pages/school.go @@ -79,6 +79,10 @@ func School() { if send { text := firstListItem.Find("a .news-summary").Text() - matrixbot.SendMessage(text) + url := firstListItem.Find("a[href=true").Text() + + log.Println("url", url) + + matrixbot.SendMessage(pageTitle, text, url) } }