mirror of
https://github.com/lyx0/nourybot.git
synced 2024-11-13 19:49:55 +01:00
seperate uid lookup for replys and for internal usage
This commit is contained in:
parent
20b598ee3b
commit
cabb0d2783
|
@ -206,10 +206,10 @@ func (app *application) handleCommand(message twitch.PrivateMessage) {
|
||||||
reply, _ = commands.Xkcd()
|
reply, _ = commands.Xkcd()
|
||||||
|
|
||||||
case "uid":
|
case "uid":
|
||||||
reply = ivr.IDByUsername(cmdParams[1])
|
reply = ivr.IDByUsernameReply(cmdParams[1])
|
||||||
|
|
||||||
case "userid":
|
case "userid":
|
||||||
reply = ivr.IDByUsername(cmdParams[1])
|
reply = ivr.IDByUsernameReply(cmdParams[1])
|
||||||
|
|
||||||
case "commands":
|
case "commands":
|
||||||
reply = app.ListChannelCommands(message.Channel)
|
reply = app.ListChannelCommands(message.Channel)
|
||||||
|
|
|
@ -10,7 +10,7 @@ type ivrIDByUsernameResponse struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func IDByUsername(username string) string {
|
func IDByUsernameReply(username string) string {
|
||||||
baseUrl := "https://api.ivr.fi/v2/twitch/user?login="
|
baseUrl := "https://api.ivr.fi/v2/twitch/user?login="
|
||||||
|
|
||||||
resp, err := http.Get(fmt.Sprintf("%s%s", baseUrl, username))
|
resp, err := http.Get(fmt.Sprintf("%s%s", baseUrl, username))
|
||||||
|
@ -26,3 +26,19 @@ func IDByUsername(username string) string {
|
||||||
reply := fmt.Sprintf("%s=%s", username, responseList[0].ID)
|
reply := fmt.Sprintf("%s=%s", username, responseList[0].ID)
|
||||||
return reply
|
return reply
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
return responseList[0].ID
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue