Skip to content

Commit

Permalink
Fixed BaseEdit.values
Browse files Browse the repository at this point in the history
chat_id and message_id should be sent only if there is no
inline_message_id (and vice versa), according to documentation.
  • Loading branch information
tucher committed Aug 1, 2016
1 parent 4f996f7 commit a1204e7
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions configs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit a1204e7

Please sign in to comment.