all repos — telegram-bot-api @ e6191af6795c37f1757d8ddba638ebb88e86c30b

Golang bindings for the Telegram Bot API

add doc message
zhuharev kirill@zhuharev.ru
Tue, 07 Nov 2017 05:17:06 +0300
commit

e6191af6795c37f1757d8ddba638ebb88e86c30b

parent

6b5102fab5586322d6fe98112fc671ad23dfae33

1 files changed, 3 insertions(+), 8 deletions(-)

jump to
M bot.gobot.go

@@ -78,14 +78,6 @@ if bot.Debug {

log.Printf("%s resp: %s", endpoint, bytes) } - if resp.StatusCode == http.StatusForbidden { - return APIResponse{}, errors.New(ErrAPIForbidden) - } - - if resp.StatusCode != http.StatusOK { - return APIResponse{}, errors.New(http.StatusText(resp.StatusCode)) - } - if !apiResp.Ok { return apiResp, errors.New(apiResp.Description) }

@@ -93,6 +85,9 @@

return apiResp, nil } +// decodeAPIResponse decode response and return slice of bytes if debug enabled. +// If debug disabled, just decode http.Response.Body stream to APIResponse struct +// for efficient memory usage func (bot *BotAPI) decodeAPIResponse(responseBody io.Reader, resp *APIResponse) (_ []byte, err error) { if !bot.Debug { dec := json.NewDecoder(responseBody)