Implement Bot API 6.1 changes
parent
4126fa6112
commit
a89ebaebf3
|
@ -2,3 +2,4 @@
|
||||||
coverage.out
|
coverage.out
|
||||||
tmp/
|
tmp/
|
||||||
book/
|
book/
|
||||||
|
.vscode/
|
||||||
|
|
60
configs.go
60
configs.go
|
@ -1164,6 +1164,7 @@ type WebhookConfig struct {
|
||||||
MaxConnections int
|
MaxConnections int
|
||||||
AllowedUpdates []string
|
AllowedUpdates []string
|
||||||
DropPendingUpdates bool
|
DropPendingUpdates bool
|
||||||
|
SecretToken string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (config WebhookConfig) method() string {
|
func (config WebhookConfig) method() string {
|
||||||
|
@ -1181,6 +1182,7 @@ func (config WebhookConfig) params() (Params, error) {
|
||||||
params.AddNonZero("max_connections", config.MaxConnections)
|
params.AddNonZero("max_connections", config.MaxConnections)
|
||||||
err := params.AddInterface("allowed_updates", config.AllowedUpdates)
|
err := params.AddInterface("allowed_updates", config.AllowedUpdates)
|
||||||
params.AddBool("drop_pending_updates", config.DropPendingUpdates)
|
params.AddBool("drop_pending_updates", config.DropPendingUpdates)
|
||||||
|
params.AddNonEmpty("secret_token", config.SecretToken)
|
||||||
|
|
||||||
return params, err
|
return params, err
|
||||||
}
|
}
|
||||||
|
@ -1784,6 +1786,64 @@ func (config InvoiceConfig) method() string {
|
||||||
return "sendInvoice"
|
return "sendInvoice"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// InvoiceLinkConfig contains information for createInvoiceLink method
|
||||||
|
type InvoiceLinkConfig struct {
|
||||||
|
Title string //Required
|
||||||
|
Description string //Required
|
||||||
|
Payload string //Required
|
||||||
|
ProviderToken string //Required
|
||||||
|
Currency string //Required
|
||||||
|
Prices []LabeledPrice //Required
|
||||||
|
MaxTipAmount int
|
||||||
|
SuggestedTipAmounts []int
|
||||||
|
ProviderData string
|
||||||
|
PhotoURL string
|
||||||
|
PhotoSize int
|
||||||
|
PhotoWidth int
|
||||||
|
PhotoHeight int
|
||||||
|
NeedName bool
|
||||||
|
NeedPhoneNumber bool
|
||||||
|
NeedEmail bool
|
||||||
|
NeedShippingAddress bool
|
||||||
|
SendPhoneNumberToProvider bool
|
||||||
|
SendEmailToProvider bool
|
||||||
|
IsFlexible bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func (config InvoiceLinkConfig) params() (Params, error) {
|
||||||
|
params := make(Params)
|
||||||
|
|
||||||
|
params["title"] = config.Title
|
||||||
|
params["description"] = config.Description
|
||||||
|
params["payload"] = config.Payload
|
||||||
|
params["provider_token"] = config.ProviderToken
|
||||||
|
params["currency"] = config.Currency
|
||||||
|
if err := params.AddInterface("prices", config.Prices); err != nil {
|
||||||
|
return params, err
|
||||||
|
}
|
||||||
|
|
||||||
|
params.AddNonZero("max_tip_amount", config.MaxTipAmount)
|
||||||
|
err := params.AddInterface("suggested_tip_amounts", config.SuggestedTipAmounts)
|
||||||
|
params.AddNonEmpty("provider_data", config.ProviderData)
|
||||||
|
params.AddNonEmpty("photo_url", config.PhotoURL)
|
||||||
|
params.AddNonZero("photo_size", config.PhotoSize)
|
||||||
|
params.AddNonZero("photo_width", config.PhotoWidth)
|
||||||
|
params.AddNonZero("photo_height", config.PhotoHeight)
|
||||||
|
params.AddBool("need_name", config.NeedName)
|
||||||
|
params.AddBool("need_phone_number", config.NeedPhoneNumber)
|
||||||
|
params.AddBool("need_email", config.NeedEmail)
|
||||||
|
params.AddBool("need_shipping_address", config.NeedShippingAddress)
|
||||||
|
params.AddBool("send_phone_number_to_provider", config.SendPhoneNumberToProvider)
|
||||||
|
params.AddBool("send_email_to_provider", config.SendEmailToProvider)
|
||||||
|
params.AddBool("is_flexible", config.IsFlexible)
|
||||||
|
|
||||||
|
return params, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (config InvoiceLinkConfig) method() string {
|
||||||
|
return "createInvoiceLink"
|
||||||
|
}
|
||||||
|
|
||||||
// ShippingConfig contains information for answerShippingQuery request.
|
// ShippingConfig contains information for answerShippingQuery request.
|
||||||
type ShippingConfig struct {
|
type ShippingConfig struct {
|
||||||
ShippingQueryID string // required
|
ShippingQueryID string // required
|
||||||
|
|
28
types.go
28
types.go
|
@ -187,6 +187,10 @@ type User struct {
|
||||||
//
|
//
|
||||||
// optional
|
// optional
|
||||||
IsPremium bool `json:"is_premium,omitempty"`
|
IsPremium bool `json:"is_premium,omitempty"`
|
||||||
|
// AddedToAttachmentMenu true, if this user added the bot to the attachment menu
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
AddedToAttachmentMenu bool `json:"added_to_attachment_menu,omitempty"`
|
||||||
// FirstName user's or bot's first name
|
// FirstName user's or bot's first name
|
||||||
FirstName string `json:"first_name"`
|
FirstName string `json:"first_name"`
|
||||||
// LastName user's or bot's last name
|
// LastName user's or bot's last name
|
||||||
|
@ -274,6 +278,18 @@ type Chat struct {
|
||||||
//
|
//
|
||||||
// optional
|
// optional
|
||||||
HasPrivateForwards bool `json:"has_private_forwards,omitempty"`
|
HasPrivateForwards bool `json:"has_private_forwards,omitempty"`
|
||||||
|
// JoinToSendMessages is true, if users need to join the supergroup
|
||||||
|
// before they can send messages.
|
||||||
|
// Returned only in getChat
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
JoinToSendMessages bool `json:"join_to_send_messages,omitempty"`
|
||||||
|
// JoinByRequest is true, if all users directly joining the supergroup
|
||||||
|
// need to be approved by supergroup administrators.
|
||||||
|
// Returned only in getChat.
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
JoinByRequest bool `json:"join_by_request,omitempty"`
|
||||||
// Description for groups, supergroups and channel chats
|
// Description for groups, supergroups and channel chats
|
||||||
//
|
//
|
||||||
// optional
|
// optional
|
||||||
|
@ -863,7 +879,7 @@ type Animation struct {
|
||||||
// FileSize file size
|
// FileSize file size
|
||||||
//
|
//
|
||||||
// optional
|
// optional
|
||||||
FileSize int `json:"file_size,omitempty"`
|
FileSize int64 `json:"file_size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Audio represents an audio file to be treated as music by the Telegram clients.
|
// Audio represents an audio file to be treated as music by the Telegram clients.
|
||||||
|
@ -896,7 +912,7 @@ type Audio struct {
|
||||||
// FileSize file size
|
// FileSize file size
|
||||||
//
|
//
|
||||||
// optional
|
// optional
|
||||||
FileSize int `json:"file_size,omitempty"`
|
FileSize int64 `json:"file_size,omitempty"`
|
||||||
// Thumbnail is the album cover to which the music file belongs
|
// Thumbnail is the album cover to which the music file belongs
|
||||||
//
|
//
|
||||||
// optional
|
// optional
|
||||||
|
@ -927,7 +943,7 @@ type Document struct {
|
||||||
// FileSize file size
|
// FileSize file size
|
||||||
//
|
//
|
||||||
// optional
|
// optional
|
||||||
FileSize int `json:"file_size,omitempty"`
|
FileSize int64 `json:"file_size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Video represents a video file.
|
// Video represents a video file.
|
||||||
|
@ -960,7 +976,7 @@ type Video struct {
|
||||||
// FileSize file size
|
// FileSize file size
|
||||||
//
|
//
|
||||||
// optional
|
// optional
|
||||||
FileSize int `json:"file_size,omitempty"`
|
FileSize int64 `json:"file_size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// VideoNote object represents a video message.
|
// VideoNote object represents a video message.
|
||||||
|
@ -1002,7 +1018,7 @@ type Voice struct {
|
||||||
// FileSize file size
|
// FileSize file size
|
||||||
//
|
//
|
||||||
// optional
|
// optional
|
||||||
FileSize int `json:"file_size,omitempty"`
|
FileSize int64 `json:"file_size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Contact represents a phone contact.
|
// Contact represents a phone contact.
|
||||||
|
@ -1234,7 +1250,7 @@ type File struct {
|
||||||
// FileSize file size, if known
|
// FileSize file size, if known
|
||||||
//
|
//
|
||||||
// optional
|
// optional
|
||||||
FileSize int `json:"file_size,omitempty"`
|
FileSize int64 `json:"file_size,omitempty"`
|
||||||
// FilePath file path
|
// FilePath file path
|
||||||
//
|
//
|
||||||
// optional
|
// optional
|
||||||
|
|
Loading…
Reference in New Issue