oob check
This commit is contained in:
parent
6c9e3f15ae
commit
29ff95e43e
@ -3,6 +3,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -47,6 +48,9 @@ func getNewestPost(subreddit string) (post, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return post{}, err
|
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]
|
numS := re.FindStringSubmatch(resp.Data.Children[0].Data.Title)[0]
|
||||||
num, err := strconv.Atoi(numS)
|
num, err := strconv.Atoi(numS)
|
||||||
if err != nil || numS == "" {
|
if err != nil || numS == "" {
|
||||||
|
Loading…
Reference in New Issue
Block a user