mirror of
https://github.com/lyx0/nourybot.git
synced 2024-11-13 19:49:55 +01:00
cleanup'
This commit is contained in:
parent
f0a4deaa55
commit
235600ea4d
|
@ -15,6 +15,7 @@ func RandomNumber() string {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(err)
|
log.Error(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
responseData, err := ioutil.ReadAll(response.Body)
|
responseData, err := ioutil.ReadAll(response.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(err)
|
log.Error(err)
|
||||||
|
@ -27,12 +28,15 @@ func RandomNumber() string {
|
||||||
// API used: http://numbersapi.com
|
// API used: http://numbersapi.com
|
||||||
func Number(number string) string {
|
func Number(number string) string {
|
||||||
response, err := http.Get(fmt.Sprint("http://numbersapi.com/" + string(number)))
|
response, err := http.Get(fmt.Sprint("http://numbersapi.com/" + string(number)))
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(err)
|
log.Error(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
responseData, err := ioutil.ReadAll(response.Body)
|
responseData, err := ioutil.ReadAll(response.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(err)
|
log.Error(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return string(responseData)
|
return string(responseData)
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ type XkcdResponse struct {
|
||||||
// RandomXkcd returns a link to a random Xkcd comic.
|
// RandomXkcd returns a link to a random Xkcd comic.
|
||||||
func RandomXkcd() string {
|
func RandomXkcd() string {
|
||||||
comicNum := fmt.Sprint(utils.GenerateRandomNumber(2468))
|
comicNum := fmt.Sprint(utils.GenerateRandomNumber(2468))
|
||||||
|
|
||||||
response, err := http.Get(fmt.Sprint("http://xkcd.com/" + comicNum + "/info.0.json"))
|
response, err := http.Get(fmt.Sprint("http://xkcd.com/" + comicNum + "/info.0.json"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(err)
|
log.Error(err)
|
||||||
|
@ -31,6 +32,5 @@ func RandomXkcd() string {
|
||||||
json.Unmarshal(responseData, &responseObject)
|
json.Unmarshal(responseData, &responseObject)
|
||||||
|
|
||||||
reply := fmt.Sprint("Random Xkcd #", responseObject.Num, " Title: ", responseObject.SafeTitle, " ", responseObject.Img)
|
reply := fmt.Sprint("Random Xkcd #", responseObject.Num, " Title: ", responseObject.SafeTitle, " ", responseObject.Img)
|
||||||
|
|
||||||
return reply
|
return reply
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue