diff --git a/README.md b/README.md index 30b15a3..c3e392f 100644 --- a/README.md +++ b/README.md @@ -139,17 +139,10 @@ err = bot.Send(recipient, audio) ## Reply markup ```go // Send a selective force reply message. -bot.Send(user, "pong", &tb.SendOptions{ - ReplyMarkup: &tb.ReplyMarkup{ - ForceReply: true, - Selective: true, - CustomKeyboard: [][]string{ - []string{"1", "2", "3"}, - []string{"4", "5", "6"}, - []string{"7", "8", "9"}, - []string{"*", "0", "#"}, - }, - }, - }, -) +bot.Send(user, "pong", &tb.ReplyMarkup{ + ForceReply: true, + Selective: true, + + ReplyKeyboard: keys, +}) ``` diff --git a/options.go b/options.go index 8a89c87..9c6bb0e 100644 --- a/options.go +++ b/options.go @@ -43,30 +43,35 @@ type SendOptions struct { // ReplyMarkup specifies convenient options for bot-user communications. type ReplyMarkup struct { - InlineKeyboard [][]InlineButton `json:"inline_keyboard,omitempty"` - // ForceReply forces Telegram clients to display // a reply interface to the user (act as if the user // has selected the bot‘s message and tapped "Reply"). ForceReply bool `json:"force_reply,omitempty"` - // CustomKeyboard is a grid, consisting of keyboard buttons. + // InlineKeyboard is a grid of InlineButtons displayed in the message. + // + // Note: DO NOT confuse with ReplyKeyboard and other keyboard properties! + InlineKeyboard [][]InlineButton `json:"inline_keyboard,omitempty"` + + // ReplyKeyboard is a grid, consisting of keyboard buttons. // // Note: you don't need to set HideCustomKeyboard field to show custom keyboard. - CustomKeyboard [][]KeyboardButton `json:"keyboard,omitempty"` + ReplyKeyboard [][]KeyboardButton `json:"keyboard,omitempty"` // Requests clients to hide the custom keyboard. // // Note: You dont need to set CustomKeyboard field to hide custom keyboard. - HideCustomKeyboard bool `json:"hide_keyboard,omitempty"` + HideReplyKeyboard bool `json:"hide_keyboard,omitempty"` // Requests clients to resize the keyboard vertically for optimal fit - // (e.g., make the keyboard smaller if there are just two rows of buttons). + // (e.g. make the keyboard smaller if there are just two rows of buttons). + // // Defaults to false, in which case the custom keyboard is always of the // same height as the app's standard keyboard. - ResizeKeyboard bool `json:"resize_keyboard,omitempty"` + ResizeReplyKeyboard bool `json:"resize_keyboard,omitempty"` - // Requests clients to hide the keyboard as soon as it's been used. + // Requests clients to hide the reply keyboard as soon as it's been used. + // // Defaults to false. OneTimeKeyboard bool `json:"one_time_keyboard,omitempty"` diff --git a/util.go b/util.go index c99ef7d..1453c2b 100644 --- a/util.go +++ b/util.go @@ -91,11 +91,12 @@ func embedSendOptions(params map[string]string, opt *SendOptions) { } if opt.ReplyMarkup != nil { - forceReply := opt.ReplyMarkup.ForceReply - customKeyboard := (opt.ReplyMarkup.CustomKeyboard != nil) - inlineKeyboard := opt.ReplyMarkup.InlineKeyboard != nil - hiddenKeyboard := opt.ReplyMarkup.HideCustomKeyboard - if forceReply || customKeyboard || hiddenKeyboard || inlineKeyboard { + force := opt.ReplyMarkup.ForceReply + reply := opt.ReplyMarkup.ReplyKeyboard != nil + inline := opt.ReplyMarkup.InlineKeyboard != nil + hidden := opt.ReplyMarkup.HideReplyKeyboard + resize := opt.ReplyMarkup.ResizeReplyKeyboard + if force || reply || inline || hidden || resize { replyMarkup, _ := json.Marshal(opt.ReplyMarkup) params["reply_markup"] = string(replyMarkup) }