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
2 changed files with 19 additions and 3 deletions
|
@ -206,10 +206,10 @@ func (app *application) handleCommand(message twitch.PrivateMessage) {
|
|||
reply, _ = commands.Xkcd()
|
||||
|
||||
case "uid":
|
||||
reply = ivr.IDByUsername(cmdParams[1])
|
||||
reply = ivr.IDByUsernameReply(cmdParams[1])
|
||||
|
||||
case "userid":
|
||||
reply = ivr.IDByUsername(cmdParams[1])
|
||||
reply = ivr.IDByUsernameReply(cmdParams[1])
|
||||
|
||||
case "commands":
|
||||
reply = app.ListChannelCommands(message.Channel)
|
||||
|
|
|
@ -10,7 +10,7 @@ type ivrIDByUsernameResponse struct {
|
|||
ID string `json:"id"`
|
||||
}
|
||||
|
||||
func IDByUsername(username string) string {
|
||||
func IDByUsernameReply(username string) string {
|
||||
baseUrl := "https://api.ivr.fi/v2/twitch/user?login="
|
||||
|
||||
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)
|
||||
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