2023-04-07 06:56:18 +00:00
|
|
|
package main
|
|
|
|
|
2023-04-16 23:58:38 +00:00
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
|
|
|
|
"github.com/joho/godotenv"
|
|
|
|
"github.com/namsral/flag"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
SnUserName string
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
err := godotenv.Load()
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal("Error loading .env file")
|
|
|
|
}
|
|
|
|
flag.StringVar(&SnUserName, "SN_USERNAME", "", "Username of bot on SN")
|
|
|
|
flag.Parse()
|
|
|
|
if SnUserName == "" {
|
|
|
|
log.Fatal("SN_USERNAME not set")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-07 06:56:18 +00:00
|
|
|
func main() {
|
2023-04-16 17:56:42 +00:00
|
|
|
stories := FetchHackerNewsTopStories()
|
|
|
|
filtered := CurateContentForStackerNews(&stories)
|
2023-04-07 06:56:18 +00:00
|
|
|
for _, story := range *filtered {
|
2023-04-16 17:56:42 +00:00
|
|
|
PostStoryToStackerNews(&story)
|
2023-04-07 06:56:18 +00:00
|
|
|
}
|
|
|
|
}
|