mirror-nourybot/pkg/ivr/user.go
lyx0 d521ace38e clear up the ()uid reply.
previously '()uid forsen' would reply with only the twitch user id: '22484632'. now it replies with 'forsen=22484632'
2023-12-17 22:12:48 +01:00

29 lines
533 B
Go

package ivr
import (
"encoding/json"
"fmt"
"net/http"
)
type ivrIDByUsernameResponse struct {
ID string `json:"id"`
}
func IDByUsername(username string) string {
baseUrl := "https://api.ivr.fi/v2/twitch/user?login="
resp, err := http.Get(fmt.Sprintf("%s%s", baseUrl, username))
if err != nil {
return "xd"
}
defer resp.Body.Close()
responseList := make([]ivrIDByUsernameResponse, 0)
_ = json.NewDecoder(resp.Body).Decode(&responseList)
reply := fmt.Sprintf("%s=%s", username, responseList[0].ID)
return reply
}