Include ResponseParameters in UploadFile error

This makes UploadFile behave more similarly to MakeRequest when the
response is not ok.
bot-api-6.1
Jiayu Yi 2020-01-13 22:08:58 +08:00
parent aa124ef1e8
commit e0d9306d8b
1 changed files with 8 additions and 4 deletions

12
bot.go
View File

@ -226,7 +226,11 @@ func (bot *BotAPI) UploadFile(endpoint string, params map[string]string, fieldna
}
if !apiResp.Ok {
return APIResponse{}, errors.New(apiResp.Description)
parameters := ResponseParameters{}
if apiResp.Parameters != nil {
parameters = *apiResp.Parameters
}
return apiResp, Error{Code: apiResp.ErrorCode, Message: apiResp.Description, ResponseParameters: parameters}
}
return apiResp, nil
@ -740,9 +744,9 @@ func (bot *BotAPI) UnbanChatMember(config ChatMemberConfig) (APIResponse, error)
}
// RestrictChatMember to restrict a user in a supergroup. The bot must be an
//administrator in the supergroup for this to work and must have the
//appropriate admin rights. Pass True for all boolean parameters to lift
//restrictions from a user. Returns True on success.
// administrator in the supergroup for this to work and must have the
// appropriate admin rights. Pass True for all boolean parameters to lift
// restrictions from a user. Returns True on success.
func (bot *BotAPI) RestrictChatMember(config RestrictChatMemberConfig) (APIResponse, error) {
v := url.Values{}