diff --git a/api.go b/api.go index 1b1e481..aa2b06c 100644 --- a/api.go +++ b/api.go @@ -233,3 +233,13 @@ type APICallbackQuery struct { ChatID string `json:"chat_instance"` Data *string `json:"data,omitempty"` } + +type apiMessageResponse struct { + Ok bool `json:"ok"` + Result APIMessage `json:"result"` +} + +type apiAlbumResponse struct { + Ok bool `json:"ok"` + Result []APIMessage `json:"result"` +} diff --git a/telegram.go b/telegram.go index 6eeb36c..fbecbea 100644 --- a/telegram.go +++ b/telegram.go @@ -101,10 +101,10 @@ func (t Telegram) SendTextMessage(data ClientTextMessageData) (APIMessage, error } defer resp.Body.Close() - var out APIMessage + var out apiMessageResponse err = json.NewDecoder(resp.Body).Decode(&out) checkerr("SendTextMessage/json.Decode", err) - return out, err + return out.Result, err } // SendPhoto sends a picture to a chat as a photo @@ -157,10 +157,10 @@ func (t Telegram) SendPhoto(data ClientPhotoData) (APIMessage, error) { } defer resp.Body.Close() - var out APIMessage + var out apiMessageResponse err = json.NewDecoder(resp.Body).Decode(&out) checkerr("SendPhoto/json.Decode", err) - return out, err + return out.Result, err } // SendAlbum sends an album of photos or videos @@ -187,10 +187,10 @@ func (t Telegram) SendAlbum(data ClientAlbumData) ([]APIMessage, error) { } defer resp.Body.Close() - var out []APIMessage + var out apiAlbumResponse err = json.NewDecoder(resp.Body).Decode(&out) checkerr("SendAlbum/json.Decode", err) - return out, err + return out.Result, err } // ForwardMessage forwards an existing message to a chat