diff --git a/main.go b/main.go index c015a9f..01291fa 100644 --- a/main.go +++ b/main.go @@ -8,13 +8,6 @@ import ( "github.com/ekzyis/sn-goapi" ) -func WaitUntilNextHour() { - now := time.Now() - dur := now.Truncate(time.Hour).Add(time.Hour).Sub(now) - log.Println("sleeping for", dur.Round(time.Second)) - time.Sleep(dur) -} - func WaitUntilNextMinute() { now := time.Now() dur := now.Truncate(time.Minute).Add(time.Minute).Sub(now) @@ -29,35 +22,6 @@ func WaitUntilNextRun() { time.Sleep(dur) } -func CheckNotifications() { - var prevHasNewNotes bool - for { - log.Println("Checking notifications ...") - hasNewNotes, err := sn.CheckNotifications() - if err != nil { - SendErrorToDiscord(err) - } else { - if !prevHasNewNotes && hasNewNotes { - // only send embed on "rising edge" - SendNotificationsEmbedToDiscord() - log.Println("Forwarded notifications to monitoring") - } else if hasNewNotes { - log.Println("Notifications already forwarded") - } - } - prevHasNewNotes = hasNewNotes - WaitUntilNextRun() - } -} - -func SessionKeepAlive() { - for { - log.Println("Refresh session using GET /api/auth/session ...") - sn.RefreshSession() - WaitUntilNextHour() - } -} - func SyncStories() { for { stories, err := FetchHackerNewsTopStories() @@ -78,8 +42,6 @@ func SyncStories() { } func main() { - go CheckNotifications() - go SessionKeepAlive() go SyncStories() for { var (