Skip to content

Commit

Permalink
Add answerCallbackQuery method.
Browse files Browse the repository at this point in the history
  • Loading branch information
onrik committed Jul 8, 2016
1 parent 79c45db commit 93e8fee
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
23 changes: 23 additions & 0 deletions api.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,29 @@ func NewSendContactParams(chatId int64, phoneNumber, firstName, lastName string,
return params
}

// answerCallbackQuery request params
type AnswerCallbackQueryOptions struct {
Text string `json:"text,omitempty"`
ShowAlert bool `json:"show_alert,omitempty"`
}

type AnswerCallbackQueryParams struct {
CallbackQueryId string `json:"callback_query_id"`
AnswerCallbackQueryOptions
}

func NewAnswerCallbackQueryParams(callbackQueryId string, options *AnswerCallbackQueryOptions) *AnswerCallbackQueryParams {
params := &AnswerCallbackQueryParams{
CallbackQueryId: callbackQueryId,
}

if options != nil {
params.AnswerCallbackQueryOptions = *options
}

return params
}

type EditMessageTextOptions struct {
ParseMode ParseMode `json:"parse_mode,omitempty"`
DisableWebPagePreview bool `json:"disable_web_page_preview,omitempty"`
Expand Down
8 changes: 8 additions & 0 deletions bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -543,3 +543,11 @@ func (bot *Bot) GetChatMember(chatId, userId int64) (*ChatMember, error) {

return chatMember, err
}

// Use this method to send answers to callback queries sent from inline keyboards.
// The answer will be displayed to the user as a notification at the top of the chat screen or as an alert.
func (bot *Bot) AnswerCallbackQuery(callbackQueryID string, options *AnswerCallbackQueryOptions) error {
params := NewAnswerCallbackQueryParams(callbackQueryID, options)

return bot.post("answerCallbackQuery", params, nil)
}

0 comments on commit 93e8fee

Please sign in to comment.