Updates for Bot API 5.0.
parent
18c023f584
commit
ac5306ce0c
|
@ -477,7 +477,7 @@ func TestSetWebhookWithCert(t *testing.T) {
|
|||
|
||||
time.Sleep(time.Second * 2)
|
||||
|
||||
bot.Request(RemoveWebhookConfig{})
|
||||
bot.Request(DeleteWebhookConfig{})
|
||||
|
||||
wh := NewWebhookWithCert("https://example.com/tgbotapi-test/"+bot.Token, "tests/cert.pem")
|
||||
_, err := bot.Request(wh)
|
||||
|
@ -491,7 +491,7 @@ func TestSetWebhookWithCert(t *testing.T) {
|
|||
t.Error(err)
|
||||
}
|
||||
|
||||
bot.Request(RemoveWebhookConfig{})
|
||||
bot.Request(DeleteWebhookConfig{})
|
||||
}
|
||||
|
||||
func TestSetWebhookWithoutCert(t *testing.T) {
|
||||
|
@ -499,7 +499,7 @@ func TestSetWebhookWithoutCert(t *testing.T) {
|
|||
|
||||
time.Sleep(time.Second * 2)
|
||||
|
||||
bot.Request(RemoveWebhookConfig{})
|
||||
bot.Request(DeleteWebhookConfig{})
|
||||
|
||||
wh := NewWebhook("https://example.com/tgbotapi-test/" + bot.Token)
|
||||
_, err := bot.Request(wh)
|
||||
|
@ -519,7 +519,7 @@ func TestSetWebhookWithoutCert(t *testing.T) {
|
|||
t.Errorf("failed to set webhook: %s", info.LastErrorMessage)
|
||||
}
|
||||
|
||||
bot.Request(RemoveWebhookConfig{})
|
||||
bot.Request(DeleteWebhookConfig{})
|
||||
}
|
||||
|
||||
func TestSendWithMediaGroup(t *testing.T) {
|
||||
|
|
173
configs.go
173
configs.go
|
@ -63,6 +63,33 @@ type Fileable interface {
|
|||
useExistingFile() bool
|
||||
}
|
||||
|
||||
// LogOutConfig is a request to log out of the cloud Bot API server.
|
||||
//
|
||||
// Note that you may not log back in for at least 10 minutes.
|
||||
type LogOutConfig struct{}
|
||||
|
||||
func (LogOutConfig) method() string {
|
||||
return "logOut"
|
||||
}
|
||||
|
||||
func (LogOutConfig) params() (Params, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// CloseConfig is a request to close the bot instance on a local server.
|
||||
//
|
||||
// Note that you may not close an instance for the first 10 minutes after the
|
||||
// bot has started.
|
||||
type CloseConfig struct{}
|
||||
|
||||
func (CloseConfig) method() string {
|
||||
return "close"
|
||||
}
|
||||
|
||||
func (CloseConfig) params() (Params, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// BaseChat is base type for all chat config types.
|
||||
type BaseChat struct {
|
||||
ChatID int64 // required
|
||||
|
@ -70,6 +97,7 @@ type BaseChat struct {
|
|||
ReplyToMessageID int
|
||||
ReplyMarkup interface{}
|
||||
DisableNotification bool
|
||||
AllowSendingWithoutReply bool
|
||||
}
|
||||
|
||||
func (chat *BaseChat) params() (Params, error) {
|
||||
|
@ -78,6 +106,7 @@ func (chat *BaseChat) params() (Params, error) {
|
|||
params.AddFirstValid("chat_id", chat.ChatID, chat.ChannelUsername)
|
||||
params.AddNonZero("reply_to_message_id", chat.ReplyToMessageID)
|
||||
params.AddBool("disable_notification", chat.DisableNotification)
|
||||
params.AddBool("allow_sending_without_reply", chat.AllowSendingWithoutReply)
|
||||
|
||||
err := params.AddInterface("reply_markup", chat.ReplyMarkup)
|
||||
|
||||
|
@ -140,6 +169,7 @@ type MessageConfig struct {
|
|||
BaseChat
|
||||
Text string
|
||||
ParseMode string
|
||||
Entities []MessageEntity
|
||||
DisableWebPagePreview bool
|
||||
}
|
||||
|
||||
|
@ -152,8 +182,9 @@ func (config MessageConfig) params() (Params, error) {
|
|||
params.AddNonEmpty("text", config.Text)
|
||||
params.AddBool("disable_web_page_preview", config.DisableWebPagePreview)
|
||||
params.AddNonEmpty("parse_mode", config.ParseMode)
|
||||
err = params.AddInterface("entities", config.Entities)
|
||||
|
||||
return params, nil
|
||||
return params, err
|
||||
}
|
||||
|
||||
func (config MessageConfig) method() string {
|
||||
|
@ -184,19 +215,50 @@ func (config ForwardConfig) method() string {
|
|||
return "forwardMessage"
|
||||
}
|
||||
|
||||
// CopyMessageConfig contains information about a copyMessage request.
|
||||
type CopyMessageConfig struct {
|
||||
BaseChat
|
||||
FromChatID int64
|
||||
FromChannelUsername string
|
||||
MessageID int
|
||||
Caption string
|
||||
ParseMode string
|
||||
CaptionEntities []MessageEntity
|
||||
}
|
||||
|
||||
func (config CopyMessageConfig) params() (Params, error) {
|
||||
params, err := config.BaseChat.params()
|
||||
if err != nil {
|
||||
return params, err
|
||||
}
|
||||
|
||||
params.AddFirstValid("from_chat_id", config.FromChatID, config.FromChannelUsername)
|
||||
params.AddNonZero("message_id", config.MessageID)
|
||||
params.AddNonEmpty("caption", config.Caption)
|
||||
params.AddNonEmpty("parse_mode", config.ParseMode)
|
||||
err = params.AddInterface("caption_entities", config.CaptionEntities)
|
||||
|
||||
return params, err
|
||||
}
|
||||
|
||||
// PhotoConfig contains information about a SendPhoto request.
|
||||
type PhotoConfig struct {
|
||||
BaseFile
|
||||
Caption string
|
||||
ParseMode string
|
||||
CaptionEntities []MessageEntity
|
||||
}
|
||||
|
||||
func (config PhotoConfig) params() (Params, error) {
|
||||
params, err := config.BaseFile.params()
|
||||
if err != nil {
|
||||
return params, err
|
||||
}
|
||||
|
||||
params.AddNonEmpty(config.name(), config.FileID)
|
||||
params.AddNonEmpty("caption", config.Caption)
|
||||
params.AddNonEmpty("parse_mode", config.ParseMode)
|
||||
err = params.AddInterface("caption_entities", config.CaptionEntities)
|
||||
|
||||
return params, err
|
||||
}
|
||||
|
@ -214,6 +276,7 @@ type AudioConfig struct {
|
|||
BaseFile
|
||||
Caption string
|
||||
ParseMode string
|
||||
CaptionEntities []MessageEntity
|
||||
Duration int
|
||||
Performer string
|
||||
Title string
|
||||
|
@ -231,8 +294,9 @@ func (config AudioConfig) params() (Params, error) {
|
|||
params.AddNonEmpty("title", config.Title)
|
||||
params.AddNonEmpty("caption", config.Caption)
|
||||
params.AddNonEmpty("parse_mode", config.ParseMode)
|
||||
err = params.AddInterface("caption_entities", config.CaptionEntities)
|
||||
|
||||
return params, nil
|
||||
return params, err
|
||||
}
|
||||
|
||||
func (config AudioConfig) name() string {
|
||||
|
@ -248,6 +312,8 @@ type DocumentConfig struct {
|
|||
BaseFile
|
||||
Caption string
|
||||
ParseMode string
|
||||
CaptionEntities []MessageEntity
|
||||
DisableContentTypeDetection bool
|
||||
}
|
||||
|
||||
func (config DocumentConfig) params() (Params, error) {
|
||||
|
@ -256,6 +322,7 @@ func (config DocumentConfig) params() (Params, error) {
|
|||
params.AddNonEmpty(config.name(), config.FileID)
|
||||
params.AddNonEmpty("caption", config.Caption)
|
||||
params.AddNonEmpty("parse_mode", config.ParseMode)
|
||||
params.AddBool("disable_content_type_detection", config.DisableContentTypeDetection)
|
||||
|
||||
return params, err
|
||||
}
|
||||
|
@ -295,17 +362,22 @@ type VideoConfig struct {
|
|||
Duration int
|
||||
Caption string
|
||||
ParseMode string
|
||||
CaptionEntities []MessageEntity
|
||||
SupportsStreaming bool
|
||||
}
|
||||
|
||||
func (config VideoConfig) params() (Params, error) {
|
||||
params, err := config.BaseChat.params()
|
||||
if err != nil {
|
||||
return params, err
|
||||
}
|
||||
|
||||
params.AddNonEmpty(config.name(), config.FileID)
|
||||
params.AddNonZero("duration", config.Duration)
|
||||
params.AddNonEmpty("caption", config.Caption)
|
||||
params.AddNonEmpty("parse_mode", config.ParseMode)
|
||||
params.AddBool("supports_streaming", config.SupportsStreaming)
|
||||
err = params.AddInterface("caption_entities", config.CaptionEntities)
|
||||
|
||||
return params, err
|
||||
}
|
||||
|
@ -324,15 +396,20 @@ type AnimationConfig struct {
|
|||
Duration int
|
||||
Caption string
|
||||
ParseMode string
|
||||
CaptionEntities []MessageEntity
|
||||
}
|
||||
|
||||
func (config AnimationConfig) params() (Params, error) {
|
||||
params, err := config.BaseChat.params()
|
||||
if err != nil {
|
||||
return params, err
|
||||
}
|
||||
|
||||
params.AddNonEmpty(config.name(), config.FileID)
|
||||
params.AddNonZero("duration", config.Duration)
|
||||
params.AddNonEmpty("caption", config.Caption)
|
||||
params.AddNonEmpty("parse_mode", config.ParseMode)
|
||||
err = params.AddInterface("caption_entities", config.CaptionEntities)
|
||||
|
||||
return params, err
|
||||
}
|
||||
|
@ -375,16 +452,21 @@ type VoiceConfig struct {
|
|||
BaseFile
|
||||
Caption string
|
||||
ParseMode string
|
||||
CaptionEntities []MessageEntity
|
||||
Duration int
|
||||
}
|
||||
|
||||
func (config VoiceConfig) params() (Params, error) {
|
||||
params, err := config.BaseChat.params()
|
||||
if err != nil {
|
||||
return params, err
|
||||
}
|
||||
|
||||
params.AddNonEmpty(config.name(), config.FileID)
|
||||
params.AddNonZero("duration", config.Duration)
|
||||
params.AddNonEmpty("caption", config.Caption)
|
||||
params.AddNonEmpty("parse_mode", config.ParseMode)
|
||||
err = params.AddInterface("caption_entities", config.CaptionEntities)
|
||||
|
||||
return params, err
|
||||
}
|
||||
|
@ -402,7 +484,10 @@ type LocationConfig struct {
|
|||
BaseChat
|
||||
Latitude float64 // required
|
||||
Longitude float64 // required
|
||||
HorizontalAccuracy float64 // optional
|
||||
LivePeriod int // optional
|
||||
Heading int // optional
|
||||
ProximityAlertRadius int // optional
|
||||
}
|
||||
|
||||
func (config LocationConfig) params() (Params, error) {
|
||||
|
@ -410,7 +495,10 @@ func (config LocationConfig) params() (Params, error) {
|
|||
|
||||
params.AddNonZeroFloat("latitude", config.Latitude)
|
||||
params.AddNonZeroFloat("longitude", config.Longitude)
|
||||
params.AddNonZeroFloat("horizontal_accuracy", config.HorizontalAccuracy)
|
||||
params.AddNonZero("live_period", config.LivePeriod)
|
||||
params.AddNonZero("heading", config.Heading)
|
||||
params.AddNonZero("proximity_alert_radius", config.ProximityAlertRadius)
|
||||
|
||||
return params, err
|
||||
}
|
||||
|
@ -424,6 +512,9 @@ type EditMessageLiveLocationConfig struct {
|
|||
BaseEdit
|
||||
Latitude float64 // required
|
||||
Longitude float64 // required
|
||||
HorizontalAccuracy float64 // optional
|
||||
Heading int // optional
|
||||
ProximityAlertRadius int // optional
|
||||
}
|
||||
|
||||
func (config EditMessageLiveLocationConfig) params() (Params, error) {
|
||||
|
@ -431,6 +522,9 @@ func (config EditMessageLiveLocationConfig) params() (Params, error) {
|
|||
|
||||
params.AddNonZeroFloat("latitude", config.Latitude)
|
||||
params.AddNonZeroFloat("longitude", config.Longitude)
|
||||
params.AddNonZeroFloat("horizontal_accuracy", config.HorizontalAccuracy)
|
||||
params.AddNonZero("heading", config.Heading)
|
||||
params.AddNonZero("proximity_alert_radius", config.ProximityAlertRadius)
|
||||
|
||||
return params, err
|
||||
}
|
||||
|
@ -460,6 +554,9 @@ type VenueConfig struct {
|
|||
Title string // required
|
||||
Address string // required
|
||||
FoursquareID string
|
||||
FoursquareType string
|
||||
GooglePlaceID string
|
||||
GooglePlaceType string
|
||||
}
|
||||
|
||||
func (config VenueConfig) params() (Params, error) {
|
||||
|
@ -470,6 +567,9 @@ func (config VenueConfig) params() (Params, error) {
|
|||
params["title"] = config.Title
|
||||
params["address"] = config.Address
|
||||
params.AddNonEmpty("foursquare_id", config.FoursquareID)
|
||||
params.AddNonEmpty("foursquare_type", config.FoursquareType)
|
||||
params.AddNonEmpty("google_place_id", config.GooglePlaceID)
|
||||
params.AddNonEmpty("google_place_type", config.GooglePlaceType)
|
||||
|
||||
return params, err
|
||||
}
|
||||
|
@ -514,6 +614,7 @@ type SendPollConfig struct {
|
|||
CorrectOptionID int64
|
||||
Explanation string
|
||||
ExplanationParseMode string
|
||||
ExplanationEntities []MessageEntity
|
||||
OpenPeriod int
|
||||
CloseDate int
|
||||
IsClosed bool
|
||||
|
@ -526,7 +627,9 @@ func (config SendPollConfig) params() (Params, error) {
|
|||
}
|
||||
|
||||
params["question"] = config.Question
|
||||
err = params.AddInterface("options", config.Options)
|
||||
if err = params.AddInterface("options", config.Options); err != nil {
|
||||
return params, err
|
||||
}
|
||||
params["is_anonymous"] = strconv.FormatBool(config.IsAnonymous)
|
||||
params.AddNonEmpty("type", config.Type)
|
||||
params["allows_multiple_answers"] = strconv.FormatBool(config.AllowsMultipleAnswers)
|
||||
|
@ -536,6 +639,7 @@ func (config SendPollConfig) params() (Params, error) {
|
|||
params.AddNonEmpty("explanation_parse_mode", config.ExplanationParseMode)
|
||||
params.AddNonZero("open_period", config.OpenPeriod)
|
||||
params.AddNonZero("close_date", config.CloseDate)
|
||||
err = params.AddInterface("explanation_entities", config.ExplanationEntities)
|
||||
|
||||
return params, err
|
||||
}
|
||||
|
@ -646,15 +750,20 @@ type EditMessageTextConfig struct {
|
|||
BaseEdit
|
||||
Text string
|
||||
ParseMode string
|
||||
Entities []MessageEntity
|
||||
DisableWebPagePreview bool
|
||||
}
|
||||
|
||||
func (config EditMessageTextConfig) params() (Params, error) {
|
||||
params, err := config.BaseEdit.params()
|
||||
if err != nil {
|
||||
return params, err
|
||||
}
|
||||
|
||||
params["text"] = config.Text
|
||||
params.AddNonEmpty("parse_mode", config.ParseMode)
|
||||
params.AddBool("disable_web_page_preview", config.DisableWebPagePreview)
|
||||
err = params.AddInterface("entities", config.Entities)
|
||||
|
||||
return params, err
|
||||
}
|
||||
|
@ -668,13 +777,18 @@ type EditMessageCaptionConfig struct {
|
|||
BaseEdit
|
||||
Caption string
|
||||
ParseMode string
|
||||
CaptionEntities []MessageEntity
|
||||
}
|
||||
|
||||
func (config EditMessageCaptionConfig) params() (Params, error) {
|
||||
params, err := config.BaseEdit.params()
|
||||
if err != nil {
|
||||
return params, err
|
||||
}
|
||||
|
||||
params["caption"] = config.Caption
|
||||
params.AddNonEmpty("parse_mode", config.ParseMode)
|
||||
err = params.AddInterface("caption_entities", config.CaptionEntities)
|
||||
|
||||
return params, err
|
||||
}
|
||||
|
@ -793,8 +907,10 @@ func (config UpdateConfig) params() (Params, error) {
|
|||
type WebhookConfig struct {
|
||||
URL *url.URL
|
||||
Certificate interface{}
|
||||
IPAddress string
|
||||
MaxConnections int
|
||||
AllowedUpdates []string
|
||||
DropPendingUpdates bool
|
||||
}
|
||||
|
||||
func (config WebhookConfig) method() string {
|
||||
|
@ -808,8 +924,10 @@ func (config WebhookConfig) params() (Params, error) {
|
|||
params["url"] = config.URL.String()
|
||||
}
|
||||
|
||||
params.AddNonEmpty("ip_address", config.IPAddress)
|
||||
params.AddNonZero("max_connections", config.MaxConnections)
|
||||
params.AddInterface("allowed_updates", config.AllowedUpdates)
|
||||
params.AddBool("drop_pending_updates", config.DropPendingUpdates)
|
||||
|
||||
return params, nil
|
||||
}
|
||||
|
@ -826,16 +944,21 @@ func (config WebhookConfig) useExistingFile() bool {
|
|||
return config.URL != nil
|
||||
}
|
||||
|
||||
// RemoveWebhookConfig is a helper to remove a webhook.
|
||||
type RemoveWebhookConfig struct {
|
||||
// DeleteWebhookConfig is a helper to delete a webhook.
|
||||
type DeleteWebhookConfig struct {
|
||||
DropPendingUpdates bool
|
||||
}
|
||||
|
||||
func (config RemoveWebhookConfig) method() string {
|
||||
return "setWebhook"
|
||||
func (config DeleteWebhookConfig) method() string {
|
||||
return "deleteWebhook"
|
||||
}
|
||||
|
||||
func (config RemoveWebhookConfig) params() (Params, error) {
|
||||
return nil, nil
|
||||
func (config DeleteWebhookConfig) params() (Params, error) {
|
||||
params := make(Params)
|
||||
|
||||
params.AddBool("drop_pending_updates", config.DropPendingUpdates)
|
||||
|
||||
return params, nil
|
||||
}
|
||||
|
||||
// FileBytes contains information about a set of bytes to upload
|
||||
|
@ -923,6 +1046,7 @@ type ChatMemberConfig struct {
|
|||
// UnbanChatMemberConfig allows you to unban a user.
|
||||
type UnbanChatMemberConfig struct {
|
||||
ChatMemberConfig
|
||||
OnlyIfBanned bool
|
||||
}
|
||||
|
||||
func (config UnbanChatMemberConfig) method() string {
|
||||
|
@ -934,6 +1058,7 @@ func (config UnbanChatMemberConfig) params() (Params, error) {
|
|||
|
||||
params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername, config.ChannelUsername)
|
||||
params.AddNonZero("user_id", config.UserID)
|
||||
params.AddBool("only_if_banned", config.OnlyIfBanned)
|
||||
|
||||
return params, nil
|
||||
}
|
||||
|
@ -986,6 +1111,7 @@ func (config RestrictChatMemberConfig) params() (Params, error) {
|
|||
// PromoteChatMemberConfig contains fields to promote members of chat
|
||||
type PromoteChatMemberConfig struct {
|
||||
ChatMemberConfig
|
||||
IsAnonymous bool
|
||||
CanChangeInfo bool
|
||||
CanPostMessages bool
|
||||
CanEditMessages bool
|
||||
|
@ -1006,6 +1132,7 @@ func (config PromoteChatMemberConfig) params() (Params, error) {
|
|||
params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername, config.ChannelUsername)
|
||||
params.AddNonZero("user_id", config.UserID)
|
||||
|
||||
params.AddBool("is_anonymous", config.IsAnonymous)
|
||||
params.AddBool("can_change_info", config.CanChangeInfo)
|
||||
params.AddBool("can_post_messages", config.CanPostMessages)
|
||||
params.AddBool("can_edit_messages", config.CanEditMessages)
|
||||
|
@ -1281,10 +1408,13 @@ func (config PinChatMessageConfig) params() (Params, error) {
|
|||
return params, nil
|
||||
}
|
||||
|
||||
// UnpinChatMessageConfig contains information of chat to unpin.
|
||||
// UnpinChatMessageConfig contains information of a chat message to unpin.
|
||||
//
|
||||
// If MessageID is not specified, it will unpin the most recent pin.
|
||||
type UnpinChatMessageConfig struct {
|
||||
ChatID int64
|
||||
ChannelUsername string
|
||||
MessageID int
|
||||
}
|
||||
|
||||
func (config UnpinChatMessageConfig) method() string {
|
||||
|
@ -1294,6 +1424,26 @@ func (config UnpinChatMessageConfig) method() string {
|
|||
func (config UnpinChatMessageConfig) params() (Params, error) {
|
||||
params := make(Params)
|
||||
|
||||
params.AddFirstValid("chat_id", config.ChatID, config.ChannelUsername)
|
||||
params.AddNonZero("message_id", config.MessageID)
|
||||
|
||||
return params, nil
|
||||
}
|
||||
|
||||
// UnpinAllChatMessagesConfig contains information of all messages to unpin in
|
||||
// a chat.
|
||||
type UnpinAllChatMessagesConfig struct {
|
||||
ChatID int64
|
||||
ChannelUsername string
|
||||
}
|
||||
|
||||
func (config UnpinAllChatMessagesConfig) method() string {
|
||||
return "unpinAllChatMessages"
|
||||
}
|
||||
|
||||
func (config UnpinAllChatMessagesConfig) params() (Params, error) {
|
||||
params := make(Params)
|
||||
|
||||
params.AddFirstValid("chat_id", config.ChatID, config.ChannelUsername)
|
||||
|
||||
return params, nil
|
||||
|
@ -1680,7 +1830,8 @@ func (config MediaGroupConfig) params() (Params, error) {
|
|||
|
||||
// DiceConfig allows you to send a random dice roll to Telegram.
|
||||
//
|
||||
// Emoji may be one of the following: 🎲 (1-6), 🎯 (1-6), 🏀 (1-5).
|
||||
// Emoji may be one of the following: 🎲 (1-6), 🎯 (1-6), 🏀 (1-5), ⚽ (1-5),
|
||||
// 🎰 (1-64).
|
||||
type DiceConfig struct {
|
||||
BaseChat
|
||||
|
||||
|
|
82
types.go
82
types.go
|
@ -121,6 +121,7 @@ type Chat struct {
|
|||
LastName string `json:"last_name,omitempty"` // optional
|
||||
AllMembersAreAdmins bool `json:"all_members_are_administrators,omitempty"` // deprecated, optional
|
||||
Photo *ChatPhoto `json:"photo,omitempty"` // optional
|
||||
Bio string `json:"bio,omitempty"` // optional
|
||||
Description string `json:"description,omitempty"` // optional
|
||||
InviteLink string `json:"invite_link,omitempty"` // optional
|
||||
PinnedMessage *Message `json:"pinned_message,omitempty"` // optional
|
||||
|
@ -128,6 +129,8 @@ type Chat struct {
|
|||
SlowModeDelay int `json:"slow_mode_delay,omitempty"` // optional
|
||||
StickerSetName string `json:"sticker_set_name,omitempty"` // optional
|
||||
CanSetStickerSet bool `json:"can_set_sticker_set,omitempty"` // optional
|
||||
LinkedChatID int `json:"linked_chat_id,omitempty"` // optional
|
||||
Location *ChatLocation `json:"location"` // optional
|
||||
}
|
||||
|
||||
// IsPrivate returns if the Chat is a private conversation.
|
||||
|
@ -160,6 +163,7 @@ func (c Chat) ChatConfig() ChatConfig {
|
|||
type Message struct {
|
||||
MessageID int `json:"message_id"`
|
||||
From *User `json:"from,omitempty"` // optional
|
||||
SenderChat *Chat `json:"sender_chat,omitempty"` // optional
|
||||
Date int `json:"date"`
|
||||
Chat *Chat `json:"chat"`
|
||||
ForwardFrom *User `json:"forward_from,omitempty"` // optional
|
||||
|
@ -175,22 +179,22 @@ type Message struct {
|
|||
AuthorSignature string `json:"author_signature,omitempty"` // optional
|
||||
Text string `json:"text,omitempty"` // optional
|
||||
Entities []MessageEntity `json:"entities,omitempty"` // optional
|
||||
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"` // optional
|
||||
Audio *Audio `json:"audio,omitempty"` // optional
|
||||
Document *Document `json:"document,omitempty"` // optional
|
||||
Animation *ChatAnimation `json:"animation,omitempty"` // optional
|
||||
Game *Game `json:"game,omitempty"` // optional
|
||||
Photo []PhotoSize `json:"photo,omitempty"` // optional
|
||||
Sticker *Sticker `json:"sticker,omitempty"` // optional
|
||||
Video *Video `json:"video,omitempty"` // optional
|
||||
VideoNote *VideoNote `json:"video_note,omitempty"` // optional
|
||||
Voice *Voice `json:"voice,omitempty"` // optional
|
||||
Caption string `json:"caption,omitempty"` // optional
|
||||
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"` // optional
|
||||
Contact *Contact `json:"contact,omitempty"` // optional
|
||||
Location *Location `json:"location,omitempty"` // optional
|
||||
Venue *Venue `json:"venue,omitempty"` // optional
|
||||
Poll *Poll `json:"poll,omitempty"` // optional
|
||||
Dice *Dice `json:"dice,omitempty"` // optional
|
||||
Game *Game `json:"game,omitempty"` // optional
|
||||
Poll *Poll `json:"poll,omitempty"` // optional
|
||||
Venue *Venue `json:"venue,omitempty"` // optional
|
||||
Location *Location `json:"location,omitempty"` // optional
|
||||
NewChatMembers []User `json:"new_chat_members,omitempty"` // optional
|
||||
LeftChatMember *User `json:"left_chat_member,omitempty"` // optional
|
||||
NewChatTitle string `json:"new_chat_title,omitempty"` // optional
|
||||
|
@ -206,6 +210,7 @@ type Message struct {
|
|||
SuccessfulPayment *SuccessfulPayment `json:"successful_payment,omitempty"` // optional
|
||||
ConnectedWebsite string `json:"connected_website,omitempty"` // optional
|
||||
PassportData *PassportData `json:"passport_data,omitempty"` // optional
|
||||
ProximityAlertTriggered *ProximityAlertTriggered `json:"proximity_alert_triggered"` // optional
|
||||
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"` // optional
|
||||
}
|
||||
|
||||
|
@ -363,6 +368,7 @@ type Audio struct {
|
|||
Duration int `json:"duration"`
|
||||
Performer string `json:"performer,omitempty"` // optional
|
||||
Title string `json:"title,omitempty"` // optional
|
||||
FileName string `json:"file_name,omitempty"` // optional
|
||||
MimeType string `json:"mime_type,omitempty"` // optional
|
||||
FileSize int `json:"file_size,omitempty"` // optional
|
||||
}
|
||||
|
@ -427,6 +433,7 @@ type Video struct {
|
|||
Height int `json:"height"`
|
||||
Duration int `json:"duration"`
|
||||
Thumbnail *PhotoSize `json:"thumb,omitempty"` // optional
|
||||
FileName string `json:"file_name,omitempty"` // optional
|
||||
MimeType string `json:"mime_type,omitempty"` // optional
|
||||
FileSize int `json:"file_size,omitempty"` // optional
|
||||
}
|
||||
|
@ -465,6 +472,10 @@ type Contact struct {
|
|||
type Location struct {
|
||||
Longitude float64 `json:"longitude"`
|
||||
Latitude float64 `json:"latitude"`
|
||||
HorizontalAccuracy float64 `json:"horizontal_accuracy"` // optional
|
||||
LivePeriod int `json:"live_period"` // optional
|
||||
Heading int `json:"heading"` // optional
|
||||
ProximityAlertRadius int `json:"proximity_alert_radius"` // optional
|
||||
}
|
||||
|
||||
// Venue contains information about a venue, including its Location.
|
||||
|
@ -473,6 +484,9 @@ type Venue struct {
|
|||
Title string `json:"title"`
|
||||
Address string `json:"address"`
|
||||
FoursquareID string `json:"foursquare_id,omitempty"` // optional
|
||||
FoursquareType string `json:"foursquare_type,omitempty"` // optional
|
||||
GooglePlaceID string `json:"google_place_id,omitempty"` // optional
|
||||
GooglePlaceType string `json:"google_place_type,omitempty"` // optional
|
||||
}
|
||||
|
||||
// PollOption contains information about one answer option in a poll.
|
||||
|
@ -510,6 +524,14 @@ type Dice struct {
|
|||
Value int `json:"value"`
|
||||
}
|
||||
|
||||
// ProximityAlertTriggered represents a service message sent when a user in the
|
||||
// chat triggers a proximity alert sent by another user.
|
||||
type ProximityAlertTriggered struct {
|
||||
Traveler User `json:"traveler"`
|
||||
Watcher User `json:"watcher"`
|
||||
Distance int `json:"distance"`
|
||||
}
|
||||
|
||||
// UserProfilePhotos contains a set of user profile photos.
|
||||
type UserProfilePhotos struct {
|
||||
TotalCount int `json:"total_count"`
|
||||
|
@ -620,6 +642,7 @@ type ChatMember struct {
|
|||
User *User `json:"user"`
|
||||
Status string `json:"status"`
|
||||
CustomTitle string `json:"custom_title,omitempty"` // optional
|
||||
IsAnonymous bool `json:"is_anonymous"` // optional
|
||||
UntilDate int64 `json:"until_date,omitempty"` // optional
|
||||
CanBeEdited bool `json:"can_be_edited,omitempty"` // optional
|
||||
CanPostMessages bool `json:"can_post_messages,omitempty"` // optional
|
||||
|
@ -688,9 +711,11 @@ type WebhookInfo struct {
|
|||
URL string `json:"url"`
|
||||
HasCustomCertificate bool `json:"has_custom_certificate"`
|
||||
PendingUpdateCount int `json:"pending_update_count"`
|
||||
IPAddress string `json:"ip_address"` // optional
|
||||
LastErrorDate int `json:"last_error_date"` // optional
|
||||
LastErrorMessage string `json:"last_error_message"` // optional
|
||||
MaxConnections int `json:"max_connections"` // optional
|
||||
AllowedUpdates []string `json:"allowed_updates"` // optional
|
||||
}
|
||||
|
||||
// IsSet returns true if a webhook is currently set.
|
||||
|
@ -734,6 +759,8 @@ type InlineQueryResultPhoto struct {
|
|||
Title string `json:"title"`
|
||||
Description string `json:"description"`
|
||||
Caption string `json:"caption"`
|
||||
ParseMode string `json:"parse_mode,omitempty"`
|
||||
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
|
||||
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
|
||||
InputMessageContent interface{} `json:"input_message_content,omitempty"`
|
||||
}
|
||||
|
@ -747,6 +774,7 @@ type InlineQueryResultCachedPhoto struct {
|
|||
Description string `json:"description"`
|
||||
Caption string `json:"caption"`
|
||||
ParseMode string `json:"parse_mode"`
|
||||
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
|
||||
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
|
||||
InputMessageContent interface{} `json:"input_message_content,omitempty"`
|
||||
}
|
||||
|
@ -763,6 +791,8 @@ type InlineQueryResultGIF struct {
|
|||
Duration int `json:"gif_duration,omitempty"`
|
||||
Title string `json:"title,omitempty"`
|
||||
Caption string `json:"caption,omitempty"`
|
||||
ParseMode string `json:"parse_mode,omitempty"`
|
||||
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
|
||||
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
|
||||
InputMessageContent interface{} `json:"input_message_content,omitempty"`
|
||||
}
|
||||
|
@ -776,6 +806,7 @@ type InlineQueryResultCachedGIF struct {
|
|||
Caption string `json:"caption"`
|
||||
ParseMode string `json:"parse_mode"`
|
||||
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
|
||||
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
|
||||
InputMessageContent interface{} `json:"input_message_content,omitempty"`
|
||||
}
|
||||
|
||||
|
@ -791,6 +822,8 @@ type InlineQueryResultMPEG4GIF struct {
|
|||
ThumbMimeType string `json:"thumb_mime_type"`
|
||||
Title string `json:"title"`
|
||||
Caption string `json:"caption"`
|
||||
ParseMode string `json:"parse_mode,omitempty"`
|
||||
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
|
||||
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
|
||||
InputMessageContent interface{} `json:"input_message_content,omitempty"`
|
||||
}
|
||||
|
@ -804,6 +837,7 @@ type InlineQueryResultCachedMpeg4Gif struct {
|
|||
Title string `json:"title"`
|
||||
Caption string `json:"caption"`
|
||||
ParseMode string `json:"parse_mode"`
|
||||
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
|
||||
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
|
||||
InputMessageContent interface{} `json:"input_message_content,omitempty"`
|
||||
}
|
||||
|
@ -817,6 +851,8 @@ type InlineQueryResultVideo struct {
|
|||
ThumbURL string `json:"thumb_url"`
|
||||
Title string `json:"title"`
|
||||
Caption string `json:"caption"`
|
||||
ParseMode string `json:"parse_mode,omitempty"`
|
||||
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
|
||||
Width int `json:"video_width"`
|
||||
Height int `json:"video_height"`
|
||||
Duration int `json:"video_duration"`
|
||||
|
@ -834,6 +870,7 @@ type InlineQueryResultCachedVideo struct {
|
|||
Description string `json:"description"`
|
||||
Caption string `json:"caption"`
|
||||
ParseMode string `json:"parse_mode"`
|
||||
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
|
||||
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
|
||||
InputMessageContent interface{} `json:"input_message_content,omitempty"`
|
||||
}
|
||||
|
@ -844,7 +881,6 @@ type InlineQueryResultCachedSticker struct {
|
|||
ID string `json:"id"` // required
|
||||
StickerID string `json:"sticker_file_id"` // required
|
||||
Title string `json:"title"` // required
|
||||
ParseMode string `json:"parse_mode"`
|
||||
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
|
||||
InputMessageContent interface{} `json:"input_message_content,omitempty"`
|
||||
}
|
||||
|
@ -856,6 +892,8 @@ type InlineQueryResultAudio struct {
|
|||
URL string `json:"audio_url"` // required
|
||||
Title string `json:"title"` // required
|
||||
Caption string `json:"caption"`
|
||||
ParseMode string `json:"parse_mode,omitempty"`
|
||||
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
|
||||
Performer string `json:"performer"`
|
||||
Duration int `json:"audio_duration"`
|
||||
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
|
||||
|
@ -869,6 +907,7 @@ type InlineQueryResultCachedAudio struct {
|
|||
AudioID string `json:"audio_file_id"` // required
|
||||
Caption string `json:"caption"`
|
||||
ParseMode string `json:"parse_mode"`
|
||||
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
|
||||
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
|
||||
InputMessageContent interface{} `json:"input_message_content,omitempty"`
|
||||
}
|
||||
|
@ -880,6 +919,8 @@ type InlineQueryResultVoice struct {
|
|||
URL string `json:"voice_url"` // required
|
||||
Title string `json:"title"` // required
|
||||
Caption string `json:"caption"`
|
||||
ParseMode string `json:"parse_mode,omitempty"`
|
||||
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
|
||||
Duration int `json:"voice_duration"`
|
||||
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
|
||||
InputMessageContent interface{} `json:"input_message_content,omitempty"`
|
||||
|
@ -893,6 +934,7 @@ type InlineQueryResultCachedVoice struct {
|
|||
Title string `json:"title"` // required
|
||||
Caption string `json:"caption"`
|
||||
ParseMode string `json:"parse_mode"`
|
||||
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
|
||||
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
|
||||
InputMessageContent interface{} `json:"input_message_content,omitempty"`
|
||||
}
|
||||
|
@ -903,6 +945,8 @@ type InlineQueryResultDocument struct {
|
|||
ID string `json:"id"` // required
|
||||
Title string `json:"title"` // required
|
||||
Caption string `json:"caption"`
|
||||
ParseMode string `json:"parse_mode,omitempty"`
|
||||
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
|
||||
URL string `json:"document_url"` // required
|
||||
MimeType string `json:"mime_type"` // required
|
||||
Description string `json:"description"`
|
||||
|
@ -922,6 +966,7 @@ type InlineQueryResultCachedDocument struct {
|
|||
Caption string `json:"caption"`
|
||||
Description string `json:"description"`
|
||||
ParseMode string `json:"parse_mode"`
|
||||
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
|
||||
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
|
||||
InputMessageContent interface{} `json:"input_message_content,omitempty"`
|
||||
}
|
||||
|
@ -934,6 +979,9 @@ type InlineQueryResultLocation struct {
|
|||
Longitude float64 `json:"longitude"` // required
|
||||
LivePeriod int `json:"live_period"` // optional
|
||||
Title string `json:"title"` // required
|
||||
HorizontalAccuracy float64 `json:"horizontal_accuracy,omitempty"`
|
||||
Heading int `json:"heading"`
|
||||
ProximityAlertRadius int `json:"proximity_alert_radius"`
|
||||
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
|
||||
InputMessageContent interface{} `json:"input_message_content,omitempty"`
|
||||
ThumbURL string `json:"thumb_url"`
|
||||
|
@ -964,8 +1012,10 @@ type InlineQueryResultVenue struct {
|
|||
Longitude float64 `json:"longitude"` // required
|
||||
Title string `json:"title"` // required
|
||||
Address string `json:"address"` // required
|
||||
FoursquareID string `json:"foursquare_id"`
|
||||
FoursquareType string `json:"foursquare_type"`
|
||||
FoursquareID string `json:"foursquare_id,omitempty"`
|
||||
FoursquareType string `json:"foursquare_type,omitempty"`
|
||||
GooglePlaceID string `json:"google_place_id,omitempty"`
|
||||
GooglePlaceType string `json:"google_place_type,omitempty"`
|
||||
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
|
||||
InputMessageContent interface{} `json:"input_message_content,omitempty"`
|
||||
ThumbURL string `json:"thumb_url"`
|
||||
|
@ -995,6 +1045,7 @@ type ChosenInlineResult struct {
|
|||
type InputTextMessageContent struct {
|
||||
Text string `json:"message_text"`
|
||||
ParseMode string `json:"parse_mode"`
|
||||
Entities []MessageEntity `json:"entities,omitempty"`
|
||||
DisableWebPagePreview bool `json:"disable_web_page_preview"`
|
||||
}
|
||||
|
||||
|
@ -1003,6 +1054,10 @@ type InputTextMessageContent struct {
|
|||
type InputLocationMessageContent struct {
|
||||
Latitude float64 `json:"latitude"`
|
||||
Longitude float64 `json:"longitude"`
|
||||
HorizontalAccuracy float64 `json:"horizontal_accuracy"`
|
||||
LivePeriod int `json:"live_period"`
|
||||
Heading int `json:"heading"`
|
||||
ProximityAlertRadius int `json:"proximity_alert_radius"`
|
||||
}
|
||||
|
||||
// InputVenueMessageContent contains a venue for displaying
|
||||
|
@ -1013,6 +1068,9 @@ type InputVenueMessageContent struct {
|
|||
Title string `json:"title"`
|
||||
Address string `json:"address"`
|
||||
FoursquareID string `json:"foursquare_id"`
|
||||
FoursquareType string `json:"foursquare_type"`
|
||||
GooglePlaceID string `json:"google_place_id"`
|
||||
GooglePlaceType string `json:"google_place_type"`
|
||||
}
|
||||
|
||||
// InputContactMessageContent contains a contact for displaying
|
||||
|
@ -1104,6 +1162,12 @@ type StickerSet struct {
|
|||
Thumb *PhotoSize `json:"thumb"`
|
||||
}
|
||||
|
||||
// ChatLocation represents a location to which a chat is connected.
|
||||
type ChatLocation struct {
|
||||
Location Location `json:"location"`
|
||||
Address string `json:"address"`
|
||||
}
|
||||
|
||||
// BotCommand represents Telegram's understanding of a command.
|
||||
type BotCommand struct {
|
||||
Command string `json:"command"`
|
||||
|
@ -1116,6 +1180,7 @@ type BaseInputMedia struct {
|
|||
Media string `json:"media"`
|
||||
Caption string `json:"caption"`
|
||||
ParseMode string `json:"parse_mode"`
|
||||
CaptionEntities []MessageEntity `json:"caption_entities"`
|
||||
}
|
||||
|
||||
// InputMediaPhoto is a photo to send as part of a media group.
|
||||
|
@ -1151,6 +1216,7 @@ type InputMediaAudio struct {
|
|||
// InputMediaDocument is a audio to send as part of a media group.
|
||||
type InputMediaDocument struct {
|
||||
BaseInputMedia
|
||||
DisableContentTypeDetection bool `json:"disable_content_type_detection,omitempty"`
|
||||
}
|
||||
|
||||
// Error is an error containing extra information returned by the Telegram API.
|
||||
|
|
|
@ -311,7 +311,7 @@ var (
|
|||
_ Chattable = PhotoConfig{}
|
||||
_ Chattable = PinChatMessageConfig{}
|
||||
_ Chattable = PromoteChatMemberConfig{}
|
||||
_ Chattable = RemoveWebhookConfig{}
|
||||
_ Chattable = DeleteWebhookConfig{}
|
||||
_ Chattable = RestrictChatMemberConfig{}
|
||||
_ Chattable = SendPollConfig{}
|
||||
_ Chattable = SetChatDescriptionConfig{}
|
||||
|
|
Loading…
Reference in New Issue