From 5644a4fb3c82af0f97877a04913a6f024c017376 Mon Sep 17 00:00:00 2001 From: loweel Date: Sat, 15 Jul 2023 02:04:50 +0200 Subject: [PATCH] Better paging. --- env.go | 25 +++++++++++++++++++++++++ feed.go | 5 ++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/env.go b/env.go index 4b53d92..9ce7f60 100644 --- a/env.go +++ b/env.go @@ -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) + +} diff --git a/feed.go b/feed.go index 81bbcd8..0f9b2fe 100644 --- a/feed.go +++ b/feed.go @@ -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)