mirror of
https://github.com/lyx0/nourybot.git
synced 2024-11-13 19:49:55 +01:00
replace log.Fatalln with log.Error
This commit is contained in:
parent
0762145c2f
commit
07eb4090c5
|
@ -4,8 +4,9 @@ import (
|
|||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// https://api.ivr.fi
|
||||
|
@ -17,14 +18,14 @@ type uidApiResponse struct {
|
|||
func Userid(username string) string {
|
||||
resp, err := http.Get(fmt.Sprintf("https://api.ivr.fi/twitch/resolve/%s", username))
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
log.Error(err)
|
||||
}
|
||||
|
||||
defer resp.Body.Close()
|
||||
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
log.Error(err)
|
||||
}
|
||||
|
||||
var responseObject uidApiResponse
|
||||
|
|
|
@ -3,8 +3,9 @@ package api
|
|||
import (
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
type randomCatResponse struct {
|
||||
|
@ -14,12 +15,12 @@ type randomCatResponse struct {
|
|||
func RandomCat() string {
|
||||
response, err := http.Get("https://aws.random.cat/meow")
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
log.Error(err)
|
||||
}
|
||||
|
||||
responseData, err := ioutil.ReadAll(response.Body)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
log.Error(err)
|
||||
}
|
||||
|
||||
var responseObject randomCatResponse
|
||||
|
|
|
@ -3,8 +3,9 @@ package api
|
|||
import (
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
type randomDogResponse struct {
|
||||
|
@ -14,12 +15,12 @@ type randomDogResponse struct {
|
|||
func RandomDog() string {
|
||||
response, err := http.Get("https://random.dog/woof.json")
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
log.Error(err)
|
||||
}
|
||||
|
||||
responseData, err := ioutil.ReadAll(response.Body)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
log.Error(err)
|
||||
}
|
||||
|
||||
var responseObject randomDogResponse
|
||||
|
|
|
@ -3,8 +3,9 @@ package api
|
|||
import (
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
type randomFoxResponse struct {
|
||||
|
@ -15,12 +16,12 @@ type randomFoxResponse struct {
|
|||
func RandomFox() string {
|
||||
response, err := http.Get("https://randomfox.ca/floof/")
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
log.Error(err)
|
||||
}
|
||||
|
||||
responseData, err := ioutil.ReadAll(response.Body)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
log.Error(err)
|
||||
}
|
||||
|
||||
var responseObject randomFoxResponse
|
||||
|
|
|
@ -4,10 +4,10 @@ import (
|
|||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
"github.com/lyx0/nourybot/pkg/utils"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
type XkcdResponse struct {
|
||||
|
@ -20,11 +20,11 @@ func RandomXkcd() string {
|
|||
comicNum := fmt.Sprint(utils.GenerateRandomNumber(2468))
|
||||
response, err := http.Get(fmt.Sprint("http://xkcd.com/" + comicNum + "/info.0.json"))
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
log.Error(err)
|
||||
}
|
||||
responseData, err := ioutil.ReadAll(response.Body)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
log.Error(err)
|
||||
}
|
||||
var responseObject XkcdResponse
|
||||
json.Unmarshal(responseData, &responseObject)
|
||||
|
|
|
@ -4,18 +4,19 @@ import (
|
|||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func Xkcd() string {
|
||||
response, err := http.Get("https://xkcd.com/info.0.json")
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
log.Error(err)
|
||||
}
|
||||
responseData, err := ioutil.ReadAll(response.Body)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
log.Error(err)
|
||||
}
|
||||
var responseObject XkcdResponse
|
||||
json.Unmarshal(responseData, &responseObject)
|
||||
|
|
Loading…
Reference in a new issue