mirror of
https://github.com/lyx0/nourybot.git
synced 2024-11-13 19:49:55 +01:00
35 lines
565 B
Go
35 lines
565 B
Go
|
package decapi
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"io"
|
||
|
"net/http"
|
||
|
|
||
|
"go.uber.org/zap"
|
||
|
)
|
||
|
|
||
|
func GetIdByLogin(login string) (string, error) {
|
||
|
var basePath = "https://decapi.me/twitch/id/"
|
||
|
|
||
|
sugar := zap.NewExample().Sugar()
|
||
|
defer sugar.Sync()
|
||
|
|
||
|
resp, err := http.Get(fmt.Sprint(basePath + login))
|
||
|
if err != nil {
|
||
|
sugar.Error(err)
|
||
|
return "Something went wrong FeelsBadMan", err
|
||
|
}
|
||
|
|
||
|
defer resp.Body.Close()
|
||
|
|
||
|
body, err := io.ReadAll(resp.Body)
|
||
|
if err != nil {
|
||
|
sugar.Error(err)
|
||
|
return "Something went wrong FeelsBadMan", err
|
||
|
}
|
||
|
|
||
|
reply := string(body)
|
||
|
return reply, nil
|
||
|
|
||
|
}
|