diff --git a/nun.go b/nun.go index 1df7c4f..a41c3c1 100644 --- a/nun.go +++ b/nun.go @@ -33,21 +33,22 @@ func (n *nunWatch) Main() { case <-n.stop: return case <-ticker.C: - if n.fail > 5 { - log.Fatal("fail count too high; ending loop") - return - } - if n.fail > 3 { - log.Println("over three failures, increasing tick time by 5x") - ticker.Reset(5 * time.Duration(n.timer) * time.Minute) - break - } + newPost, err := getNewestPost("LittleNuns") if err != nil { log.Printf("error getting newest post: %v", err) log.Println("skipping this cycle, incrementing fail count") n.fail++ - break + if n.fail > 5 { + log.Fatal("fail count too high; ending loop") + return + } else if n.fail > 3 { + log.Println("over three failures, increasing tick time by 5x") + ticker.Reset(5 * time.Duration(n.timer) * time.Minute) + break + } else { + break + } } if n.fail != 0 { n.fail = 0