add comments

This commit is contained in:
lyx0 2021-10-20 23:21:13 +02:00
parent 3bcef5b48a
commit c2a8b35c12
13 changed files with 28 additions and 5 deletions

View file

@ -12,6 +12,8 @@ var (
basePath = "https://customapi.aidenwallis.co.uk/"
)
// ApiCall calls https://customapi.aidenwallis.co.uk/ with
// a given uri and returns the result and an error.
func ApiCall(uri string) (string, error) {
resp, err := http.Get(fmt.Sprint(basePath + uri))
if err != nil {

View file

@ -20,8 +20,10 @@ var (
firstLineBaseUrl = "https://api.ivr.fi/logs/firstmessage"
)
func FirstLine(streamer string, username string) (string, error) {
resp, err := http.Get(fmt.Sprintf("%s/%s/%s", firstLineBaseUrl, streamer, username))
// FirstLine returns the first line a given user has sent in a
// given channel.
func FirstLine(channel string, username string) (string, error) {
resp, err := http.Get(fmt.Sprintf("%s/%s/%s", firstLineBaseUrl, channel, username))
if err != nil {
log.Error(err)
return "Something went wrong FeelsBadMan", err

View file

@ -19,6 +19,7 @@ type followageApiResponse struct {
Error string `json:"error"`
}
// Followage returns the time since a given user followed a given streamer
func Followage(streamer string, username string) (string, error) {
resp, err := http.Get(fmt.Sprintf("https://api.ivr.fi/twitch/subage/%s/%s", username, streamer))
if err != nil {

View file

@ -19,6 +19,7 @@ var (
baseUrl = "https://api.ivr.fi/twitch/resolve"
)
// ProfilePicture returns a link to a given users profilepicture.
func ProfilePicture(username string) (string, error) {
resp, err := http.Get(fmt.Sprintf("%s/%s", baseUrl, username))
if err != nil {

View file

@ -34,8 +34,9 @@ var (
subageBaseUrl = "https://api.ivr.fi/twitch/subage"
)
func Subage(username string, streamer string) (string, error) {
resp, err := http.Get(fmt.Sprintf("%s/%s/%s", subageBaseUrl, username, streamer))
// Subage returns the length a given user has been subscribed to a given channel.
func Subage(username string, channel string) (string, error) {
resp, err := http.Get(fmt.Sprintf("%s/%s/%s", subageBaseUrl, username, channel))
if err != nil {
log.Error(err)
return "Something went wrong FeelsBadMan", err
@ -64,7 +65,7 @@ func Subage(username string, streamer string) (string, error) {
return reply, nil
} else {
months := fmt.Sprint(responseObject.Cumulative.Months)
reply := fmt.Sprintf(username + " has been subscribed to " + streamer + " for " + months + " months.")
reply := fmt.Sprintf(username + " has been subscribed to " + channel + " for " + months + " months.")
return reply, nil
}
}

View file

@ -15,6 +15,7 @@ type uidApiResponse struct {
Error string `json:"error"`
}
// Userid returns the userID of a given user
func Userid(username string) string {
resp, err := http.Get(fmt.Sprintf("https://api.ivr.fi/twitch/resolve/%s", username))
if err != nil {

View file

@ -8,6 +8,8 @@ import (
log "github.com/sirupsen/logrus"
)
// RandomNumber returns a string containg fun facts about a random number.
// API used: http://numbersapi.com
func RandomNumber() string {
response, err := http.Get("http://numbersapi.com/random/trivia")
if err != nil {
@ -21,6 +23,8 @@ func RandomNumber() string {
return string(responseData)
}
// Number returns a string containing fun facts about a given number.
// API used: http://numbersapi.com
func Number(number string) string {
response, err := http.Get(fmt.Sprint("http://numbersapi.com/" + string(number)))
if err != nil {

View file

@ -12,6 +12,8 @@ type randomCatResponse struct {
File string `json:"file"`
}
// RandomCat returns a link to a random cat picture.
// API used: https://aws.random.cat/meow
func RandomCat() string {
response, err := http.Get("https://aws.random.cat/meow")
if err != nil {

View file

@ -12,6 +12,8 @@ type randomDogResponse struct {
Url string `json:"url"`
}
// RandomDog returns a link to a random dog picture.
// API used: https://random.dog/woof.json
func RandomDog() string {
response, err := http.Get("https://random.dog/woof.json")
if err != nil {

View file

@ -12,6 +12,8 @@ type randomDuckResponse struct {
Url string `json:"url"`
}
// RandomDuck returns a link to a random duck picture.
// API used: https://random-d.uk/api/random
func RandomDuck() string {
response, err := http.Get("https://random-d.uk/api/random")
if err != nil {

View file

@ -13,6 +13,8 @@ type randomFoxResponse struct {
Link string `json:"link"`
}
// RandomFox returns a link to a random fox picture.
// API used: https://randomfox.ca/floof/
func RandomFox() string {
response, err := http.Get("https://randomfox.ca/floof/")
if err != nil {

View file

@ -16,6 +16,7 @@ type XkcdResponse struct {
Img string `json:"img"`
}
// 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"))

View file

@ -9,6 +9,8 @@ import (
log "github.com/sirupsen/logrus"
)
// Xkcd returns a link to the latest Xkcd comic.
// API used: https://xkcd.com/info.0.json
func Xkcd() string {
response, err := http.Get("https://xkcd.com/info.0.json")
if err != nil {