@@ -12,10 +12,17 @@ import (
1212// APIResponse is a response from the Telegram API with the result
1313// stored raw.
1414type APIResponse struct {
15- Ok bool `json:"ok"`
16- Result json.RawMessage `json:"result"`
17- ErrorCode int `json:"error_code"`
18- Description string `json:"description"`
15+ Ok bool `json:"ok"`
16+ Result json.RawMessage `json:"result"`
17+ ErrorCode int `json:"error_code"`
18+ Description string `json:"description"`
19+ Parameters * ResponseParameters `json:"parameters"`
20+ }
21+
22+ // ResponseParameters are various errors that can be returned in APIResponse.
23+ type ResponseParameters struct {
24+ MigrateToChatID int `json:"migrate_to_chat_id"` // optional
25+ RetryAfter int `json:"retry_after"` // optional
1926}
2027
2128// Update is an update response, from GetUpdates.
@@ -61,12 +68,13 @@ type GroupChat struct {
6168
6269// Chat contains information about the place a message was sent.
6370type Chat struct {
64- ID int64 `json:"id"`
65- Type string `json:"type"`
66- Title string `json:"title"` // optional
67- UserName string `json:"username"` // optional
68- FirstName string `json:"first_name"` // optional
69- LastName string `json:"last_name"` // optional
71+ ID int64 `json:"id"`
72+ Type string `json:"type"`
73+ Title string `json:"title"` // optional
74+ UserName string `json:"username"` // optional
75+ FirstName string `json:"first_name"` // optional
76+ LastName string `json:"last_name"` // optional
77+ AllMembersAreAdmins bool `json:"all_members_are_administrators"` // optional
7078}
7179
7280// IsPrivate returns if the Chat is a private conversation.
@@ -110,6 +118,7 @@ type Message struct {
110118 Entities * []MessageEntity `json:"entities"` // optional
111119 Audio * Audio `json:"audio"` // optional
112120 Document * Document `json:"document"` // optional
121+ Game * Game `json:"game"` // optional
113122 Photo * []PhotoSize `json:"photo"` // optional
114123 Sticker * Sticker `json:"sticker"` // optional
115124 Video * Video `json:"video"` // optional
@@ -324,11 +333,15 @@ type InlineKeyboardMarkup struct {
324333//
325334// Note that some values are references as even an empty string
326335// will change behavior.
336+ //
337+ // CallbackGame, if set, MUST be first button in first row.
327338type InlineKeyboardButton struct {
328- Text string `json:"text"`
329- URL * string `json:"url,omitempty"` // optional
330- CallbackData * string `json:"callback_data,omitempty"` // optional
331- SwitchInlineQuery * string `json:"switch_inline_query,omitempty"` // optional
339+ Text string `json:"text"`
340+ URL * string `json:"url,omitempty"` // optional
341+ CallbackData * string `json:"callback_data,omitempty"` // optional
342+ SwitchInlineQuery * string `json:"switch_inline_query,omitempty"` // optional
343+ SwitchInlineQueryCurrentChat * string `json:"switch_inline_query_current_chat"` // optional
344+ CallbackGame * CallbackGame `json:"callback_game"` // optional
332345}
333346
334347// CallbackQuery is data sent when a keyboard button with callback data
@@ -338,7 +351,9 @@ type CallbackQuery struct {
338351 From * User `json:"from"`
339352 Message * Message `json:"message"` // optional
340353 InlineMessageID string `json:"inline_message_id"` // optional
341- Data string `json:"data"` // optional
354+ ChatInstance string `json:"chat_instance"`
355+ Data string `json:"data"` // optional
356+ GameShortName string `json:"game_short_name"` // optional
342357}
343358
344359// ForceReply allows the Bot to have users directly reply to it without
@@ -369,6 +384,49 @@ func (chat ChatMember) HasLeft() bool { return chat.Status == "left" }
369384// WasKicked returns if the ChatMember was kicked from the chat.
370385func (chat ChatMember ) WasKicked () bool { return chat .Status == "kicked" }
371386
387+ // Game is a game within Telegram.
388+ type Game struct {
389+ Title string `json:"title"`
390+ Description string `json:"description"`
391+ Photo []PhotoSize `json:"photo"`
392+ Text string `json:"text"`
393+ TextEntities []MessageEntity `json:"text_entities"`
394+ Animation Animation `json:"animation"`
395+ }
396+
397+ // Animation is a GIF animation demonstrating the game.
398+ type Animation struct {
399+ FileID string `json:"file_id"`
400+ Thumb PhotoSize `json:"thumb"`
401+ FileName string `json:"file_name"`
402+ MimeType string `json:"mime_type"`
403+ FileSize int `json:"file_size"`
404+ }
405+
406+ // GameHighScore is a user's score and position on the leaderboard.
407+ type GameHighScore struct {
408+ Position int `json:"position"`
409+ User User `json:"user"`
410+ Score int `json:"score"`
411+ }
412+
413+ // CallbackGame is for starting a game in an inline keyboard button.
414+ type CallbackGame struct {}
415+
416+ // WebhookInfo is information about a currently set webhook.
417+ type WebhookInfo struct {
418+ URL string `json:"url"`
419+ HasCustomCertificate bool `json:"has_custom_certificate"`
420+ PendingUpdateCount int `json:"pending_update_count"`
421+ LastErrorDate int `json:"last_error_date"` // optional
422+ LastErrorMessage string `json:"last_error_message"` // optional
423+ }
424+
425+ // IsSet returns true if a webhook is currently set.
426+ func (info WebhookInfo ) IsSet () bool {
427+ return info .URL != ""
428+ }
429+
372430// InlineQuery is a Query from Telegram for an inline request.
373431type InlineQuery struct {
374432 ID string `json:"id"`
@@ -460,6 +518,7 @@ type InlineQueryResultAudio struct {
460518 ID string `json:"id"` // required
461519 URL string `json:"audio_url"` // required
462520 Title string `json:"title"` // required
521+ Caption string `json:"caption"`
463522 Performer string `json:"performer"`
464523 Duration int `json:"audio_duration"`
465524 ReplyMarkup * InlineKeyboardMarkup `json:"reply_markup,omitempty"`
@@ -472,6 +531,7 @@ type InlineQueryResultVoice struct {
472531 ID string `json:"id"` // required
473532 URL string `json:"voice_url"` // required
474533 Title string `json:"title"` // required
534+ Caption string `json:"caption"`
475535 Duration int `json:"voice_duration"`
476536 ReplyMarkup * InlineKeyboardMarkup `json:"reply_markup,omitempty"`
477537 InputMessageContent interface {} `json:"input_message_content,omitempty"`
@@ -507,6 +567,14 @@ type InlineQueryResultLocation struct {
507567 ThumbHeight int `json:"thumb_height"`
508568}
509569
570+ // InlineQueryResultGame is an inline query response game.
571+ type InlineQueryResultGame struct {
572+ Type string `json:"type"`
573+ ID string `json:"id"`
574+ GameShortName string `json:"game_short_name"`
575+ ReplyMarkup * InlineKeyboardMarkup `json:"reply_markup"`
576+ }
577+
510578// ChosenInlineResult is an inline query result chosen by a User
511579type ChosenInlineResult struct {
512580 ResultID string `json:"result_id"`
0 commit comments