Compare commits
2 Commits
a72316b106
...
77e66464b0
Author | SHA1 | Date |
---|---|---|
alex | 77e66464b0 | |
alex | e6588b36e9 |
|
@ -2,6 +2,7 @@ package matrixbot
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log"
|
||||||
|
|
||||||
"maunium.net/go/mautrix"
|
"maunium.net/go/mautrix"
|
||||||
"maunium.net/go/mautrix/event"
|
"maunium.net/go/mautrix/event"
|
||||||
|
@ -16,7 +17,8 @@ func SendMessage(roomID string, topic string, header string, content string, url
|
||||||
client, err := mautrix.NewClient(cfg.HomeserverUrl, "", "")
|
client, err := mautrix.NewClient(cfg.HomeserverUrl, "", "")
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
log.Println("New client, err:", err.Error())
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = client.Login(&mautrix.ReqLogin{
|
_, err = client.Login(&mautrix.ReqLogin{
|
||||||
|
@ -27,10 +29,15 @@ func SendMessage(roomID string, topic string, header string, content string, url
|
||||||
})
|
})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
log.Println("Client login, err:", err.Error())
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
msg := format.RenderMarkdown(fmt.Sprintf("Thema: %s <h4>%s</h4>%s<br>%s", topic, header, content, url), false, true)
|
msg := format.RenderMarkdown(fmt.Sprintf("Thema: %s <h4>%s</h4>%s<br>%s", topic, header, content, url), false, true)
|
||||||
|
|
||||||
client.SendMessageEvent(id.RoomID(roomID), event.EventMessage, &msg)
|
_, err = client.SendMessageEvent(id.RoomID(roomID), event.EventMessage, &msg)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.Println("SendMessageEvent, err:", err.Error())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,7 +96,7 @@ func MelsungenNews() {
|
||||||
matrixbot.SendMessage(config.Cfg.Pages[1].RoomID, "Melsungen - Aktuelles", postTitle, postExcerpt, postUrl)
|
matrixbot.SendMessage(config.Cfg.Pages[1].RoomID, "Melsungen - Aktuelles", postTitle, postExcerpt, postUrl)
|
||||||
}
|
}
|
||||||
|
|
||||||
time.Sleep(2 * time.Second)
|
time.Sleep(10 * time.Second)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue