2023-04-07 06:56:18 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
|
|
|
|
"github.com/joho/godotenv"
|
|
|
|
"github.com/namsral/flag"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2023-04-16 15:28:38 +00:00
|
|
|
SnApiToken string
|
2023-04-07 06:56:18 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
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")
|
2023-04-07 06:56:18 +00:00
|
|
|
flag.Parse()
|
2023-04-16 15:28:38 +00:00
|
|
|
if SnApiToken == "" {
|
|
|
|
log.Fatal("NEXT_AUTH_CSRF_TOKEN not set")
|
2023-04-07 06:56:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
stories := fetchTopStoriesFromHN()
|
|
|
|
filtered := filterByRelevanceForSN(&stories)
|
|
|
|
for _, story := range *filtered {
|
|
|
|
postToSN(&story)
|
|
|
|
}
|
|
|
|
}
|