Fix returning APIResponse from SetWebHook

bot-api-6.1
Sergey Juriev 2017-01-18 12:05:01 +03:00
parent 99170e2de4
commit 5d28cf05d0
1 changed files with 6 additions and 9 deletions

15
bot.go
View File

@ -184,7 +184,11 @@ func (bot *BotAPI) UploadFile(endpoint string, params map[string]string, fieldna
} }
var apiResp APIResponse var apiResp APIResponse
json.Unmarshal(bytes, &apiResp)
err = json.Unmarshal(bytes, &apiResp)
if err != nil {
return APIResponse{}, err
}
if !apiResp.Ok { if !apiResp.Ok {
return APIResponse{}, errors.New(apiResp.Description) return APIResponse{}, errors.New(apiResp.Description)
@ -431,14 +435,7 @@ func (bot *BotAPI) SetWebhook(config WebhookConfig) (APIResponse, error) {
return APIResponse{}, err return APIResponse{}, err
} }
var apiResp APIResponse return resp, nil
json.Unmarshal(resp.Result, &apiResp)
if bot.Debug {
log.Printf("setWebhook resp: %+v\n", apiResp)
}
return apiResp, nil
} }
// GetWebhookInfo allows you to fetch information about a webhook and if // GetWebhookInfo allows you to fetch information about a webhook and if