updated school message format

master
Alex 2022-02-25 17:16:36 +01:00
parent b95e35dcd8
commit ffed568d01
2 changed files with 10 additions and 4 deletions

View File

@ -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 <h4>%s</h4>%s<br>%s", header, content, url), false, true)
client.SendMessageEvent(id.RoomID(cfg.RoomId), event.EventMessage, &content)
client.SendMessageEvent(id.RoomID(cfg.RoomId), event.EventMessage, &msg)
}

View File

@ -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)
}
}