2017-09-05 08:32:27 +00:00
|
|
|
|
package telegram
|
|
|
|
|
|
2017-09-05 09:20:10 +00:00
|
|
|
|
import json "github.com/pquerna/ffjson/ffjson"
|
2017-09-05 08:32:27 +00:00
|
|
|
|
|
|
|
|
|
type AnswerInlineQueryParameters struct {
|
2017-09-05 09:20:10 +00:00
|
|
|
|
// Unique identifier for the answered query
|
2017-10-06 07:55:54 +00:00
|
|
|
|
InlineQueryID string `json:"inline_query_id"`
|
2017-09-05 09:20:10 +00:00
|
|
|
|
|
2017-10-06 07:55:54 +00:00
|
|
|
|
// 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 don‘t support pagination. Offset length can’t exceed 64
|
|
|
|
|
// bytes.
|
|
|
|
|
NextOffset string `json:"next_offset,omitempty"`
|
|
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
SwitchPrivateMessageText string `json:"switch_pm_text,omitempty"`
|
|
|
|
|
|
|
|
|
|
// 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.
|
|
|
|
|
SwitchPrivateMessageParameter string `json:"switch_pm_parameter,omitempty"`
|
2018-04-12 13:49:05 +00:00
|
|
|
|
|
|
|
|
|
// A JSON-serialized array of results for the inline query
|
|
|
|
|
Results []interface{} `json:"results"`
|
|
|
|
|
|
|
|
|
|
// The maximum amount of time in seconds that the result of the inline query
|
|
|
|
|
// may be cached on the server. Defaults to 300.
|
|
|
|
|
CacheTime int `json:"cache_time,omitempty"`
|
|
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
IsPersonal bool `json:"is_personal,omitempty"`
|
2017-09-05 08:32:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-10-26 00:24:25 +00:00
|
|
|
|
func NewAnswerInlineQuery(inlineQueryID string, results ...interface{}) *AnswerInlineQueryParameters {
|
2017-10-17 11:08:09 +00:00
|
|
|
|
return &AnswerInlineQueryParameters{
|
|
|
|
|
InlineQueryID: inlineQueryID,
|
|
|
|
|
Results: results,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-05 08:32:27 +00:00
|
|
|
|
// 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) {
|
2018-02-15 12:32:47 +00:00
|
|
|
|
dst, err := json.Marshal(params)
|
2017-09-05 08:32:27 +00:00
|
|
|
|
if err != nil {
|
|
|
|
|
return false, err
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-12 11:58:05 +00:00
|
|
|
|
resp, err := bot.request(dst, MethodAnswerInlineQuery)
|
2017-09-05 08:32:27 +00:00
|
|
|
|
if err != nil {
|
|
|
|
|
return false, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var data bool
|
|
|
|
|
err = json.Unmarshal(*resp.Result, &data)
|
|
|
|
|
return data, err
|
|
|
|
|
}
|