jlelse
/
jsonpub
Archived
1
Fork 0
This repository has been archived on 2020-04-25. You can view files and clone it, but cannot push or open issues or pull requests.
jsonpub/main.go

42 lines
841 B
Go

package main
import (
"fmt"
"time"
)
func main() {
Setup()
SetupActors()
go func() {
ticker := time.NewTicker(60 * time.Second)
defer ticker.Stop()
for {
select {
case t := <-ticker.C:
fmt.Println("Fetch feeds: ", t.Format(time.RFC3339))
for _, actor := range actors {
fmt.Println(actor.feed)
articles, err := allFeedItems(actor.feed)
if err != nil {
fmt.Println(actor.feed, err.Error())
continue
}
// Prevent map from getting to big
oldSentItems := actor.sentItems
actor.sentItems = make(map[string]bool)
for _, article := range articles {
if oldSentItems[article] == false {
fmt.Println("Send", article)
go actor.PostArticle(article)
}
actor.sentItems[article] = true
}
_ = actor.save()
}
}
}
}()
Serve()
}