hdkv
/
fwzookeeper
Archived
1
Fork 0
This repository has been archived on 2022-11-04. You can view files and clone it, but cannot push or open issues/pull-requests.
fwzookeeper/vendor/gitlab.com/toby3d/telegram/methods_inline_mode.go

65 lines
2.3 KiB
Go
Raw Normal View History

2018-11-29 20:32:51 +04:00
package telegram
import json "github.com/pquerna/ffjson/ffjson"
// AnswerInlineQueryParameters represents data for AnswerInlineQuery method.
type AnswerInlineQueryParameters struct {
// Unique identifier for the answered query
InlineQueryID string `json:"inline_query_id"`
// 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.
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"`
// 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"`
}
// NewAnswerInlineQuery creates AnswerInlineQueryParameters only with required
// parameters.
func NewAnswerInlineQuery(inlineQueryID string, results ...interface{}) *AnswerInlineQueryParameters {
return &AnswerInlineQueryParameters{
InlineQueryID: inlineQueryID,
Results: results,
}
}
// AnswerInlineQuery send answers to an inline query. On success, True is returned.
//
// No more than 50 results per query are allowed.
func (bot *Bot) AnswerInlineQuery(params *AnswerInlineQueryParameters) (ok bool, err error) {
dst, err := json.Marshal(params)
if err != nil {
return
}
resp, err := bot.request(dst, MethodAnswerInlineQuery)
if err != nil {
return
}
err = json.Unmarshal(*resp.Result, &ok)
return
}