2023-04-07 06:56:18 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
|
|
|
|
"github.com/joho/godotenv"
|
|
|
|
"github.com/namsral/flag"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
AuthCookie string
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
err := godotenv.Load()
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal("Error loading .env file")
|
|
|
|
}
|
|
|
|
flag.StringVar(&AuthCookie, "auth_cookie", "", "Cookie required for authorization")
|
|
|
|
flag.Parse()
|
|
|
|
if AuthCookie == "" {
|
|
|
|
log.Fatal("auth cookie not set")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
stories := fetchTopStoriesFromHN()
|
|
|
|
filtered := filterByRelevanceForSN(&stories)
|
2023-04-16 15:14:44 +00:00
|
|
|
log.Println(filtered)
|
2023-04-07 06:56:18 +00:00
|
|
|
for _, story := range *filtered {
|
|
|
|
postToSN(&story)
|
|
|
|
}
|
|
|
|
}
|