Compare commits

...

10 Commits

Author SHA1 Message Date
Astra 7389f276de Merge remote-tracking branch 'upstream/master' 2024-06-16 19:57:46 +01:00
OvyFlash 90edbbc66a
Merge pull request #25 from OvyFlash/bot-api-7.4
Bot API 7.4 implementation
2024-06-09 14:12:23 +03:00
stdkhai bece330506 Bot API 7.4 implementation 2024-05-31 19:21:42 +03:00
OvyFlash 9b9c5c57d2
Merge pull request #24 from bobra/patch-1
Fix missing ParseMode in InlineQueryResultVideo
2024-05-15 23:34:45 +03:00
bobra d0fa8e929e
Fix missing ParseMode in InlineQueryResultVideo
ParseMode for this type actually exists, but was missed in the original repo.
https://core.telegram.org/bots/api#inlinequeryresultvideo
2024-05-15 02:57:25 +02:00
OvyFlash f8ef3a5696
Merge pull request #23 from OvyFlash/bot-api-7.3
Bot API 7.3 implementation
2024-05-11 13:26:18 +03:00
stdkhai 3dfc49d5c1 add missed omitempty tag & update comments 2024-05-10 17:19:52 +03:00
stdkhai 1ad852c765 Bot API 7.3 implementation 2024-05-07 17:32:47 +03:00
OvyFlash 29fd5ed941
Merge pull request #22 from OvyFlash/bot-api-7.2
BOT API 7.2 implementation
2024-05-04 17:38:12 +03:00
OvyFlash 6a83e6e519 BOT API 7.2 implementation 2024-05-02 22:49:19 +03:00
7 changed files with 582 additions and 52 deletions

6
bot.go
View File

@ -553,13 +553,13 @@ func WriteToHTTPResponse(w http.ResponseWriter, c Chattable) error {
}
// GetChat gets information about a chat.
func (bot *BotAPI) GetChat(config ChatInfoConfig) (Chat, error) {
func (bot *BotAPI) GetChat(config ChatInfoConfig) (ChatFullInfo, error) {
resp, err := bot.Request(config)
if err != nil {
return Chat{}, err
return ChatFullInfo{}, err
}
var chat Chat
var chat ChatFullInfo
err = json.Unmarshal(resp.Result, &chat)
return chat, err

View File

@ -933,7 +933,7 @@ func TestUnpinAllChatMessages(t *testing.T) {
func TestPolls(t *testing.T) {
bot, _ := getBot(t)
poll := NewPoll(SupergroupChatID, "Are polls working?", "Yes", "No")
poll := NewPoll(SupergroupChatID, "Are polls working?", NewPollOption("Yes"), NewPollOption("No"))
msg, err := bot.Send(poll)
if err != nil {

View File

@ -60,6 +60,19 @@ const (
// UpdateTypeEditedChannelPost is new version of a channel post that is known to the bot and was edited
UpdateTypeEditedChannelPost = "edited_channel_post"
// UpdateTypeBusinessConnection is the bot was connected to or disconnected from a business account,
// or a user edited an existing connection with the bot
UpdateTypeBusinessConnection = "business_connection"
// UpdateTypeBusinessMessage is a new non-service message from a connected business account
UpdateTypeBusinessMessage = "business_message"
// UpdateTypeEditedBusinessMessage is a new version of a message from a connected business account
UpdateTypeEditedBusinessMessage = "edited_business_message"
// UpdateTypeDeletedBusinessMessages are the messages were deleted from a connected business account
UpdateTypeDeletedBusinessMessages = "deleted_business_messages"
// UpdateTypeMessageReactionis is a reaction to a message was changed by a user
UpdateTypeMessageReaction = "message_reaction"
@ -366,11 +379,12 @@ func (config ForwardMessagesConfig) method() string {
// CopyMessageConfig contains information about a copyMessage request.
type CopyMessageConfig struct {
BaseChat
FromChat ChatConfig
MessageID int
Caption string
ParseMode string
CaptionEntities []MessageEntity
FromChat ChatConfig
MessageID int
Caption string
ParseMode string
CaptionEntities []MessageEntity
ShowCaptionAboveMedia bool
}
func (config CopyMessageConfig) params() (Params, error) {
@ -387,6 +401,7 @@ func (config CopyMessageConfig) params() (Params, error) {
params.AddNonZero("message_id", config.MessageID)
params.AddNonEmpty("caption", config.Caption)
params.AddNonEmpty("parse_mode", config.ParseMode)
params.AddBool("show_caption_above_media", config.ShowCaptionAboveMedia)
err = params.AddInterface("caption_entities", config.CaptionEntities)
return params, err
@ -429,10 +444,11 @@ func (config CopyMessagesConfig) method() string {
type PhotoConfig struct {
BaseFile
BaseSpoiler
Thumb RequestFileData
Caption string
ParseMode string
CaptionEntities []MessageEntity
Thumb RequestFileData
Caption string
ParseMode string
CaptionEntities []MessageEntity
ShowCaptionAboveMedia bool
}
func (config PhotoConfig) params() (Params, error) {
@ -443,6 +459,7 @@ func (config PhotoConfig) params() (Params, error) {
params.AddNonEmpty("caption", config.Caption)
params.AddNonEmpty("parse_mode", config.ParseMode)
params.AddBool("show_caption_above_media", config.ShowCaptionAboveMedia)
err = params.AddInterface("caption_entities", config.CaptionEntities)
if err != nil {
return params, err
@ -596,12 +613,13 @@ func (config StickerConfig) files() []RequestFile {
type VideoConfig struct {
BaseFile
BaseSpoiler
Thumb RequestFileData
Duration int
Caption string
ParseMode string
CaptionEntities []MessageEntity
SupportsStreaming bool
Thumb RequestFileData
Duration int
Caption string
ParseMode string
CaptionEntities []MessageEntity
ShowCaptionAboveMedia bool
SupportsStreaming bool
}
func (config VideoConfig) params() (Params, error) {
@ -614,6 +632,7 @@ func (config VideoConfig) params() (Params, error) {
params.AddNonEmpty("caption", config.Caption)
params.AddNonEmpty("parse_mode", config.ParseMode)
params.AddBool("supports_streaming", config.SupportsStreaming)
params.AddBool("show_caption_above_media", config.ShowCaptionAboveMedia)
err = params.AddInterface("caption_entities", config.CaptionEntities)
if err != nil {
return params, err
@ -652,11 +671,12 @@ func (config VideoConfig) files() []RequestFile {
type AnimationConfig struct {
BaseFile
BaseSpoiler
Duration int
Thumb RequestFileData
Caption string
ParseMode string
CaptionEntities []MessageEntity
Duration int
Thumb RequestFileData
Caption string
ParseMode string
CaptionEntities []MessageEntity
ShowCaptionAboveMedia bool
}
func (config AnimationConfig) params() (Params, error) {
@ -668,6 +688,7 @@ func (config AnimationConfig) params() (Params, error) {
params.AddNonZero("duration", config.Duration)
params.AddNonEmpty("caption", config.Caption)
params.AddNonEmpty("parse_mode", config.ParseMode)
params.AddBool("show_caption_above_media", config.ShowCaptionAboveMedia)
err = params.AddInterface("caption_entities", config.CaptionEntities)
if err != nil {
return params, err
@ -816,6 +837,7 @@ type EditMessageLiveLocationConfig struct {
BaseEdit
Latitude float64 // required
Longitude float64 // required
LivePeriod int //optional
HorizontalAccuracy float64 // optional
Heading int // optional
ProximityAlertRadius int // optional
@ -828,6 +850,7 @@ func (config EditMessageLiveLocationConfig) params() (Params, error) {
params.AddNonZeroFloat("longitude", config.Longitude)
params.AddNonZeroFloat("horizontal_accuracy", config.HorizontalAccuracy)
params.AddNonZero("heading", config.Heading)
params.AddNonZero("live_period", config.LivePeriod)
params.AddNonZero("proximity_alert_radius", config.ProximityAlertRadius)
return params, err
@ -911,7 +934,9 @@ func (config ContactConfig) method() string {
type SendPollConfig struct {
BaseChat
Question string
Options []string
QuestionParseMode string // optional
QuestionEntities []MessageEntity // optional
Options []InputPollOption
IsAnonymous bool
Type string
AllowsMultipleAnswers bool
@ -931,6 +956,10 @@ func (config SendPollConfig) params() (Params, error) {
}
params["question"] = config.Question
params.AddNonEmpty("question_parse_mode", config.QuestionParseMode)
if err = params.AddInterface("question_entities", config.QuestionEntities); err != nil {
return params, err
}
if err = params.AddInterface("options", config.Options); err != nil {
return params, err
}
@ -1088,9 +1117,10 @@ func (config EditMessageTextConfig) method() string {
// EditMessageCaptionConfig allows you to modify the caption of a message.
type EditMessageCaptionConfig struct {
BaseEdit
Caption string
ParseMode string
CaptionEntities []MessageEntity
Caption string
ParseMode string
CaptionEntities []MessageEntity
ShowCaptionAboveMedia bool
}
func (config EditMessageCaptionConfig) params() (Params, error) {
@ -1101,6 +1131,7 @@ func (config EditMessageCaptionConfig) params() (Params, error) {
params["caption"] = config.Caption
params.AddNonEmpty("parse_mode", config.ParseMode)
params.AddBool("show_caption_above_media", config.ShowCaptionAboveMedia)
err = params.AddInterface("caption_entities", config.CaptionEntities)
return params, err
@ -1873,12 +1904,12 @@ func (config InvoiceConfig) params() (Params, error) {
params["title"] = config.Title
params["description"] = config.Description
params["payload"] = config.Payload
params["provider_token"] = config.ProviderToken
params["currency"] = config.Currency
if err = params.AddInterface("prices", config.Prices); err != nil {
return params, err
}
params.AddNonEmpty("provider_token", config.ProviderToken)
params.AddNonZero("max_tip_amount", config.MaxTipAmount)
err = params.AddInterface("suggested_tip_amounts", config.SuggestedTipAmounts)
params.AddNonEmpty("start_parameter", config.StartParameter)
@ -1932,12 +1963,12 @@ func (config InvoiceLinkConfig) params() (Params, error) {
params["title"] = config.Title
params["description"] = config.Description
params["payload"] = config.Payload
params["provider_token"] = config.ProviderToken
params["currency"] = config.Currency
if err := params.AddInterface("prices", config.Prices); err != nil {
return params, err
}
params.AddNonEmpty("provider_token", config.ProviderToken)
params.AddNonZero("max_tip_amount", config.MaxTipAmount)
err := params.AddInterface("suggested_tip_amounts", config.SuggestedTipAmounts)
params.AddNonEmpty("provider_data", config.ProviderData)
@ -2004,6 +2035,26 @@ func (config PreCheckoutConfig) params() (Params, error) {
return params, nil
}
// RefundStarPaymentConfig refunds a successful payment in Telegram Stars.
// Returns True on success.
type RefundStarPaymentConfig struct {
UserID int64 //required
TelegramPaymentChargeID string //required
}
func (config RefundStarPaymentConfig) method() string {
return "refundStarPayment"
}
func (config RefundStarPaymentConfig) params() (Params, error) {
params := make(Params)
params["telegram_payment_charge_id"] = config.TelegramPaymentChargeID
params.AddNonZero64("user_id", config.UserID)
return params, nil
}
// DeleteMessageConfig contains information of a message in a chat to delete.
type DeleteMessageConfig struct {
BaseChatMessage
@ -2216,7 +2267,6 @@ type NewStickerSetConfig struct {
Name string
Title string
Stickers []InputSticker
StickerFormat string
StickerType string
NeedsRepainting bool //optional; Pass True if stickers in the sticker set must be repainted to the color of text when used in messages, the accent color if used as emoji status, white on chat photos, or another appropriate color based on context; for custom emoji sticker sets only
}
@ -2231,7 +2281,6 @@ func (config NewStickerSetConfig) params() (Params, error) {
params.AddNonZero64("user_id", config.UserID)
params["name"] = config.Name
params["title"] = config.Title
params["sticker_format"] = config.StickerFormat
params.AddBool("needs_repainting", config.NeedsRepainting)
params.AddNonEmpty("sticker_type", string(config.StickerType))
@ -2363,6 +2412,33 @@ func (config DeleteStickerConfig) params() (Params, error) {
return params, nil
}
// ReplaceStickerInSetConfig allows you to replace an existing sticker in a sticker set
// with a new one. The method is equivalent to calling deleteStickerFromSet,
// then addStickerToSet, then setStickerPositionInSet.
// Returns True on success.
type ReplaceStickerInSetConfig struct {
UserID int64
Name string
OldSticker string
Sticker InputSticker
}
func (config ReplaceStickerInSetConfig) method() string {
return "replaceStickerInSet"
}
func (config ReplaceStickerInSetConfig) params() (Params, error) {
params := make(Params)
params.AddNonZero64("user_id", config.UserID)
params["name"] = config.Name
params["old_sticker"] = config.OldSticker
err := params.AddInterface("sticker", config.Sticker)
return params, err
}
// SetStickerEmojiListConfig allows you to change the list of emoji assigned to a regular or custom emoji sticker. The sticker must belong to a sticker set created by the bot
type SetStickerEmojiListConfig struct {
Sticker string
@ -2425,6 +2501,7 @@ type SetStickerSetThumbConfig struct {
Name string
UserID int64
Thumb RequestFileData
Format string
}
func (config SetStickerSetThumbConfig) method() string {
@ -2435,6 +2512,8 @@ func (config SetStickerSetThumbConfig) params() (Params, error) {
params := make(Params)
params["name"] = config.Name
params["format"] = config.Format
params.AddNonZero64("user_id", config.UserID)
return params, nil
@ -2739,6 +2818,29 @@ func (config GetUserChatBoostsConfig) params() (Params, error) {
return params, err
}
type (
GetBusinessConnectionConfig struct {
BusinessConnectionID BusinessConnectionID
}
BusinessConnectionID string
)
func (GetBusinessConnectionConfig) method() string {
return "getBusinessConnection"
}
func (config GetBusinessConnectionConfig) params() (Params, error) {
return config.BusinessConnectionID.params()
}
func (config BusinessConnectionID) params() (Params, error) {
params := make(Params)
params["business_connection_id"] = string(config)
return params, nil
}
// GetMyCommandsConfig gets a list of the currently registered commands.
type GetMyCommandsConfig struct {
Scope *BotCommandScope

View File

@ -933,7 +933,7 @@ func NewDeleteChatPhoto(chatID int64) DeleteChatPhotoConfig {
}
// NewPoll allows you to create a new poll.
func NewPoll(chatID int64, question string, options ...string) SendPollConfig {
func NewPoll(chatID int64, question string, options ...InputPollOption) SendPollConfig {
return SendPollConfig{
BaseChat: BaseChat{
ChatConfig: ChatConfig{ChatID: chatID},
@ -944,6 +944,13 @@ func NewPoll(chatID int64, question string, options ...string) SendPollConfig {
}
}
// NewPollOption allows you to create poll option
func NewPollOption(text string) InputPollOption {
return InputPollOption{
Text: text,
}
}
// NewStopPoll allows you to stop a poll.
func NewStopPoll(chatID int64, messageID int) StopPollConfig {
return StopPollConfig{
@ -1075,6 +1082,13 @@ func NewSetMyName(languageCode, name string) SetMyNameConfig {
}
}
// NewGetBusinessConnection gets business connection request struct
func NewGetBusinessConnection(id string) GetBusinessConnectionConfig {
return GetBusinessConnectionConfig{
BusinessConnectionID: BusinessConnectionID(id),
}
}
// NewGetMyCommandsWithScope allows you to set the registered commands for a
// given scope.
func NewGetMyCommandsWithScope(scope BotCommandScope) GetMyCommandsConfig {

View File

@ -19,11 +19,13 @@ func (base ChatConfig) paramsWithKey(key string) (Params, error) {
// BaseChat is base type for all chat config types.
type BaseChat struct {
ChatConfig
MessageThreadID int
ProtectContent bool
ReplyMarkup interface{}
DisableNotification bool
ReplyParameters ReplyParameters
BusinessConnectionID BusinessConnectionID
MessageThreadID int
ProtectContent bool
ReplyMarkup interface{}
DisableNotification bool
MessageEffectID string // for private chats only
ReplyParameters ReplyParameters
}
func (chat *BaseChat) params() (Params, error) {
@ -31,10 +33,16 @@ func (chat *BaseChat) params() (Params, error) {
if err != nil {
return params, err
}
p1, err := chat.BusinessConnectionID.params()
if err != nil {
return params, err
}
params.Merge(p1)
params.AddNonZero("message_thread_id", chat.MessageThreadID)
params.AddBool("disable_notification", chat.DisableNotification)
params.AddBool("protect_content", chat.ProtectContent)
params.AddNonEmpty("message_effect_id", chat.MessageEffectID)
err = params.AddInterface("reply_markup", chat.ReplyMarkup)
if err != nil {

431
types.go
View File

@ -61,6 +61,26 @@ type Update struct {
//
// optional
EditedChannelPost *Message `json:"edited_channel_post,omitempty"`
// BusinessConnection the bot was connected to or disconnected from a
// business account, or a user edited an existing connection with the bot
//
// optional
BusinessConnection *BusinessConnection `json:"business_connection,omitempty"`
// BusinessMessage is a new non-service message from a
// connected business account
//
// optional
BusinessMessage *Message `json:"business_message,omitempty"`
// EditedBusinessMessage is a new version of a message from a
// connected business account
//
// optional
EditedBusinessMessage *Message `json:"edited_business_message,omitempty"`
// DeletedBusinessMessages are the messages were deleted from a
// connected business account
//
// optional
DeletedBusinessMessages *BusinessMessagesDeleted `json:"deleted_business_messages,omitempty"`
// MessageReaction is a reaction to a message was changed by a user.
//
// optional
@ -237,6 +257,12 @@ type User struct {
//
// optional
SupportsInlineQueries bool `json:"supports_inline_queries,omitempty"`
// CanConnectToBusiness is true, if the bot can be connected to a
// Telegram Business account to receive its messages.
// Returned only in getMe.
//
// optional
CanConnectToBusiness bool `json:"can_connect_to_business,omitempty"`
}
// String displays a simple text version of a user.
@ -285,6 +311,11 @@ type Chat struct {
//
// optional
IsForum bool `json:"is_forum,omitempty"`
}
// ChatFullInfo contains full information about a chat.
type ChatFullInfo struct {
Chat
// Photo is a chat photo
Photo *ChatPhoto `json:"photo"`
// If non-empty, the list of all active chat usernames;
@ -292,6 +323,31 @@ type Chat struct {
//
// optional
ActiveUsernames []string `json:"active_usernames,omitempty"`
// Birthdate for private chats, the date of birth of the user.
// Returned only in getChat.
//
// optional
Birthdate *Birthdate `json:"birthdate,omitempty"`
// BusinessIntro is for private chats with business accounts, the intro of the business.
// Returned only in getChat.
//
// optional
BusinessIntro *BusinessIntro `json:"business_intro,omitempty"`
// BusinessLocation is for private chats with business accounts, the location
// of the business. Returned only in getChat.
//
// optional
BusinessLocation *BusinessLocation `json:"business_location,omitempty"`
// BusinessOpeningHours is for private chats with business accounts,
// the opening hours of the business. Returned only in getChat.
//
// optional
BusinessOpeningHours *BusinessOpeningHours `json:"business_opening_hours,omitempty"`
// PersonalChat is for private chats, the personal channel of the user.
// Returned only in getChat.
//
// optional
PersonalChat *Chat `json:"personal_chat,omitempty"`
// AvailableReactions is a list of available reactions allowed in the chat.
// If omitted, then all emoji reactions are allowed. Returned only in getChat.
//
@ -304,6 +360,8 @@ type Chat struct {
//
// optional
AccentColorID int `json:"accent_color_id,omitempty"`
// The maximum number of reactions that can be set on a message in the chat
MaxReactionCount int `json:"max_reaction_count"`
// BackgroundCustomEmojiID is a custom emoji identifier of emoji chosen by
// the chat for the reply header and link preview background.
// Returned only in getChat.
@ -426,8 +484,8 @@ type Chat struct {
//
// optional
CanSetStickerSet bool `json:"can_set_sticker_set,omitempty"`
// CustomEmojiStickerSetName is for supergroups, the name of the group's
// custom emoji sticker set. Custom emoji from this set can be used by all
// CustomEmojiStickerSetName is for supergroups, the name of the group's
// custom emoji sticker set. Custom emoji from this set can be used by all
// users and bots in the group. Returned only in getChat.
//
// optional
@ -505,8 +563,21 @@ type Message struct {
//
// optional
SenderBoostCount int `json:"sender_boost_count,omitempty"`
// SenderBusinessBot is the bot that actually sent the message on behalf of
// the business account. Available only for outgoing messages sent on
// behalf of the connected business account.
//
// optional
SenderBusinessBot *User `json:"sender_business_bot,omitempty"`
// Date of the message was sent in Unix time
Date int `json:"date"`
// BusinessConnectionID is an unique identifier of the business connection
// from which the message was received. If non-empty, the message belongs to
// a chat of the corresponding business account that is independent from
// any potential bot chat which might share the same identifier.
//
// optional
BusinessConnectionID string `json:"business_connection_id,omitempty"`
// Chat is the conversation the message belongs to
Chat Chat `json:"chat"`
// ForwardOrigin is information about the original message for forwarded messages
@ -553,6 +624,11 @@ type Message struct {
//
// optional
HasProtectedContent bool `json:"has_protected_content,omitempty"`
// IsFromOffline is True, if the message was sent by an implicit action,
// for example, as an away or a greeting business message, or as a scheduled message
//
// optional
IsFromOffline bool `json:"is_from_offline,omitempty"`
// MediaGroupID is the unique identifier of a media message group this message belongs to;
//
// optional
@ -575,6 +651,10 @@ type Message struct {
//
// Optional
LinkPreviewOptions *LinkPreviewOptions `json:"link_preview_options,omitempty"`
// EffectID is the unique identifier of the message effect added to the message
//
// optional
EffectID string `json:"effect_id,omitempty"`
// Animation message is an animation, information about the animation.
// For backward compatibility, when this field is set, the document field will also be set;
//
@ -625,6 +705,10 @@ type Message struct {
//
// optional
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
// ShowCaptionAboveMedia is True, if the caption must be shown above the message media
//
// optional
ShowCaptionAboveMedia bool `json:"show_caption_above_media,omitempty"`
// HasSpoiler True, if the message media is covered by a spoiler animation
//
// optional
@ -764,6 +848,10 @@ type Message struct {
//
// optional
BoostAdded *ChatBoostAdded `json:"boost_added,omitempty"`
// Service message: chat background set
//
// optional
ChatBackgroundSet *ChatBackground `json:"chat_background_set,omitempty"`
// ForumTopicCreated is a service message: forum topic created
//
// optional
@ -923,6 +1011,7 @@ type MessageEntity struct {
// “strikethrough” (strikethrough text),
// "spoiler" (spoiler message),
// “blockquote” (block quotation),
// “expandable_blockquote” (collapsed-by-default block quotation),
// “code” (monowidth string),
// “pre” (monowidth block),
// “text_link” (for clickable text URLs),
@ -1459,10 +1548,31 @@ type Dice struct {
type PollOption struct {
// Text is the option text, 1-100 characters
Text string `json:"text"`
// Special entities that appear in the option text.
// Currently, only custom emoji entities are allowed in poll option texts
//
// optional
TextEntities []MessageEntity `json:"text_entities,omitempty"`
// VoterCount is the number of users that voted for this option
VoterCount int `json:"voter_count"`
}
// InputPollOption contains information about one answer option in a poll to send.
type InputPollOption struct {
// Option text, 1-100 characters
Text string `json:"text"`
// Mode for parsing entities in the text. See formatting options for more details.
// Currently, only custom emoji entities are allowed
//
// optional
TextParseMode string `json:"text_parse_mode,omitempty"`
// A JSON-serialized list of special entities that appear in the poll option text.
// It can be specified instead of text_parse_mode
//
// optional
TextEntities []MessageEntity `json:"text_entities,omitempty"`
}
// PollAnswer represents an answer of a user in a non-anonymous poll.
type PollAnswer struct {
// PollID is the unique poll identifier
@ -1488,6 +1598,11 @@ type Poll struct {
ID string `json:"id"`
// Question is the poll question, 1-255 characters
Question string `json:"question"`
// Special entities that appear in the question.
// Currently, only custom emoji entities are allowed in poll questions
//
// optional
QuestionEntities []MessageEntity `json:"question_entities,omitempty"`
// Options is the list of poll options
Options []PollOption `json:"options"`
// TotalVoterCount is the total numbers of users who voted in the poll
@ -1541,6 +1656,7 @@ type Location struct {
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.
// Use 0x7FFFFFFF (2147483647 - max positive Int) to edit indefinitely
//
// optional
LivePeriod int `json:"live_period,omitempty"`
@ -1615,6 +1731,86 @@ type ChatBoostAdded struct {
BoostCount int `json:"boost_count"`
}
// BackgroundFill describes the way a background is filled based on the selected colors.
// Currently, it can be one of:
// - BackgroundFillSolid
// - BackgroundFillGradient
// - BackgroundFillFreeformGradient
type BackgroundFill struct {
// Type of the background fill, can be:
// - solid
// - gradient
// - freeform_gradient
Type string `json:"type"`
// BackgroundFillSolid only.
// The color of the background fill in the RGB24 format
Color int `json:"color"`
// BackgroundFillGradient only.
// Top color of the gradient in the RGB24 format
TopColor int `json:"top_color"`
// BackgroundFillGradient only.
// Bottom color of the gradient in the RGB24 format
BottomColor int `json:"bottom_color"`
// BackgroundFillGradient only.
// Clockwise rotation angle of the background fill in degrees; 0-359
RotationAngle int `json:"rotation_angle"`
// BackgroundFillFreeformGradient only.
// A list of the 3 or 4 base colors that are used to generate the freeform gradient in the RGB24 format
Colors []int `json:"colors"`
}
// BackgroundType describes the type of a background. Currently, it can be one of:
// - BackgroundTypeFill
// - BackgroundTypeWallpaper
// - BackgroundTypePattern
// - BackgroundTypeChatTheme
type BackgroundType struct {
// Type of the background.
// Currently, it can be one of:
// - fill
// - wallpaper
// - pattern
// - chat_theme
Type string `json:"type"`
// BackgroundTypeFill and BackgroundTypePattern only.
// The background fill or fill that is combined with the pattern
Fill BackgroundFill `json:"fill"`
// BackgroundTypeFill and BackgroundTypeWallpaper only.
// Dimming of the background in dark themes, as a percentage; 0-100
DarkThemeDimming int `json:"dark_theme_dimming"`
// BackgroundTypeWallpaper and BackgroundTypePattern only.
// Document with the wallpaper / pattern
Document Document `json:"document"`
// BackgroundTypeWallpaper only.
// True, if the wallpaper is downscaled to fit in a 450x450 square and then box-blurred with radius 12
//
// optional
IsBlurred bool `json:"is_blurred,omitempty"`
// BackgroundTypeWallpaper and BackgroundTypePattern only.
// True, if the background moves slightly when the device is tilted
//
// optional
IsMoving bool `json:"is_moving,omitempty"`
// BackgroundTypePattern only.
// Intensity of the pattern when it is shown above the filled background; 0-100
Intensity int `json:"intensity"`
// BackgroundTypePattern only.
// True, if the background fill must be applied only to the pattern itself.
// All other pixels are black in this case. For dark themes only
//
// optional
IsInverted bool `json:"is_inverted,omitempty"`
// BackgroundTypeChatTheme only.
// Name of the chat theme, which is usually an emoji
ThemeName string `json:"theme_name"`
}
// ChatBackground represents a chat background.
type ChatBackground struct {
// Type of the background
Type BackgroundType `json:"type"`
}
// ForumTopicCreated represents a service message about a new forum topic
// created in the chat.
type ForumTopicCreated struct {
@ -1663,13 +1859,37 @@ type GeneralForumTopicHidden struct {
type GeneralForumTopicUnhidden struct {
}
// SharedUser contains information about a user that was
// shared with the bot using a KeyboardButtonRequestUsers button.
type SharedUser struct {
// UserID is the identifier of the shared user.
UserID int64 `json:"user_id"`
// FirstName of the user, if the name was requested by the bot.
//
// optional
FirstName *string `json:"first_name,omitempty"`
// LastName of the user, if the name was requested by the bot.
//
// optional
LastName *string `json:"last_name,omitempty"`
// Username of the user, if the username was requested by the bot.
//
// optional
UserName *string `json:"username,omitempty"`
// Photo is array of available sizes of the chat photo,
// if the photo was requested by the bot
//
// optional
Photo []PhotoSize `json:"photo,omitempty"`
}
// UsersShared object contains information about the user whose identifier
// was shared with the bot using a KeyboardButtonRequestUser button.
type UsersShared struct {
// RequestID is an indentifier of the request.
RequestID int `json:"request_id"`
// UserIDs are identifiers of the shared user.
UserIDs []int64 `json:"user_ids"`
// Users shared with the bot.
Users []SharedUser `json:"users"`
}
// ChatShared contains information about the chat whose identifier
@ -1679,6 +1899,20 @@ type ChatShared struct {
RequestID int `json:"request_id"`
// ChatID is an identifier of the shared chat.
ChatID int64 `json:"chat_id"`
// Title of the chat, if the title was requested by the bot.
//
// optional
Title *string `json:"title,omitempty"`
// UserName of the chat, if the username was requested by
// the bot and available.
//
// optional
UserName *string `json:"username,omitempty"`
// Photo is array of available sizes of the chat photo,
// if the photo was requested by the bot
//
// optional
Photo []PhotoSize `json:"photo,omitempty"`
}
// WriteAccessAllowed represents a service message about a user allowing a bot
@ -2016,6 +2250,18 @@ type KeyboardButtonRequestUsers struct {
//
// optional
MaxQuantity int `json:"max_quantity,omitempty"`
// RequestName pass True to request the users' first and last names
//
// optional
RequestName bool `json:"request_name,omitempty"`
// RequestUsername pass True to request the users' usernames
//
// optional
RequestUsername bool `json:"request_username,omitempty"`
// RequestPhoto pass True to request the users' photos
//
// optional
RequestPhoto bool `json:"request_photo,omitempty"`
}
// KeyboardButtonRequestChat defines the criteria used to request
@ -2062,6 +2308,18 @@ type KeyboardButtonRequestChat struct {
//
// optional
BotIsMember bool `json:"bot_is_member,omitempty"`
// RequestTitle pass True to request the chat's title
//
// optional
RequestTitle bool `json:"request_title,omitempty"`
// RequestUsername pass True to request the chat's username
//
// optional
RequestUsername bool `json:"request_username,omitempty"`
// RequestPhoto pass True to request the chat's photo
//
// optional
RequestPhoto bool `json:"request_photo,omitempty"`
}
// KeyboardButtonPollType represents type of poll, which is allowed to
@ -2166,6 +2424,7 @@ type InlineKeyboardButton struct {
// optional
CallbackGame *CallbackGame `json:"callback_game,omitempty"`
// Pay specify True, to send a Pay button.
// Substrings “⭐” and “XTR” in the buttons's text will be replaced with a Telegram Star icon.
//
// NOTE: This type of button must always be the first button in the first row.
//
@ -2571,6 +2830,12 @@ type ChatMemberUpdated struct {
//
// optional
InviteLink *ChatInviteLink `json:"invite_link,omitempty"`
// ViaJoinRequest is true, if the user joined the chat
// after sending a direct join request
// and being approved by an administrator
//
// optional
ViaJoinRequest bool `json:"via_join_request,omitempty"`
// ViaChatFolderInviteLink is True, if the user joined the chat
// via a chat folder invite link
//
@ -2688,6 +2953,64 @@ func (c *ChatPermissions) CanSendMediaMessages() bool {
c.CanSendVideoNotes && c.CanSendVoiceNotes
}
// Birthdate represents a user's birthdate
type Birthdate struct {
// Day of the user's birth; 1-31
Day int `json:"day"`
// Month of the user's birth; 1-12
Month int `json:"month"`
// Year of the user's birth
//
// optional
Year *int `json:"year,omitempty"`
}
// BusinessIntro represents a basic information about your business
type BusinessIntro struct {
// Title text of the business intro
//
// optional
Title *string `json:"title,omitempty"`
// Message text of the business intro
//
// optional
Message *string `json:"message,omitempty"`
// Sticker of the business intro
//
// optional
Sticker *Sticker `json:"sticker,omitempty"`
}
// BusinessLocation represents a business geodata
type BusinessLocation struct {
// Address of the business
Address string `json:"address"`
// Location of the business
//
// optional
Location *Location `json:"location,omitempty"`
}
// BusinessOpeningHoursInterval represents a business working interval
type BusinessOpeningHoursInterval struct {
// OpeningMinute is the minute's sequence number in a week, starting on Monday,
// marking the start of the time interval during which the business is open; 0 - 7 * 24 * 60
OpeningMinute int `json:"opening_minute"`
// ClosingMinute is the minute's sequence number in a week, starting on Monday,
// marking the end of the time interval during which the business is open; 0 - 8 * 24 * 60
ClosingMinute int `json:"closing_minute"`
}
// BusinessOpeningHours represents a set of business working intervals
type BusinessOpeningHours struct {
// TimeZoneName is the unique name of the time zone
// for which the opening hours are defined
TimeZoneName string `json:"time_zone_name"`
// OpeningHours is the list of time intervals describing
// business opening hours
OpeningHours []BusinessOpeningHoursInterval `json:"opening_hours"`
}
// 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
@ -2904,6 +3227,38 @@ type UserChatBoosts struct {
Boosts []ChatBoost `json:"boosts"`
}
// BusinessConnection describes the connection of the bot with a business account.
type BusinessConnection struct {
// ID is an unique identifier of the business connection
ID string `json:"id"`
// User is a business account user that created the business connection
User User `json:"user"`
// UserChatID identifier of a private chat with the user who
// created the business connection.
UserChatID int64 `json:"user_chat_id"`
// Date the connection was established in Unix time
Date int64 `json:"date"`
// CanReply is True, if the bot can act on behalf of the
// business account in chats that were active in the last 24 hours
CanReply bool `json:"can_reply"`
// IsEnabled is True, if the connection is active
IsEnabled bool `json:"is_enabled"`
}
// BusinessMessagesDeleted is received when messages are deleted
// from a connected business account.
type BusinessMessagesDeleted struct {
// BusinessConnectionID is an unique identifier
// of the business connection
BusinessConnectionID string `json:"business_connection_id"`
// Chat is the information about a chat in the business account.
// The bot may not have access to the chat or the corresponding user.
Chat Chat `json:"chat"`
// MessageIDs is a JSON-serialized list of identifiers of deleted messages
// in the chat of the business account
MessageIDs []int `json:"message_ids"`
}
// ResponseParameters are various errors that can be returned in APIResponse.
type ResponseParameters struct {
// The group has been migrated to a supergroup with the specified identifier.
@ -2944,6 +3299,10 @@ type BaseInputMedia struct {
//
// optional
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
// Pass True, if the caption must be shown above the message media
//
// optional
ShowCaptionAboveMedia bool `json:"show_caption_above_media,omitempty"`
// HasSpoiler pass True, if the photo needs to be covered with a spoiler animation
//
// optional
@ -3139,10 +3498,6 @@ type StickerSet struct {
Title string `json:"title"`
// StickerType of stickers in the set, currently one of “regular”, “mask”, “custom_emoji”
StickerType string `json:"sticker_type"`
// IsAnimated true, if the sticker set contains animated stickers
IsAnimated bool `json:"is_animated"`
// IsVideo true, if the sticker set contains video stickers
IsVideo bool `json:"is_video"`
// ContainsMasks true, if the sticker set contains masks
//
// deprecated. Use sticker_type instead
@ -3190,6 +3545,9 @@ type MaskPosition struct {
type InputSticker struct {
// The added sticker. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, upload a new one using multipart/form-data, or pass “attach://<file_attach_name>” to upload a new one using multipart/form-data under <file_attach_name> name. Animated and video stickers can't be uploaded via HTTP URL.
Sticker RequestFile `json:"sticker"`
// Format of the added sticker, must be one of “static” for a
// .WEBP or .PNG image, “animated” for a .TGS animation, “video” for a WEBM video
Format string `json:"format"`
// List of 1-20 emoji associated with the sticker
EmojiList []string `json:"emoji_list"`
// Position where the mask should be placed on faces. For “mask” stickers only.
@ -3434,6 +3792,10 @@ type InlineQueryResultCachedGIF struct {
//
// optional
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
// Pass True, if the caption must be shown above the message media
//
// optional
ShowCaptionAboveMedia bool `json:"show_caption_above_media,omitempty"`
// ReplyMarkup inline keyboard attached to the message.
//
// optional
@ -3473,6 +3835,10 @@ type InlineQueryResultCachedMPEG4GIF struct {
//
// optional
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
// Pass True, if the caption must be shown above the message media
//
// optional
ShowCaptionAboveMedia bool `json:"show_caption_above_media,omitempty"`
// ReplyMarkup inline keyboard attached to the message.
//
// optional
@ -3514,6 +3880,10 @@ type InlineQueryResultCachedPhoto struct {
//
// optional
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
// Pass True, if the caption must be shown above the message media
//
// optional
ShowCaptionAboveMedia bool `json:"show_caption_above_media,omitempty"`
// ReplyMarkup inline keyboard attached to the message.
//
// optional
@ -3573,6 +3943,10 @@ type InlineQueryResultCachedVideo struct {
//
// optional
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
// Pass True, if the caption must be shown above the message media
//
// optional
ShowCaptionAboveMedia bool `json:"show_caption_above_media,omitempty"`
// ReplyMarkup inline keyboard attached to the message
//
// optional
@ -3815,6 +4189,10 @@ type InlineQueryResultGIF struct {
//
// optional
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
// Pass True, if the caption must be shown above the message media
//
// optional
ShowCaptionAboveMedia bool `json:"show_caption_above_media,omitempty"`
// ReplyMarkup inline keyboard attached to the message
//
// optional
@ -3923,6 +4301,10 @@ type InlineQueryResultMPEG4GIF struct {
//
// optional
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
// Pass True, if the caption must be shown above the message media
//
// optional
ShowCaptionAboveMedia bool `json:"show_caption_above_media,omitempty"`
// ReplyMarkup inline keyboard attached to the message
//
// optional
@ -3983,6 +4365,10 @@ type InlineQueryResultPhoto struct {
//
// optional
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
// Pass True, if the caption must be shown above the message media
//
// optional
ShowCaptionAboveMedia bool `json:"show_caption_above_media,omitempty"`
// InputMessageContent content of the message to be sent instead of the photo.
//
// optional
@ -4062,6 +4448,21 @@ type InlineQueryResultVideo struct {
//
// optional
Caption string `json:"caption,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,omitempty"`
// Pass True, if the caption must be shown above the message media
//
// optional
ShowCaptionAboveMedia bool `json:"show_caption_above_media,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"`
// Width video width
//
// optional
@ -4104,7 +4505,7 @@ type InlineQueryResultVoice struct {
//
// optional
Caption string `json:"caption,omitempty"`
// ParseMode mode for parsing entities in the video caption.
// ParseMode mode for parsing entities in the voice caption.
// See formatting options for more details
// (https://core.telegram.org/bots/api#formatting-options).
//
@ -4267,9 +4668,11 @@ type InputInvoiceMessageContent struct {
// Bot-defined invoice payload, 1-128 bytes. This will not be displayed to
// the user, use for your internal processes.
Payload string `json:"payload"`
// Payment provider token, obtained via Botfather
// Payment provider token, obtained via Botfather. Pass an empty string for payments in Telegram Stars.
//
// optional
ProviderToken string `json:"provider_token"`
// Three-letter ISO 4217 currency code
// Three-letter ISO 4217 currency code. Pass “XTR” for payments in Telegram Stars.
Currency string `json:"currency"`
// Price breakdown, a JSON-serialized list of components (e.g. product
// price, tax, discount, delivery cost, delivery tax, bonus, etc.)
@ -4361,7 +4764,7 @@ type Invoice struct {
Description string `json:"description"`
// StartParameter unique bot deep-linking parameter that can be used to generate this invoice
StartParameter string `json:"start_parameter"`
// Currency three-letter ISO 4217 currency code
// Currency three-letter ISO 4217 currency code, or “XTR” for payments in Telegram Stars
// (see https://core.telegram.org/bots/payments#supported-currencies)
Currency string `json:"currency"`
// TotalAmount total price in the smallest units of the currency (integer, not float/double).
@ -4421,7 +4824,7 @@ type ShippingOption struct {
// SuccessfulPayment contains basic information about a successful payment.
type SuccessfulPayment struct {
// Currency three-letter ISO 4217 currency code
// Currency three-letter ISO 4217 currency code, or “XTR” for payments in Telegram Stars
// (see https://core.telegram.org/bots/payments#supported-currencies)
Currency string `json:"currency"`
// TotalAmount total price in the smallest units of the currency (integer, not float/double).
@ -4465,7 +4868,7 @@ type PreCheckoutQuery struct {
ID string `json:"id"`
// From user who sent the query
From *User `json:"from"`
// Currency three-letter ISO 4217 currency code
// Currency three-letter ISO 4217 currency code, or “XTR” for payments in Telegram Stars
// // (see https://core.telegram.org/bots/payments#supported-currencies)
Currency string `json:"currency"`
// TotalAmount total price in the smallest units of the currency (integer, not float/double).

View File

@ -308,6 +308,7 @@ var (
_ Chattable = FileConfig{}
_ Chattable = ForwardConfig{}
_ Chattable = GameConfig{}
_ Chattable = GetBusinessConnectionConfig{}
_ Chattable = GetChatMemberConfig{}
_ Chattable = GetChatMenuButtonConfig{}
_ Chattable = GetGameHighScoresConfig{}
@ -324,6 +325,7 @@ var (
_ Chattable = PinChatMessageConfig{}
_ Chattable = PreCheckoutConfig{}
_ Chattable = PromoteChatMemberConfig{}
_ Chattable = ReplaceStickerInSetConfig{}
_ Chattable = RestrictChatMemberConfig{}
_ Chattable = RevokeChatInviteLinkConfig{}
_ Chattable = SendPollConfig{}
@ -373,6 +375,7 @@ var (
_ Chattable = SetMyShortDescriptionConfig{}
_ Chattable = GetMyNameConfig{}
_ Chattable = SetMyNameConfig{}
_ Chattable = RefundStarPaymentConfig{}
)
// Ensure all Fileable types are correct.