Better paging.

master v1.0.1
Uriel Fanelli 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 package main
import ( import (
"context"
"encoding/json" "encoding/json"
"fmt"
"io/ioutil" "io/ioutil"
"log" "log"
"os" "os"
"time" "time"
"github.com/mattn/go-mastodon"
) )
// ZorgConfig is the configuration of Zorg. // ZorgConfig is the configuration of Zorg.
@ -40,6 +44,27 @@ func init() {
Zint = time.Duration(time.Duration(ZorgConfig.ZorgInterval) * time.Second) Zint = time.Duration(time.Duration(ZorgConfig.ZorgInterval) * time.Second)
ZorgCreateToken()
log.Println("Inizialized ZORG") 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 { 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) log.Println("New content from: ", feed.Title, b.Title, feed.Description)
} else { } else {
log.Println("No new content from: ", feed.Title, feed.Description) log.Println("No new content from: ", feed.Title, feed.Description)