mirror of
https://github.com/lyx0/nourybot.git
synced 2024-11-13 19:49:55 +01:00
check if userid response actually contains elements in slice
This commit is contained in:
parent
e09ec92a3b
commit
7cf1d4ade8
1 changed files with 7 additions and 3 deletions
|
@ -18,10 +18,11 @@ func IDByUsernameReply(username string) string {
|
|||
return "xd"
|
||||
}
|
||||
|
||||
defer resp.Body.Close()
|
||||
|
||||
responseList := make([]ivrIDByUsernameResponse, 0)
|
||||
_ = json.NewDecoder(resp.Body).Decode(&responseList)
|
||||
err = json.NewDecoder(resp.Body).Decode(&responseList)
|
||||
if len(responseList) == 0 {
|
||||
return "xd"
|
||||
}
|
||||
|
||||
reply := fmt.Sprintf("%s=%s", username, responseList[0].ID)
|
||||
return reply
|
||||
|
@ -39,6 +40,9 @@ func IDByUsername(username string) string {
|
|||
|
||||
responseList := make([]ivrIDByUsernameResponse, 0)
|
||||
_ = json.NewDecoder(resp.Body).Decode(&responseList)
|
||||
if len(responseList) == 0 {
|
||||
return "xd"
|
||||
}
|
||||
|
||||
return responseList[0].ID
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue