@@ -12,10 +12,17 @@ import (
12
12
// APIResponse is a response from the Telegram API with the result
13
13
// stored raw.
14
14
type 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
19
26
}
20
27
21
28
// Update is an update response, from GetUpdates.
@@ -61,12 +68,13 @@ type GroupChat struct {
61
68
62
69
// Chat contains information about the place a message was sent.
63
70
type 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
70
78
}
71
79
72
80
// IsPrivate returns if the Chat is a private conversation.
@@ -110,6 +118,7 @@ type Message struct {
110
118
Entities * []MessageEntity `json:"entities"` // optional
111
119
Audio * Audio `json:"audio"` // optional
112
120
Document * Document `json:"document"` // optional
121
+ Game * Game `json:"game"` // optional
113
122
Photo * []PhotoSize `json:"photo"` // optional
114
123
Sticker * Sticker `json:"sticker"` // optional
115
124
Video * Video `json:"video"` // optional
@@ -324,11 +333,15 @@ type InlineKeyboardMarkup struct {
324
333
//
325
334
// Note that some values are references as even an empty string
326
335
// will change behavior.
336
+ //
337
+ // CallbackGame, if set, MUST be first button in first row.
327
338
type 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
332
345
}
333
346
334
347
// CallbackQuery is data sent when a keyboard button with callback data
@@ -338,7 +351,9 @@ type CallbackQuery struct {
338
351
From * User `json:"from"`
339
352
Message * Message `json:"message"` // optional
340
353
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
342
357
}
343
358
344
359
// 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" }
369
384
// WasKicked returns if the ChatMember was kicked from the chat.
370
385
func (chat ChatMember ) WasKicked () bool { return chat .Status == "kicked" }
371
386
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
+
372
430
// InlineQuery is a Query from Telegram for an inline request.
373
431
type InlineQuery struct {
374
432
ID string `json:"id"`
@@ -460,6 +518,7 @@ type InlineQueryResultAudio struct {
460
518
ID string `json:"id"` // required
461
519
URL string `json:"audio_url"` // required
462
520
Title string `json:"title"` // required
521
+ Caption string `json:"caption"`
463
522
Performer string `json:"performer"`
464
523
Duration int `json:"audio_duration"`
465
524
ReplyMarkup * InlineKeyboardMarkup `json:"reply_markup,omitempty"`
@@ -472,6 +531,7 @@ type InlineQueryResultVoice struct {
472
531
ID string `json:"id"` // required
473
532
URL string `json:"voice_url"` // required
474
533
Title string `json:"title"` // required
534
+ Caption string `json:"caption"`
475
535
Duration int `json:"voice_duration"`
476
536
ReplyMarkup * InlineKeyboardMarkup `json:"reply_markup,omitempty"`
477
537
InputMessageContent interface {} `json:"input_message_content,omitempty"`
@@ -507,6 +567,14 @@ type InlineQueryResultLocation struct {
507
567
ThumbHeight int `json:"thumb_height"`
508
568
}
509
569
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
+
510
578
// ChosenInlineResult is an inline query result chosen by a User
511
579
type ChosenInlineResult struct {
512
580
ResultID string `json:"result_id"`
0 commit comments