refactor baseUrl

This commit is contained in:
lyx0 2021-10-22 17:59:52 +02:00
parent 4682657025
commit 5d4c5b4402
6 changed files with 17 additions and 20 deletions

View file

@ -16,14 +16,12 @@ type firstLineApiResponse struct {
Error string `json:"error"`
}
var (
firstLineBaseUrl = "https://api.ivr.fi/logs/firstmessage"
)
// 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))
baseUrl := "https://api.ivr.fi/logs/firstmessage"
resp, err := http.Get(fmt.Sprintf("%s/%s/%s", baseUrl, channel, username))
if err != nil {
log.Error(err)
return "Something went wrong FeelsBadMan", err

View file

@ -21,7 +21,8 @@ type followageApiResponse struct {
// 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))
baseUrl := "https://api.ivr.fi/twitch/subage"
resp, err := http.Get(fmt.Sprintf("%s/%s/%s", baseUrl, username, streamer))
if err != nil {
log.Error(err)
}

View file

@ -15,12 +15,10 @@ type pfpApiResponse struct {
Error string `json:"error"`
}
var (
baseUrl = "https://api.ivr.fi/twitch/resolve"
)
// ProfilePicture returns a link to a given users profilepicture.
func ProfilePicture(username string) (string, error) {
baseUrl := "https://api.ivr.fi/twitch/resolve"
resp, err := http.Get(fmt.Sprintf("%s/%s", baseUrl, username))
if err != nil {
log.Error(err)

View file

@ -16,14 +16,14 @@ type randomQuoteApiResponse struct {
Error string `json:"Error"`
}
var (
randomQuoteBaseUrl = "https://api.ivr.fi/logs/rq"
)
var ()
// FirstLine returns the first line a given user has sent in a
// given channel.
func RandomQuote(channel string, username string) (string, error) {
resp, err := http.Get(fmt.Sprintf("%s/%s/%s", randomQuoteBaseUrl, channel, username))
baseUrl := "https://api.ivr.fi/logs/rq"
resp, err := http.Get(fmt.Sprintf("%s/%s/%s", baseUrl, channel, username))
if err != nil {
log.Error(err)
return "Something went wrong FeelsBadMan", err

View file

@ -30,13 +30,11 @@ type subStreak struct {
Months int `json:"months"`
}
var (
subageBaseUrl = "https://api.ivr.fi/twitch/subage"
)
// 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))
baseUrl := "https://api.ivr.fi/twitch/subage"
resp, err := http.Get(fmt.Sprintf("%s/%s/%s", baseUrl, username, channel))
if err != nil {
log.Error(err)
return "Something went wrong FeelsBadMan", err

View file

@ -17,7 +17,9 @@ type uidApiResponse struct {
// 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))
baseUrl := "https://api.ivr.fi/twitch/resolve"
resp, err := http.Get(fmt.Sprintf("%s/%s", baseUrl, username))
if err != nil {
log.Error(err)
}