From a1204e7ea14d507197409f0d784f66b853b175aa Mon Sep 17 00:00:00 2001 From: tucher Date: Mon, 1 Aug 2016 20:30:30 +0300 Subject: [PATCH] Fixed BaseEdit.values chat_id and message_id should be sent only if there is no inline_message_id (and vice versa), according to documentation. --- configs.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/configs.go b/configs.go index 49fc0c3..b91d070 100644 --- a/configs.go +++ b/configs.go @@ -166,13 +166,16 @@ type BaseEdit struct { func (edit BaseEdit) values() (url.Values, error) { v := url.Values{} - if edit.ChannelUsername != "" { - v.Add("chat_id", edit.ChannelUsername) + if edit.InlineMessageID == "" { + if edit.ChannelUsername != "" { + v.Add("chat_id", edit.ChannelUsername) + } else { + v.Add("chat_id", strconv.FormatInt(edit.ChatID, 10)) + } + v.Add("message_id", strconv.Itoa(edit.MessageID)) } else { - v.Add("chat_id", strconv.FormatInt(edit.ChatID, 10)) + v.Add("inline_message_id", edit.InlineMessageID) } - v.Add("message_id", strconv.Itoa(edit.MessageID)) - v.Add("inline_message_id", edit.InlineMessageID) if edit.ReplyMarkup != nil { data, err := json.Marshal(edit.ReplyMarkup)