Merge pull request #392 from go-telegram-bot-api/bot-api-5.0

Updates for Bot API 5.0 and 5.1
bot-api-6.1
Syfaro 2021-03-10 12:10:15 -05:00 committed by GitHub
commit d10c681b05
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 810 additions and 218 deletions

22
bot.go
View File

@ -387,7 +387,7 @@ func (bot *BotAPI) GetFile(config FileConfig) (File, error) {
// GetUpdates fetches updates.
// If a WebHook is set, this will not return any data!
//
// Offset, Limit, and Timeout are optional.
// Offset, Limit, Timeout, and AllowedUpdates are optional.
// To avoid stale items, set Offset to one higher than the previous item.
// Set Timeout to a large number to reduce requests so you can get updates
// instantly instead of having to wait between requests.
@ -668,3 +668,23 @@ func (bot *BotAPI) GetMyCommands() ([]BotCommand, error) {
return commands, err
}
// CopyMessage copy messages of any kind. The method is analogous to the method
// forwardMessage, but the copied message doesn't have a link to the original
// message. Returns the MessageID of the sent message on success.
func (bot *BotAPI) CopyMessage(config CopyMessageConfig) (MessageID, error) {
params, err := config.params()
if err != nil {
return MessageID{}, err
}
resp, err := bot.MakeRequest(config.method(), params)
if err != nil {
return MessageID{}, err
}
var messageID MessageID
err = json.Unmarshal(resp.Result, &messageID)
return messageID, err
}

View File

@ -73,7 +73,7 @@ func TestSendWithMessage(t *testing.T) {
bot, _ := getBot(t)
msg := NewMessage(ChatID, "A test message from the test library in telegram-bot-api")
msg.ParseMode = "markdown"
msg.ParseMode = ModeMarkdown
_, err := bot.Send(msg)
if err != nil {
@ -104,6 +104,26 @@ func TestSendWithMessageForward(t *testing.T) {
}
}
func TestCopyMessage(t *testing.T) {
bot, _ := getBot(t)
msg := NewMessage(ChatID, "A test message from the test library in telegram-bot-api")
message, err := bot.Send(msg)
if err != nil {
t.Error(err)
}
copyMessageConfig := NewCopyMessage(SupergroupChatID, message.Chat.ID, message.MessageID)
messageID, err := bot.CopyMessage(copyMessageConfig)
if err != nil {
t.Error(err)
}
if messageID.MessageID == message.MessageID {
t.Error("copied message ID was the same as original message")
}
}
func TestSendWithNewPhoto(t *testing.T) {
bot, _ := getBot(t)
@ -518,7 +538,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)
@ -532,7 +552,7 @@ func TestSetWebhookWithCert(t *testing.T) {
t.Error(err)
}
bot.Request(RemoveWebhookConfig{})
bot.Request(DeleteWebhookConfig{})
}
func TestSetWebhookWithoutCert(t *testing.T) {
@ -540,7 +560,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)
@ -560,7 +580,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) {
@ -724,7 +744,7 @@ func TestDeleteMessage(t *testing.T) {
bot, _ := getBot(t)
msg := NewMessage(ChatID, "A test message from the test library in telegram-bot-api")
msg.ParseMode = "markdown"
msg.ParseMode = ModeMarkdown
message, _ := bot.Send(msg)
deleteMessageConfig := DeleteMessageConfig{
@ -742,7 +762,7 @@ func TestPinChatMessage(t *testing.T) {
bot, _ := getBot(t)
msg := NewMessage(SupergroupChatID, "A test message from the test library in telegram-bot-api")
msg.ParseMode = "markdown"
msg.ParseMode = ModeMarkdown
message, _ := bot.Send(msg)
pinChatMessageConfig := PinChatMessageConfig{
@ -761,7 +781,7 @@ func TestUnpinChatMessage(t *testing.T) {
bot, _ := getBot(t)
msg := NewMessage(SupergroupChatID, "A test message from the test library in telegram-bot-api")
msg.ParseMode = "markdown"
msg.ParseMode = ModeMarkdown
message, _ := bot.Send(msg)
// We need pin message to unpin something
@ -777,6 +797,7 @@ func TestUnpinChatMessage(t *testing.T) {
unpinChatMessageConfig := UnpinChatMessageConfig{
ChatID: message.Chat.ID,
MessageID: message.MessageID,
}
if _, err := bot.Request(unpinChatMessageConfig); err != nil {
@ -784,6 +805,32 @@ func TestUnpinChatMessage(t *testing.T) {
}
}
func TestUnpinAllChatMessages(t *testing.T) {
bot, _ := getBot(t)
msg := NewMessage(SupergroupChatID, "A test message from the test library in telegram-bot-api")
msg.ParseMode = ModeMarkdown
message, _ := bot.Send(msg)
pinChatMessageConfig := PinChatMessageConfig{
ChatID: message.Chat.ID,
MessageID: message.MessageID,
DisableNotification: true,
}
if _, err := bot.Request(pinChatMessageConfig); err != nil {
t.Error(err)
}
unpinAllChatMessagesConfig := UnpinAllChatMessagesConfig{
ChatID: message.Chat.ID,
}
if _, err := bot.Request(unpinAllChatMessagesConfig); err != nil {
t.Error(err)
}
}
func TestPolls(t *testing.T) {
bot, _ := getBot(t)

View File

@ -42,6 +42,54 @@ const (
ModeHTML = "HTML"
)
// Constant values for update types
const (
// New incoming message of any kind — text, photo, sticker, etc.
UpdateTypeMessage = "message"
// New version of a message that is known to the bot and was edited
UpdateTypeEditedMessage = "edited_message"
// New incoming channel post of any kind — text, photo, sticker, etc.
UpdateTypeChannelPost = "channel_post"
// New version of a channel post that is known to the bot and was edited
UpdateTypeEditedChannelPost = "edited_channel_post"
// New incoming inline query
UpdateTypeInlineQuery = "inline_query"
// The result of an inline query that was chosen by a user and sent to their
// chat partner. Please see the documentation on the feedback collecting for
// details on how to enable these updates for your bot.
UpdateTypeChosenInlineResult = "chosen_inline_result"
// New incoming callback query
UpdateTypeCallbackQuery = "callback_query"
// New incoming shipping query. Only for invoices with flexible price
UpdateTypeShippingQuery = "shipping_query"
// New incoming pre-checkout query. Contains full information about checkout
UpdateTypePreCheckoutQuery = "pre_checkout_query"
// New poll state. Bots receive only updates about stopped polls and polls
// which are sent by the bot
UpdateTypePoll = "poll"
// A user changed their answer in a non-anonymous poll. Bots receive new votes
// only in polls that were sent by the bot itself.
UpdateTypePollAnswer = "poll_answer"
// The bot's chat member status was updated in a chat. For private chats, this
// update is received only when the bot is blocked or unblocked by the user.
UpdateTypeMyChatMember = "my_chat_member"
// The bot must be an administrator in the chat and must explicitly specify
// this update in the list of allowed_updates to receive these updates.
UpdateTypeChatMember = "chat_member"
)
// Library errors
const (
// ErrBadFileType happens when you pass an unknown type
@ -63,6 +111,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 +145,7 @@ type BaseChat struct {
ReplyToMessageID int
ReplyMarkup interface{}
DisableNotification bool
AllowSendingWithoutReply bool
}
func (chat *BaseChat) params() (Params, error) {
@ -78,6 +154,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 +217,7 @@ type MessageConfig struct {
BaseChat
Text string
ParseMode string
Entities []MessageEntity
DisableWebPagePreview bool
}
@ -152,8 +230,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 +263,54 @@ 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
}
func (config CopyMessageConfig) method() string {
return "copyMessage"
}
// 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 +328,7 @@ type AudioConfig struct {
BaseFile
Caption string
ParseMode string
CaptionEntities []MessageEntity
Duration int
Performer string
Title string
@ -231,8 +346,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 +364,8 @@ type DocumentConfig struct {
BaseFile
Caption string
ParseMode string
CaptionEntities []MessageEntity
DisableContentTypeDetection bool
}
func (config DocumentConfig) params() (Params, error) {
@ -256,6 +374,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 +414,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 +448,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 +504,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 +536,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 +547,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 +564,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 +574,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 +606,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 +619,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 +666,7 @@ type SendPollConfig struct {
CorrectOptionID int64
Explanation string
ExplanationParseMode string
ExplanationEntities []MessageEntity
OpenPeriod int
CloseDate int
IsClosed bool
@ -526,7 +679,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 +691,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 +802,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 +829,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
}
@ -773,6 +939,7 @@ type UpdateConfig struct {
Offset int
Limit int
Timeout int
AllowedUpdates []string
}
func (UpdateConfig) method() string {
@ -785,6 +952,7 @@ func (config UpdateConfig) params() (Params, error) {
params.AddNonZero("offset", config.Offset)
params.AddNonZero("limit", config.Limit)
params.AddNonZero("timeout", config.Timeout)
params.AddInterface("allowed_updates", config.AllowedUpdates)
return params, nil
}
@ -793,8 +961,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 +978,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 +998,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 {
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
@ -920,6 +1097,7 @@ type ChatMemberConfig struct {
// UnbanChatMemberConfig allows you to unban a user.
type UnbanChatMemberConfig struct {
ChatMemberConfig
OnlyIfBanned bool
}
func (config UnbanChatMemberConfig) method() string {
@ -931,6 +1109,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
}
@ -939,6 +1118,7 @@ func (config UnbanChatMemberConfig) params() (Params, error) {
type KickChatMemberConfig struct {
ChatMemberConfig
UntilDate int64
RevokeMessages bool
}
func (config KickChatMemberConfig) method() string {
@ -951,6 +1131,7 @@ func (config KickChatMemberConfig) params() (Params, error) {
params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername)
params.AddNonZero("user_id", config.UserID)
params.AddNonZero64("until_date", config.UntilDate)
params.AddBool("revoke_messages", config.RevokeMessages)
return params, nil
}
@ -981,10 +1162,13 @@ func (config RestrictChatMemberConfig) params() (Params, error) {
// PromoteChatMemberConfig contains fields to promote members of chat
type PromoteChatMemberConfig struct {
ChatMemberConfig
IsAnonymous bool
CanManageChat bool
CanChangeInfo bool
CanPostMessages bool
CanEditMessages bool
CanDeleteMessages bool
CanManageVoiceChats bool
CanInviteUsers bool
CanRestrictMembers bool
CanPinMessages bool
@ -1001,10 +1185,13 @@ 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_manage_chat", config.CanManageChat)
params.AddBool("can_change_info", config.CanChangeInfo)
params.AddBool("can_post_messages", config.CanPostMessages)
params.AddBool("can_edit_messages", config.CanEditMessages)
params.AddBool("can_delete_messages", config.CanDeleteMessages)
params.AddBool("can_manage_voice_chats", config.CanManageVoiceChats)
params.AddBool("can_invite_users", config.CanInviteUsers)
params.AddBool("can_restrict_members", config.CanRestrictMembers)
params.AddBool("can_pin_messages", config.CanPinMessages)
@ -1115,6 +1302,77 @@ func (config ChatInviteLinkConfig) params() (Params, error) {
return params, nil
}
// CreateChatInviteLinkConfig allows you to create an additional invite link for
// a chat. The bot must be an administrator in the chat for this to work and
// must have the appropriate admin rights. The link can be revoked using the
// RevokeChatInviteLinkConfig.
type CreateChatInviteLinkConfig struct {
ChatConfig
ExpireDate int
MemberLimit int
}
func (CreateChatInviteLinkConfig) method() string {
return "createChatInviteLink"
}
func (config CreateChatInviteLinkConfig) params() (Params, error) {
params := make(Params)
params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername)
params.AddNonZero("expire_date", config.ExpireDate)
params.AddNonZero("member_limit", config.MemberLimit)
return params, nil
}
// EditChatInviteLinkConfig allows you to edit a non-primary invite link created
// by the bot. The bot must be an administrator in the chat for this to work and
// must have the appropriate admin rights.
type EditChatInviteLinkConfig struct {
ChatConfig
InviteLink string
ExpireDate int
MemberLimit int
}
func (EditChatInviteLinkConfig) method() string {
return "editChatInviteLink"
}
func (config EditChatInviteLinkConfig) params() (Params, error) {
params := make(Params)
params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername)
params["invite_link"] = config.InviteLink
params.AddNonZero("expire_date", config.ExpireDate)
params.AddNonZero("member_limit", config.MemberLimit)
return params, nil
}
// RevokeChatInviteLinkConfig allows you to revoke an invite link created by the
// bot. If the primary link is revoked, a new link is automatically generated.
// The bot must be an administrator in the chat for this to work and must have
// the appropriate admin rights.
type RevokeChatInviteLinkConfig struct {
ChatConfig
InviteLink string
}
func (RevokeChatInviteLinkConfig) method() string {
return "revokeChatInviteLink"
}
func (config RevokeChatInviteLinkConfig) params() (Params, error) {
params := make(Params)
params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername)
params["invite_link"] = config.InviteLink
return params, nil
}
// LeaveChatConfig allows you to leave a chat.
type LeaveChatConfig struct {
ChatID int64
@ -1302,10 +1560,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 {
@ -1315,6 +1576,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
@ -1731,8 +2012,9 @@ func (config SetMyCommandsConfig) params() (Params, error) {
type DiceConfig struct {
BaseChat
// Emoji on which the dice throw animation is based.
// Currently, must be one of “🎲”, “🎯”, or “🏀”.
// Dice can have values 1-6 for “🎲” and “🎯”, and values 1-5 for “🏀”.
// Currently, must be one of 🎲, 🎯, 🏀, ⚽, 🎳, or 🎰.
// Dice can have values 1-6 for 🎲, 🎯, and 🎳, values 1-5 for 🏀 and ⚽,
// and values 1-64 for 🎰.
// Defaults to “🎲”
Emoji string
}

View File

@ -52,6 +52,18 @@ func NewForward(chatID int64, fromChatID int64, messageID int) ForwardConfig {
}
}
// NewCopyMessage creates a new copy message.
//
// chatID is where to send it, fromChatID is the source chat,
// and messageID is the ID of the original message.
func NewCopyMessage(chatID int64, fromChatID int64, messageID int) CopyMessageConfig {
return CopyMessageConfig{
BaseChat: BaseChat{ChatID: chatID},
FromChatID: fromChatID,
MessageID: messageID,
}
}
// NewPhotoUpload creates a new photo uploader.
//
// chatID is where to send it, file is a string path to the file,
@ -528,7 +540,7 @@ func NewInlineQueryResultCachedGIF(id, gifID string) InlineQueryResultCachedGIF
return InlineQueryResultCachedGIF{
Type: "gif",
ID: id,
GifID: gifID,
GIFID: gifID,
}
}
@ -542,11 +554,11 @@ func NewInlineQueryResultMPEG4GIF(id, url string) InlineQueryResultMPEG4GIF {
}
// NewInlineQueryResultCachedMPEG4GIF create a new inline query with cached MPEG4 GIF.
func NewInlineQueryResultCachedMPEG4GIF(id, MPEG4GifID string) InlineQueryResultCachedMPEG4GIF {
func NewInlineQueryResultCachedMPEG4GIF(id, MPEG4GIFID string) InlineQueryResultCachedMPEG4GIF {
return InlineQueryResultCachedMPEG4GIF{
Type: "mpeg4_gif",
ID: id,
MPEG4FileID: MPEG4GifID,
MPEG4FileID: MPEG4GIFID,
}
}

511
types.go
View File

@ -96,6 +96,18 @@ type Update struct {
//
// optional
PollAnswer *PollAnswer `json:"poll_answer,omitempty"`
// MyChatMember is the bot's chat member status was updated in a chat. For
// private chats, this update is received only when the bot is blocked or
// unblocked by the user.
//
// optional
MyChatMember *ChatMemberUpdated `json:"my_chat_member"`
// ChatMember is a chat member's status was updated in a chat. The bot must
// be an administrator in the chat and must explicitly specify "chat_member"
// in the list of allowed_updates to receive these updates.
//
// optional
ChatMember *ChatMemberUpdated `json:"chat_member"`
}
// UpdatesChannel is the channel for getting updates.
@ -198,6 +210,11 @@ type Chat struct {
LastName string `json:"last_name,omitempty"`
// Photo is a chat photo
Photo *ChatPhoto `json:"photo"`
// Bio is the bio of the other party in a private chat. Returned only in
// getChat
//
// optional
Bio string `json:"bio,omitempty"`
// Description for groups, supergroups and channel chats
//
// optional
@ -233,6 +250,17 @@ type Chat struct {
//
// optional
CanSetStickerSet bool `json:"can_set_sticker_set,omitempty"`
// LinkedChatID is a unique identifier for the linked chat, i.e. the
// discussion group identifier for a channel and vice versa; for supergroups
// and channel chats.
//
// optional
LinkedChatID int64 `json:"linked_chat_id,omitempty"`
// Location is for supergroups, the location to which the supergroup is
// connected. Returned only in getChat.
//
// optional
Location *ChatLocation `json:"location"`
}
// IsPrivate returns if the Chat is a private conversation.
@ -268,6 +296,13 @@ type Message struct {
//
// optional
From *User `json:"from,omitempty"`
// SenderChat is the sender of the message, sent on behalf of a chat. The
// channel itself for channel messages. The supergroup itself for messages
// from anonymous group administrators. The linked channel for messages
// automatically forwarded to the discussion group
//
// optional
SenderChat *Chat `json:"sender_chat,omitempty"`
// Date of the message was sent in Unix time
Date int `json:"date"`
// Chat is the conversation the message belongs to
@ -440,6 +475,11 @@ type Message struct {
//
// optional
ChannelChatCreated bool `json:"channel_chat_created,omitempty"`
// MessageAutoDeleteTimerChanged is a service message: auto-delete timer
// settings changed in the chat.
//
// optional
MessageAutoDeleteTimerChanged *MessageAutoDeleteTimerChanged `json:"message_auto_delete_timer_changed"`
// MigrateToChatID is the group has been migrated to a supergroup with the specified identifier.
// This number may be greater than 32 bits and some programming languages
// may have difficulty/silent defects in interpreting it.
@ -480,6 +520,24 @@ type Message struct {
//
// optional
PassportData *PassportData `json:"passport_data,omitempty"`
// ProximityAlertTriggered is a service message. A user in the chat
// triggered another user's proximity alert while sharing Live Location
//
// optional
ProximityAlertTriggered *ProximityAlertTriggered `json:"proximity_alert_triggered"`
// VoiceChatStarted is a service message: voice chat started.
//
// optional
VoiceChatStarted *VoiceChatStarted `json:"voice_chat_started"`
// VoiceChatEnded is a service message: voice chat ended.
//
// optional
VoiceChatEnded *VoiceChatEnded `json:"voice_chat_ended"`
// VoiceChatParticipantsInvited is a service message: new participants
// invited to a voice chat.
//
// optional
VoiceChatParticipantsInvited *VoiceChatParticipantsInvited `json:"voice_chat_participants_invited"`
// ReplyMarkup is the Inline keyboard attached to the message.
// login_url buttons are represented as ordinary url buttons.
//
@ -556,6 +614,11 @@ func (m *Message) CommandArguments() string {
return m.Text[entity.Length+1:]
}
// MessageID represents a unique message identifier.
type MessageID struct {
MessageID int `json:"message_id"`
}
// MessageEntity represents one special entity in a text message.
type MessageEntity struct {
// Type of the entity.
@ -724,6 +787,10 @@ type Audio struct {
//
// optional
Title string `json:"title,omitempty"`
// FileName is the original filename as defined by sender
//
// optional
FileName string `json:"file_name,omitempty"`
// MimeType of the file as defined by sender
//
// optional
@ -784,6 +851,10 @@ type Video struct {
//
// optional
Thumbnail *PhotoSize `json:"thumb,omitempty"`
// FileName is the original filename as defined by sender
//
// optional
FileName string `json:"file_name,omitempty"`
// MimeType of a file as defined by sender
//
// optional
@ -937,6 +1008,26 @@ type Location struct {
Longitude float64 `json:"longitude"`
// Latitude as defined by sender
Latitude float64 `json:"latitude"`
// HorizontalAccuracy is the radius of uncertainty for the location,
// measured in meters; 0-1500
//
// optional
HorizontalAccuracy float64 `json:"horizontal_accuracy,omitempty"`
// LivePeriod is time relative to the message sending date, during which the
// location can be updated, in seconds. For active live locations only.
//
// optional
LivePeriod int `json:"live_period,omitempty"`
// Heading is the direction in which user is moving, in degrees; 1-360. For
// active live locations only.
//
// optional
Heading int `json:"heading,omitempty"`
// ProximityAlertRadius is the maximum distance for proximity alerts about
// approaching another chat member, in meters. For sent live locations only.
//
// optional
ProximityAlertRadius int `json:"proximity_alert_radius,omitempty"`
}
// Venue represents a venue.
@ -955,6 +1046,52 @@ type Venue struct {
//
// optional
FoursquareType string `json:"foursquare_type,omitempty"`
// GooglePlaceID is the Google Places identifier of the venue
//
// optional
GooglePlaceID string `json:"google_place_id,omitempty"`
// GooglePlaceType is the Google Places type of the venue
//
// optional
GooglePlaceType string `json:"google_place_type,omitempty"`
}
// ProximityAlertTriggered represents a service message sent when a user in the
// chat triggers a proximity alert sent by another user.
type ProximityAlertTriggered struct {
// Traveler is the user that triggered the alert
Traveler User `json:"traveler"`
// Watcher is the user that set the alert
Watcher User `json:"watcher"`
// Distance is the distance between the users
Distance int `json:"distance"`
}
// MessageAutoDeleteTimerChanged represents a service message about a change in
// auto-delete timer settings.
type MessageAutoDeleteTimerChanged struct {
// New auto-delete time for messages in the chat.
MessageAutoDeleteTime int `json:"message_auto_delete_time"`
}
// VoiceChatStarted represents a service message about a voice chat started in
// the chat.
type VoiceChatStarted struct{}
// VoiceChatEnded represents a service message about a voice chat ended in the
// chat.
type VoiceChatEnded struct {
// Voice chat duration; in seconds.
Duration int `json:"duration"`
}
// VoiceChatParticipantsInvited represents a service message about new members
// invited to a voice chat.
type VoiceChatParticipantsInvited struct {
// New members that were invited to the voice chat.
//
// optional
Users []User `json:"users"`
}
// UserProfilePhotos contains a set of user profile photos.
@ -1256,6 +1393,29 @@ type ChatPhoto struct {
BigFileUniqueID string `json:"big_file_unique_id"`
}
// ChatInviteLink represents an invite link for a chat.
type ChatInviteLink struct {
// InviteLink is the invite link. If the link was created by another chat
// administrator, then the second part of the link will be replaced with “…”.
InviteLink string `json:"invite_link"`
// Creator of the link.
Creator User `json:"creator"`
// IsPrimary is true, if the link is primary.
IsPrimary bool `json:"is_primary"`
// IsRevoked is true, if the link is revoked.
IsRevoked bool `json:"is_revoked"`
// ExpireDate is the point in time (Unix timestamp) when the link will
// expire or has been expired.
//
// optional
ExpireDate int `json:"expire_date"`
// MemberLimit is the maximum number of users that can be members of the
// chat simultaneously after joining the chat via this invite link; 1-99999.
//
// optional
MemberLimit int `json:"member_limit"`
}
// ChatMember contains information about one member of a chat.
type ChatMember struct {
// User information about the user
@ -1273,6 +1433,11 @@ type ChatMember struct {
//
// optional
CustomTitle string `json:"custom_title,omitempty"`
// IsAnonymous owner and administrators only. True, if the user's presence
// in the chat is hidden
//
// optional
IsAnonymous bool `json:"is_anonymous"`
// UntilDate restricted and kicked only.
// Date when restrictions will be lifted for this user;
// unix time.
@ -1284,6 +1449,14 @@ type ChatMember struct {
//
// optional
CanBeEdited bool `json:"can_be_edited,omitempty"`
// CanManageChat administrators only.
// True, if the administrator can access the chat event log, chat
// statistics, message statistics in channels, see channel members, see
// anonymous administrators in supergoups and ignore slow mode. Implied by
// any other administrator privilege.
//
// optional
CanManageChat bool `json:"can_manage_chat"`
// CanPostMessages administrators only.
// True, if the administrator can post in the channel;
// channels only.
@ -1301,6 +1474,11 @@ type ChatMember struct {
//
// optional
CanDeleteMessages bool `json:"can_delete_messages,omitempty"`
// CanManageVoiceChats administrators only.
// True, if the administrator can manage voice chats.
//
// optional
CanManageVoiceChats bool `json:"can_manage_voice_chats"`
// CanRestrictMembers administrators only.
// True, if the administrator can restrict, ban or unban chat members.
//
@ -1370,6 +1548,25 @@ func (chat ChatMember) HasLeft() bool { return chat.Status == "left" }
// WasKicked returns if the ChatMember was kicked from the chat.
func (chat ChatMember) WasKicked() bool { return chat.Status == "kicked" }
// ChatMemberUpdated represents changes in the status of a chat member.
type ChatMemberUpdated struct {
// Chat the user belongs to.
Chat Chat `json:"chat"`
// From is the performer of the action, which resulted in the change.
From User `json:"from"`
// Date the change was done in Unix time.
Date int `json:"date"`
// Previous information about the chat member.
OldChatMember ChatMember `json:"old_chat_member"`
// New information about the chat member.
NewChatMember ChatMember `json:"new_chat_member"`
// InviteLink is the link which was used by the user to join the chat;
// for joining by invite link events only.
//
// optional
InviteLink *ChatInviteLink `json:"invite_link"`
}
// ChatPermissions describes actions that a non-administrator user is
// allowed to take in a chat. All fields are optional.
type ChatPermissions struct {
@ -1416,6 +1613,16 @@ type ChatPermissions struct {
CanPinMessages bool `json:"can_pin_messages,omitempty"`
}
// ChatLocation represents a location to which a chat is connected.
type ChatLocation struct {
// Location is the location to which the supergroup is connected. Can't be a
// live location.
Location Location `json:"location"`
// Address is the location address; 1-64 characters, as defined by the chat
// owner
Address string `json:"address"`
}
// BotCommand represents a bot command.
type BotCommand struct {
// Command text of the command, 1-32 characters.
@ -1460,6 +1667,11 @@ type BaseInputMedia struct {
//
// optional
ParseMode string `json:"parse_mode,omitempty"`
// CaptionEntities is a list of special entities that appear in the caption,
// which can be specified instead of parse_mode
//
// optional
CaptionEntities []MessageEntity `json:"caption_entities"`
}
// InputMediaPhoto is a photo to send as part of a media group.
@ -1525,6 +1737,12 @@ type InputMediaAudio struct {
// InputMediaDocument is a general file to send as part of a media group.
type InputMediaDocument struct {
BaseInputMedia
// DisableContentTypeDetection disables automatic server-side content type
// detection for files uploaded using multipart/form-data. Always true, if
// the document is sent as part of an album
//
// optional
DisableContentTypeDetection bool `json:"disable_content_type_detection,omitempty"`
}
// Sticker represents a sticker.
@ -1648,6 +1866,10 @@ type WebhookInfo struct {
HasCustomCertificate bool `json:"has_custom_certificate"`
// PendingUpdateCount number of updates awaiting delivery.
PendingUpdateCount int `json:"pending_update_count"`
// IPAddress is the currently used webhook IP address
//
// optional
IPAddress string `json:"ip_address,omitempty"`
// LastErrorDate unix time for the most recent error
// that happened when trying to deliver an update via webhook.
//
@ -1694,16 +1916,10 @@ type InlineQuery struct {
// InlineQueryResultCachedAudio is an inline query response with cached audio.
type InlineQueryResultCachedAudio struct {
// Type of the result, must be audio
//
// required
Type string `json:"type"`
// ID unique identifier for this result, 1-64 bytes
//
// required
ID string `json:"id"`
// AudioID a valid file identifier for the audio file
//
// required
AudioID string `json:"audio_file_id"`
// Caption 0-1024 characters after entities parsing
//
@ -1715,6 +1931,11 @@ type InlineQueryResultCachedAudio struct {
//
// optional
ParseMode string `json:"parse_mode,omitempty"`
// CaptionEntities is a list of special entities that appear in the caption,
// which can be specified instead of parse_mode
//
// optional
CaptionEntities []MessageEntity `json:"caption_entities"`
// ReplyMarkup inline keyboard attached to the message
//
// optional
@ -1728,21 +1949,15 @@ type InlineQueryResultCachedAudio struct {
// InlineQueryResultCachedDocument is an inline query response with cached document.
type InlineQueryResultCachedDocument struct {
// Type of the result, must be document
//
// required
Type string `json:"type"`
// ID unique identifier for this result, 1-64 bytes
//
// required
ID string `json:"id"`
// DocumentID a valid file identifier for the file
//
// required
DocumentID string `json:"document_file_id"`
// Title for the result
//
// optional
Title string `json:"title,omitempty"` // required
Title string `json:"title,omitempty"`
// Caption of the document to be sent, 0-1024 characters after entities parsing
//
// optional
@ -1757,6 +1972,11 @@ type InlineQueryResultCachedDocument struct {
//
// optional
ParseMode string `json:"parse_mode,omitempty"`
// CaptionEntities is a list of special entities that appear in the caption,
// which can be specified instead of parse_mode
//
// optional
CaptionEntities []MessageEntity `json:"caption_entities"`
// ReplyMarkup inline keyboard attached to the message
//
// optional
@ -1770,17 +1990,11 @@ type InlineQueryResultCachedDocument struct {
// InlineQueryResultCachedGIF is an inline query response with cached gif.
type InlineQueryResultCachedGIF struct {
// Type of the result, must be gif.
//
// required
Type string `json:"type"`
// ID unique identifier for this result, 1-64 bytes.
//
// required
ID string `json:"id"`
// GifID a valid file identifier for the GIF file.
//
// required
GifID string `json:"gif_file_id"`
GIFID string `json:"gif_file_id"`
// Title for the result
//
// optional
@ -1795,6 +2009,11 @@ type InlineQueryResultCachedGIF struct {
//
// optional
ParseMode string `json:"parse_mode,omitempty"`
// CaptionEntities is a list of special entities that appear in the caption,
// which can be specified instead of parse_mode
//
// optional
CaptionEntities []MessageEntity `json:"caption_entities"`
// ReplyMarkup inline keyboard attached to the message.
//
// optional
@ -1809,16 +2028,10 @@ type InlineQueryResultCachedGIF struct {
// H.264/MPEG-4 AVC video without sound gif.
type InlineQueryResultCachedMPEG4GIF struct {
// Type of the result, must be mpeg4_gif
//
// required
Type string `json:"type"`
// ID unique identifier for this result, 1-64 bytes
//
// required
ID string `json:"id"`
// MGifID a valid file identifier for the MP4 file
//
// required
// MPEG4FileID a valid file identifier for the MP4 file
MPEG4FileID string `json:"mpeg4_file_id"`
// Title for the result
//
@ -1834,6 +2047,12 @@ type InlineQueryResultCachedMPEG4GIF struct {
//
// optional
ParseMode string `json:"parse_mode,omitempty"`
// ParseMode mode for parsing entities in the video caption.
// See formatting options for more details
// (https://core.telegram.org/bots/api#formatting-options).
//
// optional
CaptionEntities []MessageEntity `json:"caption_entities"`
// ReplyMarkup inline keyboard attached to the message.
//
// optional
@ -1847,16 +2066,10 @@ type InlineQueryResultCachedMPEG4GIF struct {
// InlineQueryResultCachedPhoto is an inline query response with cached photo.
type InlineQueryResultCachedPhoto struct {
// Type of the result, must be photo.
//
// required
Type string `json:"type"`
// ID unique identifier for this result, 1-64 bytes.
//
// required
ID string `json:"id"`
// PhotoID a valid file identifier of the photo.
//
// required
PhotoID string `json:"photo_file_id"`
// Title for the result.
//
@ -1876,6 +2089,11 @@ type InlineQueryResultCachedPhoto struct {
//
// optional
ParseMode string `json:"parse_mode,omitempty"`
// CaptionEntities is a list of special entities that appear in the caption,
// which can be specified instead of parse_mode
//
// optional
CaptionEntities []MessageEntity `json:"caption_entities"`
// ReplyMarkup inline keyboard attached to the message.
//
// optional
@ -1889,25 +2107,13 @@ type InlineQueryResultCachedPhoto struct {
// InlineQueryResultCachedSticker is an inline query response with cached sticker.
type InlineQueryResultCachedSticker struct {
// Type of the result, must be sticker
//
// required
Type string `json:"type"`
// ID unique identifier for this result, 1-64 bytes
//
// required
ID string `json:"id"`
// StickerID a valid file identifier of the sticker
//
// required
StickerID string `json:"sticker_file_id"`
// Title is a title
Title string `json:"title"`
// ParseMode mode for parsing entities in the video caption.
// See formatting options for more details
// (https://core.telegram.org/bots/api#formatting-options).
//
// optional
ParseMode string `json:"parse_mode,omitempty"`
// ReplyMarkup inline keyboard attached to the message
//
// optional
@ -1921,20 +2127,12 @@ type InlineQueryResultCachedSticker struct {
// InlineQueryResultCachedVideo is an inline query response with cached video.
type InlineQueryResultCachedVideo struct {
// Type of the result, must be video
//
// required
Type string `json:"type"`
// ID unique identifier for this result, 1-64 bytes
//
// required
ID string `json:"id"`
// VideoID a valid file identifier for the video file
//
// required
VideoID string `json:"video_file_id"`
// Title for the result
//
// required
Title string `json:"title"`
// Description short description of the result
//
@ -1950,6 +2148,11 @@ type InlineQueryResultCachedVideo struct {
//
// optional
ParseMode string `json:"parse_mode,omitempty"`
// CaptionEntities is a list of special entities that appear in the caption,
// which can be specified instead of parse_mode
//
// optional
CaptionEntities []MessageEntity `json:"caption_entities"`
// ReplyMarkup inline keyboard attached to the message
//
// optional
@ -1963,20 +2166,12 @@ type InlineQueryResultCachedVideo struct {
// InlineQueryResultCachedVoice is an inline query response with cached voice.
type InlineQueryResultCachedVoice struct {
// Type of the result, must be voice
//
// required
Type string `json:"type"`
// ID unique identifier for this result, 1-64 bytes
//
// required
ID string `json:"id"`
// VoiceID a valid file identifier for the voice message
//
// required
VoiceID string `json:"voice_file_id"`
// Title voice message title
//
// required
Title string `json:"title"`
// Caption 0-1024 characters after entities parsing
//
@ -1988,6 +2183,11 @@ type InlineQueryResultCachedVoice struct {
//
// optional
ParseMode string `json:"parse_mode,omitempty"`
// CaptionEntities is a list of special entities that appear in the caption,
// which can be specified instead of parse_mode
//
// optional
CaptionEntities []MessageEntity `json:"caption_entities"`
// ReplyMarkup inline keyboard attached to the message
//
// optional
@ -2041,25 +2241,28 @@ type InlineQueryResultArticle struct {
// InlineQueryResultAudio is an inline query response audio.
type InlineQueryResultAudio struct {
// Type of the result, must be audio
//
// required
Type string `json:"type"`
// ID unique identifier for this result, 1-64 bytes
//
// required
ID string `json:"id"`
// URL a valid url for the audio file
//
// required
URL string `json:"audio_url"`
// Title is a title
//
// required
Title string `json:"title"`
// Caption 0-1024 characters after entities parsing
//
// optional
Caption string `json:"caption,omitempty"`
// ParseMode mode for parsing entities in the video caption.
// See formatting options for more details
// (https://core.telegram.org/bots/api#formatting-options).
//
// optional
ParseMode string `json:"parse_mode,omitempty"`
// CaptionEntities is a list of special entities that appear in the caption,
// which can be specified instead of parse_mode
//
// optional
CaptionEntities []MessageEntity `json:"caption_entities"`
// Performer is a performer
//
// optional
@ -2096,16 +2299,10 @@ type InlineQueryResultContact struct {
// InlineQueryResultGame is an inline query response game.
type InlineQueryResultGame struct {
// Type of the result, must be game
//
// required
Type string `json:"type"`
// ID unique identifier for this result, 1-64 bytes
//
// required
ID string `json:"id"`
// GameShortName short name of the game
//
// required
GameShortName string `json:"game_short_name"`
// ReplyMarkup inline keyboard attached to the message
//
@ -2116,28 +2313,18 @@ type InlineQueryResultGame struct {
// InlineQueryResultDocument is an inline query response document.
type InlineQueryResultDocument struct {
// Type of the result, must be document
//
// required
Type string `json:"type"`
// ID unique identifier for this result, 1-64 bytes
//
// required
ID string `json:"id"`
// Title for the result
//
// required
Title string `json:"title"`
// Caption of the document to be sent, 0-1024 characters after entities parsing
//
// optional
Caption string `json:"caption,omitempty"`
// URL a valid url for the file
//
// required
URL string `json:"document_url"`
// MimeType of the content of the file, either “application/pdf” or “application/zip”
//
// required
MimeType string `json:"mime_type"`
// Description short description of the result
//
@ -2168,20 +2355,12 @@ type InlineQueryResultDocument struct {
// InlineQueryResultGIF is an inline query response GIF.
type InlineQueryResultGIF struct {
// Type of the result, must be gif.
//
// required
Type string `json:"type"`
// ID unique identifier for this result, 1-64 bytes.
//
// required
ID string `json:"id"`
// URL a valid URL for the GIF file. File size must not exceed 1MB.
//
// required
URL string `json:"gif_url"`
// ThumbURL url of the static (JPEG or GIF) or animated (MPEG4) thumbnail for the result.
//
// required
ThumbURL string `json:"thumb_url"`
// Width of the GIF
//
@ -2203,6 +2382,17 @@ type InlineQueryResultGIF struct {
//
// optional
Caption string `json:"caption,omitempty"`
// ParseMode mode for parsing entities in the video caption.
// See formatting options for more details
// (https://core.telegram.org/bots/api#formatting-options).
//
// optional
ParseMode string `json:"parse_mode,omitempty"`
// CaptionEntities is a list of special entities that appear in the caption,
// which can be specified instead of parse_mode
//
// optional
CaptionEntities []MessageEntity `json:"caption_entities"`
// ReplyMarkup inline keyboard attached to the message
//
// optional
@ -2216,25 +2406,36 @@ type InlineQueryResultGIF struct {
// InlineQueryResultLocation is an inline query response location.
type InlineQueryResultLocation struct {
// Type of the result, must be location
//
// required
Type string `json:"type"`
// ID unique identifier for this result, 1-64 Bytes
//
// required
ID string `json:"id"`
// Latitude of the location in degrees
//
// required
Latitude float64 `json:"latitude"`
// Longitude of the location in degrees
//
// required
Longitude float64 `json:"longitude"`
// Title of the location
//
// required
Title string `json:"title"`
// HorizontalAccuracy is the radius of uncertainty for the location,
// measured in meters; 0-1500
//
// optional
HorizontalAccuracy float64 `json:"horizontal_accuracy"`
// LivePeriod is the period in seconds for which the location can be
// updated, should be between 60 and 86400.
//
// optional
LivePeriod int `json:"live_period"`
// Heading is for live locations, a direction in which the user is moving,
// in degrees. Must be between 1 and 360 if specified.
//
// optional
Heading int `json:"heading"`
// ProximityAlertRadius is for live locations, a maximum distance for
// proximity alerts about approaching another chat member, in meters. Must
// be between 1 and 100000 if specified.
//
// optional
ProximityAlertRadius int `json:"proximity_alert_radius"`
// ReplyMarkup inline keyboard attached to the message
//
// optional
@ -2260,16 +2461,10 @@ type InlineQueryResultLocation struct {
// InlineQueryResultMPEG4GIF is an inline query response MPEG4 GIF.
type InlineQueryResultMPEG4GIF struct {
// Type of the result, must be mpeg4_gif
//
// required
Type string `json:"type"`
// ID unique identifier for this result, 1-64 bytes
//
// required
ID string `json:"id"`
// URL a valid URL for the MP4 file. File size must not exceed 1MB
//
// required
URL string `json:"mpeg4_url"`
// Width video width
//
@ -2293,6 +2488,17 @@ type InlineQueryResultMPEG4GIF struct {
//
// optional
Caption string `json:"caption,omitempty"`
// ParseMode mode for parsing entities in the video caption.
// See formatting options for more details
// (https://core.telegram.org/bots/api#formatting-options).
//
// optional
ParseMode string `json:"parse_mode,omitempty"`
// CaptionEntities is a list of special entities that appear in the caption,
// which can be specified instead of parse_mode
//
// optional
CaptionEntities []MessageEntity `json:"caption_entities"`
// ReplyMarkup inline keyboard attached to the message
//
// optional
@ -2306,12 +2512,8 @@ type InlineQueryResultMPEG4GIF struct {
// InlineQueryResultPhoto is an inline query response photo.
type InlineQueryResultPhoto struct {
// Type of the result, must be article.
//
// required
Type string `json:"type"`
// ID unique identifier for this result, 1-64 Bytes.
//
// required
ID string `json:"id"`
// URL a valid URL of the photo. Photo must be in jpeg format.
// Photo size must not exceed 5MB.
@ -2352,6 +2554,11 @@ type InlineQueryResultPhoto struct {
//
// optional
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
// CaptionEntities is a list of special entities that appear in the caption,
// which can be specified instead of parse_mode
//
// optional
CaptionEntities []MessageEntity `json:"caption_entities"`
// InputMessageContent content of the message to be sent instead of the photo.
//
// optional
@ -2361,28 +2568,16 @@ type InlineQueryResultPhoto struct {
// InlineQueryResultVenue is an inline query response venue.
type InlineQueryResultVenue struct {
// Type of the result, must be venue
//
// required
Type string `json:"type"`
// ID unique identifier for this result, 1-64 Bytes
//
// required
ID string `json:"id"`
// Latitude of the venue location in degrees
//
// required
Latitude float64 `json:"latitude"`
// Longitude of the venue location in degrees
//
// required
Longitude float64 `json:"longitude"`
// Title of the venue
//
// required
Title string `json:"title"`
// Address of the venue
//
// required
Address string `json:"address"`
// FoursquareID foursquare identifier of the venue if known
//
@ -2393,6 +2588,14 @@ type InlineQueryResultVenue struct {
//
// optional
FoursquareType string `json:"foursquare_type,omitempty"`
// GooglePlaceID is the Google Places identifier of the venue
//
// optional
GooglePlaceID string `json:"google_place_id,omitempty"`
// GooglePlaceType is the Google Places type of the venue
//
// optional
GooglePlaceType string `json:"google_place_type,omitempty"`
// ReplyMarkup inline keyboard attached to the message
//
// optional
@ -2418,28 +2621,18 @@ type InlineQueryResultVenue struct {
// InlineQueryResultVideo is an inline query response video.
type InlineQueryResultVideo struct {
// Type of the result, must be video
//
// required
Type string `json:"type"`
// ID unique identifier for this result, 1-64 bytes
//
// required
ID string `json:"id"`
// URL a valid url for the embedded video player or video file
//
// required
URL string `json:"video_url"`
// MimeType of the content of video url, “text/html” or “video/mp4”
//
// required
MimeType string `json:"mime_type"`
//
// ThumbURL url of the thumbnail (jpeg only) for the video
// optional
ThumbURL string `json:"thumb_url,omitempty"`
// Title for the result
//
// required
Title string `json:"title"`
// Caption of the video to be sent, 0-1024 characters after entities parsing
//
@ -2476,25 +2669,28 @@ type InlineQueryResultVideo struct {
// InlineQueryResultVoice is an inline query response voice.
type InlineQueryResultVoice struct {
// Type of the result, must be voice
//
// required
Type string `json:"type"`
// ID unique identifier for this result, 1-64 bytes
//
// required
ID string `json:"id"`
// URL a valid URL for the voice recording
//
// required
URL string `json:"voice_url"`
// Title recording title
//
// required
Title string `json:"title"`
// Caption 0-1024 characters after entities parsing
//
// optional
Caption string `json:"caption,omitempty"`
// ParseMode mode for parsing entities in the video caption.
// See formatting options for more details
// (https://core.telegram.org/bots/api#formatting-options).
//
// optional
ParseMode string `json:"parse_mode,omitempty"`
// CaptionEntities is a list of special entities that appear in the caption,
// which can be specified instead of parse_mode
//
// optional
CaptionEntities []MessageEntity `json:"caption_entities"`
// Duration recording duration in seconds
//
// optional
@ -2540,6 +2736,11 @@ type InputTextMessageContent struct {
//
// optional
ParseMode string `json:"parse_mode,omitempty"`
// Entities is a list of special entities that appear in message text, which
// can be specified instead of parse_mode
//
// optional
Entities []MessageEntity `json:"entities,omitempty"`
// DisableWebPagePreview disables link previews for links in the sent message
//
// optional
@ -2553,11 +2754,27 @@ type InputLocationMessageContent struct {
Latitude float64 `json:"latitude"`
// Longitude of the location in degrees
Longitude float64 `json:"longitude"`
// HorizontalAccuracy is the radius of uncertainty for the location,
// measured in meters; 0-1500
//
// optional
HorizontalAccuracy float64 `json:"horizontal_accuracy"`
// LivePeriod is the period in seconds for which the location can be
// updated, should be between 60 and 86400
//
// optional
LivePeriod int `json:"live_period,omitempty"`
// Heading is for live locations, a direction in which the user is moving,
// in degrees. Must be between 1 and 360 if specified.
//
// optional
Heading int `json:"heading"`
// ProximityAlertRadius is for live locations, a maximum distance for
// proximity alerts about approaching another chat member, in meters. Must
// be between 1 and 100000 if specified.
//
// optional
ProximityAlertRadius int `json:"proximity_alert_radius"`
}
// InputVenueMessageContent contains a venue for displaying
@ -2579,6 +2796,14 @@ type InputVenueMessageContent struct {
//
// optional
FoursquareType string `json:"foursquare_type,omitempty"`
// GooglePlaceID is the Google Places identifier of the venue
//
// optional
GooglePlaceID string `json:"google_place_id"`
// GooglePlaceType is the Google Places type of the venue
//
// optional
GooglePlaceType string `json:"google_place_type"`
}
// InputContactMessageContent contains a contact for displaying

View File

@ -282,15 +282,20 @@ var (
_ Chattable = AnimationConfig{}
_ Chattable = AudioConfig{}
_ Chattable = CallbackConfig{}
_ Chattable = ChatAdministratorsConfig{}
_ Chattable = ChatActionConfig{}
_ Chattable = ChatAdministratorsConfig{}
_ Chattable = ChatInfoConfig{}
_ Chattable = ChatInviteLinkConfig{}
_ Chattable = CloseConfig{}
_ Chattable = ContactConfig{}
_ Chattable = CopyMessageConfig{}
_ Chattable = CreateChatInviteLinkConfig{}
_ Chattable = DeleteChatPhotoConfig{}
_ Chattable = DeleteChatStickerSetConfig{}
_ Chattable = DeleteMessageConfig{}
_ Chattable = DeleteWebhookConfig{}
_ Chattable = DocumentConfig{}
_ Chattable = EditChatInviteLinkConfig{}
_ Chattable = EditMessageCaptionConfig{}
_ Chattable = EditMessageLiveLocationConfig{}
_ Chattable = EditMessageMediaConfig{}
@ -306,14 +311,15 @@ var (
_ Chattable = KickChatMemberConfig{}
_ Chattable = LeaveChatConfig{}
_ Chattable = LocationConfig{}
_ Chattable = LogOutConfig{}
_ Chattable = MediaGroupConfig{}
_ Chattable = MessageConfig{}
_ Chattable = PhotoConfig{}
_ Chattable = PinChatMessageConfig{}
_ Chattable = PreCheckoutConfig{}
_ Chattable = PromoteChatMemberConfig{}
_ Chattable = RemoveWebhookConfig{}
_ Chattable = RestrictChatMemberConfig{}
_ Chattable = RevokeChatInviteLinkConfig{}
_ Chattable = SendPollConfig{}
_ Chattable = SetChatDescriptionConfig{}
_ Chattable = SetChatPhotoConfig{}
@ -321,8 +327,8 @@ var (
_ Chattable = SetGameScoreConfig{}
_ Chattable = ShippingConfig{}
_ Chattable = StickerConfig{}
_ Chattable = StopPollConfig{}
_ Chattable = StopMessageLiveLocationConfig{}
_ Chattable = StopPollConfig{}
_ Chattable = UnbanChatMemberConfig{}
_ Chattable = UnpinChatMessageConfig{}
_ Chattable = UpdateConfig{}