hnbot/main.go

33 lines
584 B
Go
Raw Permalink Normal View History

package main
import (
"log"
"github.com/joho/godotenv"
"github.com/namsral/flag"
)
var (
2023-04-16 15:28:38 +00:00
SnApiToken string
)
func init() {
err := godotenv.Load()
if err != nil {
log.Fatal("Error loading .env file")
}
2023-04-16 15:28:38 +00:00
flag.StringVar(&SnApiToken, "NEXT_AUTH_CSRF_TOKEN", "", "Token required for authorizing requests to stacker.news/api/graphql")
flag.Parse()
2023-04-16 15:28:38 +00:00
if SnApiToken == "" {
log.Fatal("NEXT_AUTH_CSRF_TOKEN not set")
}
}
func main() {
stories := fetchTopStoriesFromHN()
filtered := filterByRelevanceForSN(&stories)
for _, story := range *filtered {
postToSN(&story)
}
}