oob check

This commit is contained in:
stryan 2022-11-12 12:55:14 -05:00
parent 6c9e3f15ae
commit 29ff95e43e
1 changed files with 4 additions and 0 deletions

View File

@ -3,6 +3,7 @@ package main
import (
"crypto/tls"
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"net/http"
@ -47,6 +48,9 @@ func getNewestPost(subreddit string) (post, error) {
if err != nil {
return post{}, err
}
if len(resp.Data.Children) < 1 {
return post{}, errors.New("bad data from reddit")
}
numS := re.FindStringSubmatch(resp.Data.Children[0].Data.Title)[0]
num, err := strconv.Atoi(numS)
if err != nil || numS == "" {