mirror of
https://git.keinpfusch.net/loweel/zorg
synced 2024-12-18 15:08:42 +01:00
31 lines
609 B
Go
31 lines
609 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"log"
|
|
|
|
"github.com/mattn/go-mastodon"
|
|
)
|
|
|
|
func postOnMastodon(message, title string) {
|
|
c := mastodon.NewClient(&mastodon.Config{
|
|
|
|
Server: ZorgConfig.ZorgServer,
|
|
ClientID: ZorgConfig.ZorgClientID,
|
|
ClientSecret: ZorgConfig.ZorgClientSecret,
|
|
})
|
|
err := c.Authenticate(context.Background(), ZorgConfig.ZorgUname, ZorgConfig.ZorgPass)
|
|
if err != nil {
|
|
log.Println(err)
|
|
} else {
|
|
log.Println("Authenticated to the server: ", ZorgConfig.ZorgServer)
|
|
|
|
}
|
|
|
|
c.PostStatus(context.Background(), &mastodon.Toot{
|
|
Status: message,
|
|
SpoilerText: title,
|
|
})
|
|
|
|
}
|