pull/210/merge
Denis 6 years ago committed by GitHub
commit 0800625e4b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 25
      bot.go
  2. 8
      configs.go

@ -208,30 +208,33 @@ func (bot *BotAPI) UploadFile(endpoint string, params Params, fieldname string,
ms.SetupRequest(req) ms.SetupRequest(req)
res, err := bot.Client.Do(req) resp, err := bot.Client.Do(req)
if err != nil { if err != nil {
return APIResponse{}, err return APIResponse{}, err
} }
defer res.Body.Close() defer resp.Body.Close()
bytes, err := ioutil.ReadAll(res.Body) var apiResp APIResponse
bytes, err := bot.decodeAPIResponse(resp.Body, &apiResp)
if err != nil { if err != nil {
return APIResponse{}, err return apiResp, err
} }
if bot.Debug { if bot.Debug {
log.Printf("Endpoint: %s, response: %s\n", endpoint, string(bytes)) log.Printf("Endpoint: %s, response: %s\n", endpoint, string(bytes))
} }
var apiResp APIResponse if !apiResp.Ok {
var parameters ResponseParameters
err = json.Unmarshal(bytes, &apiResp) if apiResp.Parameters != nil {
if err != nil { parameters = *apiResp.Parameters
return APIResponse{}, err }
}
if !apiResp.Ok { return apiResp, Error{
return APIResponse{}, errors.New(apiResp.Description) Message: apiResp.Description,
ResponseParameters: parameters,
}
} }
return apiResp, nil return apiResp, nil

@ -1363,7 +1363,9 @@ func (config UploadStickerConfig) getFile() interface{} {
} }
func (config UploadStickerConfig) useExistingFile() bool { func (config UploadStickerConfig) useExistingFile() bool {
return false _, ok := config.PNGSticker.(string)
return ok
} }
// NewStickerSetConfig allows creating a new sticker set. // NewStickerSetConfig allows creating a new sticker set.
@ -1453,7 +1455,9 @@ func (config AddStickerConfig) getFile() interface{} {
} }
func (config AddStickerConfig) useExistingFile() bool { func (config AddStickerConfig) useExistingFile() bool {
return false _, ok := config.PNGSticker.(string)
return ok
} }
// SetStickerPositionConfig allows you to change the position of a sticker in a set. // SetStickerPositionConfig allows you to change the position of a sticker in a set.