mirror of
https://git.keinpfusch.net/loweel/zorg
synced 2024-12-19 00:03:28 +01:00
Better paging.
This commit is contained in:
parent
a50d6c91ea
commit
5644a4fb3c
25
env.go
25
env.go
@ -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)
|
||||||
|
|
||||||
|
}
|
||||||
|
5
feed.go
5
feed.go
@ -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)
|
||||||
|
Loading…
Reference in New Issue
Block a user