parent
638939edd6
commit
a3933b48c6
14
main.go
14
main.go
|
@ -15,9 +15,9 @@ func WaitUntilNextHour() {
|
||||||
time.Sleep(dur)
|
time.Sleep(dur)
|
||||||
}
|
}
|
||||||
|
|
||||||
func WaitUntilNextMinute() {
|
func WaitUntilNextRun() {
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
dur := now.Truncate(time.Minute).Add(time.Minute).Sub(now)
|
dur := now.Truncate(time.Minute).Add(15 * time.Minute).Sub(now)
|
||||||
log.Println("sleeping for", dur.Round(time.Second))
|
log.Println("sleeping for", dur.Round(time.Second))
|
||||||
time.Sleep(dur)
|
time.Sleep(dur)
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ func CheckNotifications() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
prevHasNewNotes = hasNewNotes
|
prevHasNewNotes = hasNewNotes
|
||||||
WaitUntilNextMinute()
|
WaitUntilNextRun()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,20 +59,20 @@ func main() {
|
||||||
stories, err := FetchHackerNewsTopStories()
|
stories, err := FetchHackerNewsTopStories()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
SendErrorToDiscord(err)
|
SendErrorToDiscord(err)
|
||||||
WaitUntilNextMinute()
|
WaitUntilNextRun()
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := SaveStories(&stories); err != nil {
|
if err := SaveStories(&stories); err != nil {
|
||||||
SendErrorToDiscord(err)
|
SendErrorToDiscord(err)
|
||||||
WaitUntilNextMinute()
|
WaitUntilNextRun()
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
var filtered *[]Story
|
var filtered *[]Story
|
||||||
if filtered, err = CurateContentForStackerNews(); err != nil {
|
if filtered, err = CurateContentForStackerNews(); err != nil {
|
||||||
SendErrorToDiscord(err)
|
SendErrorToDiscord(err)
|
||||||
WaitUntilNextMinute()
|
WaitUntilNextRun()
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,6 +94,6 @@ func main() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
WaitUntilNextMinute()
|
WaitUntilNextRun()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue