1
0
telegram/answer_inline_query.go

46 lines
2.0 KiB
Go
Raw Normal View History

package telegram
2017-09-05 09:20:10 +00:00
import json "github.com/pquerna/ffjson/ffjson"
type AnswerInlineQueryParameters struct {
2017-09-05 09:20:10 +00:00
// Unique identifier for the answered query
InlineQueryID string `json:"inline_query_id"` // required
// A JSON-serialized array of results for the inline query
Results []*InlineQueryResult `json:"results"` // required
// The maximum amount of time in seconds that the result of the inline query may be cached on the server. Defaults to 300.
2017-10-05 11:27:33 +00:00
CacheTime int `json:"cache_time,omitempty"` // optional
// Pass True, if results may be cached on the server side only for the user that sent the query. By default, results may be returned to any user who sends the same query
2017-10-05 11:27:33 +00:00
IsPersonal bool `json:"is_personal,omitempty"` // optional
// Pass the offset that a client should send in the next query with the same text to receive more results. Pass an empty string if there are no more results or if you dont support pagination. Offset length cant exceed 64 bytes.
2017-10-05 11:27:33 +00:00
NextOffset string `json:"next_offset,omitempty"` // optional
// If passed, clients will display a button with specified text that switches the user to a private chat with the bot and sends the bot a start message with the parameter switch_pm_parameter
2017-10-05 11:27:33 +00:00
SwitchPrivateMessageText string `json:"switch_pm_text,omitempty"` // optional
// Deep-linking parameter for the /start message sent to the bot when user presses the switch button. 1-64 characters, only A-Z, a-z, 0-9, _ and - are allowed.
2017-10-05 11:27:33 +00:00
SwitchPrivateMessageParameter string `json:"switch_pm_parameter,omitempty"` // optional
}
// AnswerInlineQuery send answers to an inline query. On success, True is returned.
//
// No more than 50 results per query are allowed.
2017-09-05 09:20:10 +00:00
func (bot *Bot) AnswerInlineQuery(params *AnswerInlineQueryParameters) (bool, error) {
dst, err := json.Marshal(*params)
if err != nil {
return false, err
}
2017-09-05 09:20:10 +00:00
resp, err := bot.request(dst, "answerInlineQuery", nil)
if err != nil {
return false, err
}
var data bool
err = json.Unmarshal(*resp.Result, &data)
return data, err
}