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 {
|
||||
log.Error(err)
|
||||
}
|
||||
|
||||
responseData, err := ioutil.ReadAll(response.Body)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
|
@ -27,12 +28,15 @@ func RandomNumber() string {
|
|||
// API used: http://numbersapi.com
|
||||
func Number(number string) string {
|
||||
response, err := http.Get(fmt.Sprint("http://numbersapi.com/" + string(number)))
|
||||
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
|
||||
responseData, err := ioutil.ReadAll(response.Body)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
|
||||
return string(responseData)
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ type XkcdResponse struct {
|
|||
// RandomXkcd returns a link to a random Xkcd comic.
|
||||
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.Error(err)
|
||||
|
@ -31,6 +32,5 @@ func RandomXkcd() string {
|
|||
json.Unmarshal(responseData, &responseObject)
|
||||
|
||||
reply := fmt.Sprint("Random Xkcd #", responseObject.Num, " Title: ", responseObject.SafeTitle, " ", responseObject.Img)
|
||||
|
||||
return reply
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue