all repos — telegram-bot-api @ da98517cd2d9897e9cff6ee365b65fa9a41e3ae5

Golang bindings for the Telegram Bot API

Merge pull request #210 from overplumbum/develop

fix add sticker to stickerset uploads by url and fileId
Syfaro syfaro@huefox.com
Tue, 21 Jul 2020 01:48:35 -0500
commit

da98517cd2d9897e9cff6ee365b65fa9a41e3ae5

parent

38c2cb18eddd4a0664ba18d82cd9f77a8c959381

2 files changed, 20 insertions(+), 13 deletions(-)

jump to
M bot.gobot.go

@@ -218,30 +218,33 @@ }

ms.SetupRequest(req) - res, err := bot.Client.Do(req) + resp, err := bot.Client.Do(req) if err != nil { 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 { - return APIResponse{}, err + return apiResp, err } if bot.Debug { 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 err != nil { - return APIResponse{}, err - } + if apiResp.Parameters != nil { + parameters = *apiResp.Parameters + } - if !apiResp.Ok { - return APIResponse{}, errors.New(apiResp.Description) + return apiResp, Error{ + Message: apiResp.Description, + ResponseParameters: parameters, + } } return apiResp, nil
M configs.goconfigs.go

@@ -1421,7 +1421,9 @@ return config.PNGSticker

} func (config UploadStickerConfig) useExistingFile() bool { - return false + _, ok := config.PNGSticker.(string) + + return ok } // NewStickerSetConfig allows creating a new sticker set.

@@ -1527,7 +1529,9 @@ return config.PNGSticker

} 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.