Skip to content

Commit 2c2c95a

Browse files
authored
Merge pull request #443 from go-telegram-bot-api/bot-api-5.2
Updates for Bot API 5.2, other small fixes
2 parents d0e1dfd + b4a22fe commit 2c2c95a

File tree

2 files changed

+146
-28
lines changed

2 files changed

+146
-28
lines changed

configs.go

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,15 @@ const (
1818

1919
// Constant values for ChatActions
2020
const (
21-
ChatTyping = "typing"
22-
ChatUploadPhoto = "upload_photo"
23-
ChatRecordVideo = "record_video"
24-
ChatUploadVideo = "upload_video"
25-
ChatRecordAudio = "record_audio"
21+
ChatTyping = "typing"
22+
ChatUploadPhoto = "upload_photo"
23+
ChatRecordVideo = "record_video"
24+
ChatUploadVideo = "upload_video"
25+
ChatRecordVoice = "record_voice"
26+
ChatUploadVoice = "upload_voice"
27+
// Deprecated: use ChatRecordVoice instead.
28+
ChatRecordAudio = "record_audio"
29+
// Deprecated: use ChatUploadVoice instead.
2630
ChatUploadAudio = "upload_audio"
2731
ChatUploadDocument = "upload_document"
2832
ChatFindLocation = "find_location"
@@ -1506,9 +1510,11 @@ type InvoiceConfig struct {
15061510
Description string // required
15071511
Payload string // required
15081512
ProviderToken string // required
1509-
StartParameter string // required
15101513
Currency string // required
15111514
Prices []LabeledPrice // required
1515+
MaxTipAmount int
1516+
SuggestedTipAmounts []int
1517+
StartParameter string
15121518
ProviderData string
15131519
PhotoURL string
15141520
PhotoSize int
@@ -1533,10 +1539,14 @@ func (config InvoiceConfig) params() (Params, error) {
15331539
params["description"] = config.Description
15341540
params["payload"] = config.Payload
15351541
params["provider_token"] = config.ProviderToken
1536-
params["start_parameter"] = config.StartParameter
15371542
params["currency"] = config.Currency
1543+
if err = params.AddInterface("prices", config.Prices); err != nil {
1544+
return params, err
1545+
}
15381546

1539-
err = params.AddInterface("prices", config.Prices)
1547+
params.AddNonZero("max_tip_amount", config.MaxTipAmount)
1548+
err = params.AddInterface("suggested_tip_amounts", config.SuggestedTipAmounts)
1549+
params.AddNonEmpty("start_parameter", config.StartParameter)
15401550
params.AddNonEmpty("provider_data", config.ProviderData)
15411551
params.AddNonEmpty("photo_url", config.PhotoURL)
15421552
params.AddNonZero("photo_size", config.PhotoSize)

types.go

Lines changed: 128 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,10 @@ type Message struct {
519519
//
520520
// optional
521521
ProximityAlertTriggered *ProximityAlertTriggered `json:"proximity_alert_triggered"`
522+
// VoiceChatScheduled is a service message: voice chat scheduled.
523+
//
524+
// optional
525+
VoiceChatScheduled *VoiceChatScheduled `json:"voice_chat_scheduled"`
522526
// VoiceChatStarted is a service message: voice chat started.
523527
//
524528
// optional
@@ -1068,6 +1072,19 @@ type MessageAutoDeleteTimerChanged struct {
10681072
MessageAutoDeleteTime int `json:"message_auto_delete_time"`
10691073
}
10701074

1075+
// VoiceChatScheduled represents a service message about a voice chat scheduled
1076+
// in the chat.
1077+
type VoiceChatScheduled struct {
1078+
// Point in time (Unix timestamp) when the voice chat is supposed to be
1079+
// started by a chat administrator
1080+
StartDate int `json:"start_date"`
1081+
}
1082+
1083+
// Time converts the scheduled start date into a Time.
1084+
func (m *VoiceChatScheduled) Time() time.Time {
1085+
return time.Unix(int64(m.StartDate), 0)
1086+
}
1087+
10711088
// VoiceChatStarted represents a service message about a voice chat started in
10721089
// the chat.
10731090
type VoiceChatStarted struct{}
@@ -1680,7 +1697,7 @@ type InputMediaVideo struct {
16801697
// the file is supported server-side.
16811698
//
16821699
// optional
1683-
Thumb interface{} `json:"thumb"`
1700+
Thumb interface{} `json:"thumb,omitempty"`
16841701
// Width video width
16851702
//
16861703
// optional
@@ -1706,7 +1723,7 @@ type InputMediaAnimation struct {
17061723
// the file is supported server-side.
17071724
//
17081725
// optional
1709-
Thumb interface{} `json:"thumb"`
1726+
Thumb interface{} `json:"thumb,omitempty"`
17101727
// Width video width
17111728
//
17121729
// optional
@@ -1728,7 +1745,7 @@ type InputMediaAudio struct {
17281745
// the file is supported server-side.
17291746
//
17301747
// optional
1731-
Thumb interface{} `json:"thumb"`
1748+
Thumb interface{} `json:"thumb,omitempty"`
17321749
// Duration of the audio in seconds
17331750
//
17341751
// optional
@@ -1750,7 +1767,7 @@ type InputMediaDocument struct {
17501767
// the file is supported server-side.
17511768
//
17521769
// optional
1753-
Thumb interface{} `json:"thumb"`
1770+
Thumb interface{} `json:"thumb,omitempty"`
17541771
// DisableContentTypeDetection disables automatic server-side content type
17551772
// detection for files uploaded using multipart/form-data. Always true, if
17561773
// the document is sent as part of an album
@@ -1917,14 +1934,22 @@ type InlineQuery struct {
19171934
ID string `json:"id"`
19181935
// From sender
19191936
From *User `json:"from"`
1920-
// Location sender location, only for bots that request user location.
1921-
//
1922-
// optional
1923-
Location *Location `json:"location,omitempty"`
19241937
// Query text of the query (up to 256 characters).
19251938
Query string `json:"query"`
19261939
// Offset of the results to be returned, can be controlled by the bot.
19271940
Offset string `json:"offset"`
1941+
// Type of the chat, from which the inline query was sent. Can be either
1942+
// “sender” for a private chat with the inline query sender, “private”,
1943+
// “group”, “supergroup”, or “channel”. The chat type should be always known
1944+
// for requests sent from official clients and most third-party clients,
1945+
// unless the request was sent from a secret chat
1946+
//
1947+
// optional
1948+
ChatType string `json:"chat_type"`
1949+
// Location sender location, only for bots that request user location.
1950+
//
1951+
// optional
1952+
Location *Location `json:"location,omitempty"`
19281953
}
19291954

19301955
// InlineQueryResultCachedAudio is an inline query response with cached audio.
@@ -1949,7 +1974,7 @@ type InlineQueryResultCachedAudio struct {
19491974
// which can be specified instead of parse_mode
19501975
//
19511976
// optional
1952-
CaptionEntities []MessageEntity `json:"caption_entities"`
1977+
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
19531978
// ReplyMarkup inline keyboard attached to the message
19541979
//
19551980
// optional
@@ -1990,7 +2015,7 @@ type InlineQueryResultCachedDocument struct {
19902015
// which can be specified instead of parse_mode
19912016
//
19922017
// optional
1993-
CaptionEntities []MessageEntity `json:"caption_entities"`
2018+
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
19942019
// ReplyMarkup inline keyboard attached to the message
19952020
//
19962021
// optional
@@ -2027,7 +2052,7 @@ type InlineQueryResultCachedGIF struct {
20272052
// which can be specified instead of parse_mode
20282053
//
20292054
// optional
2030-
CaptionEntities []MessageEntity `json:"caption_entities"`
2055+
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
20312056
// ReplyMarkup inline keyboard attached to the message.
20322057
//
20332058
// optional
@@ -2066,7 +2091,7 @@ type InlineQueryResultCachedMPEG4GIF struct {
20662091
// (https://core.telegram.org/bots/api#formatting-options).
20672092
//
20682093
// optional
2069-
CaptionEntities []MessageEntity `json:"caption_entities"`
2094+
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
20702095
// ReplyMarkup inline keyboard attached to the message.
20712096
//
20722097
// optional
@@ -2107,7 +2132,7 @@ type InlineQueryResultCachedPhoto struct {
21072132
// which can be specified instead of parse_mode
21082133
//
21092134
// optional
2110-
CaptionEntities []MessageEntity `json:"caption_entities"`
2135+
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
21112136
// ReplyMarkup inline keyboard attached to the message.
21122137
//
21132138
// optional
@@ -2166,7 +2191,7 @@ type InlineQueryResultCachedVideo struct {
21662191
// which can be specified instead of parse_mode
21672192
//
21682193
// optional
2169-
CaptionEntities []MessageEntity `json:"caption_entities"`
2194+
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
21702195
// ReplyMarkup inline keyboard attached to the message
21712196
//
21722197
// optional
@@ -2201,7 +2226,7 @@ type InlineQueryResultCachedVoice struct {
22012226
// which can be specified instead of parse_mode
22022227
//
22032228
// optional
2204-
CaptionEntities []MessageEntity `json:"caption_entities"`
2229+
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
22052230
// ReplyMarkup inline keyboard attached to the message
22062231
//
22072232
// optional
@@ -2276,7 +2301,7 @@ type InlineQueryResultAudio struct {
22762301
// which can be specified instead of parse_mode
22772302
//
22782303
// optional
2279-
CaptionEntities []MessageEntity `json:"caption_entities"`
2304+
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
22802305
// Performer is a performer
22812306
//
22822307
// optional
@@ -2406,7 +2431,7 @@ type InlineQueryResultGIF struct {
24062431
// which can be specified instead of parse_mode
24072432
//
24082433
// optional
2409-
CaptionEntities []MessageEntity `json:"caption_entities"`
2434+
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
24102435
// ReplyMarkup inline keyboard attached to the message
24112436
//
24122437
// optional
@@ -2512,7 +2537,7 @@ type InlineQueryResultMPEG4GIF struct {
25122537
// which can be specified instead of parse_mode
25132538
//
25142539
// optional
2515-
CaptionEntities []MessageEntity `json:"caption_entities"`
2540+
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
25162541
// ReplyMarkup inline keyboard attached to the message
25172542
//
25182543
// optional
@@ -2572,7 +2597,7 @@ type InlineQueryResultPhoto struct {
25722597
// which can be specified instead of parse_mode
25732598
//
25742599
// optional
2575-
CaptionEntities []MessageEntity `json:"caption_entities"`
2600+
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
25762601
// InputMessageContent content of the message to be sent instead of the photo.
25772602
//
25782603
// optional
@@ -2704,7 +2729,7 @@ type InlineQueryResultVoice struct {
27042729
// which can be specified instead of parse_mode
27052730
//
27062731
// optional
2707-
CaptionEntities []MessageEntity `json:"caption_entities"`
2732+
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
27082733
// Duration recording duration in seconds
27092734
//
27102735
// optional
@@ -2837,6 +2862,89 @@ type InputContactMessageContent struct {
28372862
VCard string `json:"vcard,omitempty"`
28382863
}
28392864

2865+
// InputInvoiceMessageContent represents the content of an invoice message to be
2866+
// sent as the result of an inline query.
2867+
type InputInvoiceMessageContent struct {
2868+
// Product name, 1-32 characters
2869+
Title string `json:"title"`
2870+
// Product description, 1-255 characters
2871+
Description string `json:"description"`
2872+
// Bot-defined invoice payload, 1-128 bytes. This will not be displayed to
2873+
// the user, use for your internal processes.
2874+
Payload string `json:"payload"`
2875+
// Payment provider token, obtained via Botfather
2876+
ProviderToken string `json:"provider_token"`
2877+
// Three-letter ISO 4217 currency code
2878+
Currency string `json:"currency"`
2879+
// Price breakdown, a JSON-serialized list of components (e.g. product
2880+
// price, tax, discount, delivery cost, delivery tax, bonus, etc.)
2881+
Prices []LabeledPrice `json:"prices"`
2882+
// The maximum accepted amount for tips in the smallest units of the
2883+
// currency (integer, not float/double).
2884+
//
2885+
// optional
2886+
MaxTipAmount int `json:"max_tip_amount,omitempty"`
2887+
// An array of suggested amounts of tip in the smallest units of the
2888+
// currency (integer, not float/double). At most 4 suggested tip amounts can
2889+
// be specified. The suggested tip amounts must be positive, passed in a
2890+
// strictly increased order and must not exceed max_tip_amount.
2891+
//
2892+
// optional
2893+
SuggestedTipAmounts []int `json:"suggested_tip_amounts,omitempty"`
2894+
// A JSON-serialized object for data about the invoice, which will be shared
2895+
// with the payment provider. A detailed description of the required fields
2896+
// should be provided by the payment provider.
2897+
//
2898+
// optional
2899+
ProviderData string `json:"provider_data,omitempty"`
2900+
// URL of the product photo for the invoice. Can be a photo of the goods or
2901+
// a marketing image for a service. People like it better when they see what
2902+
// they are paying for.
2903+
//
2904+
// optional
2905+
PhotoURL string `json:"photo_url,omitempty"`
2906+
// Photo size
2907+
//
2908+
// optional
2909+
PhotoSize int `json:"photo_size,omitempty"`
2910+
// Photo width
2911+
//
2912+
// optional
2913+
PhotoWidth int `json:"photo_width,omitempty"`
2914+
// Photo height
2915+
//
2916+
// optional
2917+
PhotoHeight int `json:"photo_height,omitempty"`
2918+
// Pass True, if you require the user's full name to complete the order
2919+
//
2920+
// optional
2921+
NeedName bool `json:"need_name,omitempty"`
2922+
// Pass True, if you require the user's phone number to complete the order
2923+
//
2924+
// optional
2925+
NeedPhoneNumber bool `json:"need_phone_number,omitempty"`
2926+
// Pass True, if you require the user's email address to complete the order
2927+
//
2928+
// optional
2929+
NeedEmail bool `json:"need_email,omitempty"`
2930+
// Pass True, if you require the user's shipping address to complete the order
2931+
//
2932+
// optional
2933+
NeedShippingAddress bool `json:"need_shipping_address,omitempty"`
2934+
// Pass True, if user's phone number should be sent to provider
2935+
//
2936+
// optional
2937+
SendPhoneNumberToProvider bool `json:"send_phone_number_to_provider,omitempty"`
2938+
// Pass True, if user's email address should be sent to provider
2939+
//
2940+
// optional
2941+
SendEmailToProvider bool `json:"send_email_to_provider,omitempty"`
2942+
// Pass True, if the final price depends on the shipping method
2943+
//
2944+
// optional
2945+
IsFlexible bool `json:"is_flexible,omitempty"`
2946+
}
2947+
28402948
// LabeledPrice represents a portion of the price for goods or services.
28412949
type LabeledPrice struct {
28422950
// Label portion label

0 commit comments

Comments
 (0)