From 58a3112bd8fb66f7098d6a3ecac2a2b500b1f72f Mon Sep 17 00:00:00 2001 From: Alexander Date: Fri, 10 Nov 2017 02:47:23 +0300 Subject: [PATCH] fixes --- bot.go | 10 +++++++++- types.go | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/bot.go b/bot.go index 9cd8125..d343e2e 100644 --- a/bot.go +++ b/bot.go @@ -423,6 +423,14 @@ func (bot *BotAPI) GetUpdates(config UpdateConfig) ([]Update, error) { var updates []Update json.Unmarshal(resp.Result, &updates) + // Every update contains raw JSON which + // can include information about other + // updates. This is because response is + // single for all. Be aware. + for _, v := range updates { + v.RawUpdateJSON = string(resp.Result) + } + bot.debugLog("getUpdates", v, updates) return updates, nil @@ -515,7 +523,7 @@ func (bot *BotAPI) ListenForWebhook(pattern string) UpdatesChannel { var update Update json.Unmarshal(bytes, &update) - update.RawUpdateJson = string(bytes) + update.RawUpdateJSON = string(bytes) ch <- update }) diff --git a/types.go b/types.go index 356ba2f..83dd5ad 100644 --- a/types.go +++ b/types.go @@ -37,7 +37,7 @@ type Update struct { CallbackQuery *CallbackQuery `json:"callback_query"` ShippingQuery *ShippingQuery `json:"shipping_query"` PreCheckoutQuery *PreCheckoutQuery `json:"pre_checkout_query"` - RawUpdateJson string + RawUpdateJSON string } // UpdatesChannel is the channel for getting updates.