1
0
mirror of https://git.keinpfusch.net/loweel/zorg synced 2024-12-18 11:39:31 +01:00

Better paging.

This commit is contained in:
loweel 2023-07-15 02:04:50 +02:00
parent a50d6c91ea
commit 5644a4fb3c
2 changed files with 29 additions and 1 deletions

25
env.go
View File

@ -1,11 +1,15 @@
package main
import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"log"
"os"
"time"
"github.com/mattn/go-mastodon"
)
// ZorgConfig is the configuration of Zorg.
@ -40,6 +44,27 @@ func init() {
Zint = time.Duration(time.Duration(ZorgConfig.ZorgInterval) * time.Second)
ZorgCreateToken()
log.Println("Inizialized ZORG")
}
func ZorgCreateToken() {
app, err := mastodon.RegisterApp(context.Background(), &mastodon.AppConfig{
Server: ZorgConfig.ZorgServer,
ClientName: "Zorg",
Scopes: "read write follow",
Website: ZorgConfig.ZorgServer,
})
if err != nil {
log.Fatal(err)
}
ZorgConfig.ZorgClientID = app.ClientID
ZorgConfig.ZorgClientSecret = app.ClientSecret
fmt.Printf("Zorg new client-id : %s\n", ZorgConfig.ZorgClientID)
fmt.Printf("Zorg new client-secret: %s\n", ZorgConfig.ZorgClientSecret)
}

View File

@ -49,7 +49,10 @@ func forwardLastFeed(url string) {
if time.Since(postAge) < Zint {
postOnMastodon(b.Link, "["+feed.Title+"] "+b.Title)
TheTitle := fmt.Sprintf("[ %s ]", feed.Title)
TheBody := fmt.Sprintf("%s \n\n%s \n\n%s", b.Author.Name, feed.Description, b.Link)
postOnMastodon(TheBody, TheTitle)
log.Println("New content from: ", feed.Title, b.Title, feed.Description)
} else {
log.Println("No new content from: ", feed.Title, feed.Description)