package tgapi import "encoding/json" // UpdateType represents the type of incoming update. type UpdateType string const ( // UpdateTypeUnknown marks an update whose payload does not match a known Telegram update kind. UpdateTypeUnknown UpdateType = "unknown" // UpdateTypeMessage is a regular message update. UpdateTypeMessage UpdateType = "message" // UpdateTypeEditedMessage is an edited message update. UpdateTypeEditedMessage UpdateType = "edited_message" // UpdateTypeChannelPost is a channel post update. UpdateTypeChannelPost UpdateType = "channel_post" // UpdateTypeEditedChannelPost is an edited channel post update. UpdateTypeEditedChannelPost UpdateType = "edited_channel_post" // UpdateTypeMessageReaction is a message reaction update. UpdateTypeMessageReaction UpdateType = "message_reaction" // UpdateTypeMessageReactionCount is a message reaction count update. UpdateTypeMessageReactionCount UpdateType = "message_reaction_count" // UpdateTypeBusinessConnection is a business connection update. UpdateTypeBusinessConnection UpdateType = "business_connection" // UpdateTypeBusinessMessage is a business message update. UpdateTypeBusinessMessage UpdateType = "business_message" // UpdateTypeEditedBusinessMessage is an edited business message update. UpdateTypeEditedBusinessMessage UpdateType = "edited_business_message" // UpdateTypeDeletedBusinessMessages is a deleted business messages update. UpdateTypeDeletedBusinessMessages UpdateType = "deleted_business_messages" // UpdateTypeInlineQuery is an inline query update. UpdateTypeInlineQuery UpdateType = "inline_query" // UpdateTypeChosenInlineResult is a chosen inline result update. UpdateTypeChosenInlineResult UpdateType = "chosen_inline_result" // UpdateTypeCallbackQuery is a callback query update. UpdateTypeCallbackQuery UpdateType = "callback_query" // UpdateTypeShippingQuery is a shipping query update. UpdateTypeShippingQuery UpdateType = "shipping_query" // UpdateTypePreCheckoutQuery is a pre-checkout query update. UpdateTypePreCheckoutQuery UpdateType = "pre_checkout_query" // UpdateTypePurchasedPaidMedia is a purchased paid media update. UpdateTypePurchasedPaidMedia UpdateType = "purchased_paid_media" // UpdateTypePoll is a poll update. UpdateTypePoll UpdateType = "poll" // UpdateTypePollAnswer is a poll answer update. UpdateTypePollAnswer UpdateType = "poll_answer" // UpdateTypeMyChatMember is a my chat member update. UpdateTypeMyChatMember UpdateType = "my_chat_member" // UpdateTypeChatMember is a chat member update. UpdateTypeChatMember UpdateType = "chat_member" // UpdateTypeChatJoinRequest is a chat join request update. UpdateTypeChatJoinRequest UpdateType = "chat_join_request" // UpdateTypeChatBoost is a chat boost update. UpdateTypeChatBoost UpdateType = "chat_boost" // UpdateTypeRemovedChatBoost is a removed chat boost update. UpdateTypeRemovedChatBoost UpdateType = "removed_chat_boost" // UpdateTypeManagedBot is a managed bot update. UpdateTypeManagedBot UpdateType = "managed_bot" // UpdateTypeGuestMessage is a guest message update. UpdateTypeGuestMessage UpdateType = "guest_message" // UpdateTypeSubscription is a bot subscription update. // // Since: Bot API 10.2 UpdateTypeSubscription UpdateType = "subscription" ) // Update represents an incoming update from Telegram. // Since: Bot API 1.0 // See https://core.telegram.org/bots/api#update type Update struct { // Type is the locally derived update type and is not part of Telegram JSON. Type UpdateType `json:"-"` // UpdateID The update's unique identifier. Update identifiers start from a certain positive number and // increase sequentially. This identifier becomes especially handy if you're using webhooks, since it allows // you to ignore repeated updates or to restore the correct update sequence, should they get out of order. // If there are no new updates for at least a week, then identifier of the next update will be chosen // randomly instead of sequentially. UpdateID int `json:"update_id"` // Message Optional. New incoming message of any kind - text, photo, sticker, etc. Message *Message `json:"message,omitempty"` // EditedMessage Optional. New version of a message that is known to the bot and was edited. This update may // at times be triggered by changes to message fields that are either unavailable or not actively used by // your bot. EditedMessage *Message `json:"edited_message,omitempty"` // ChannelPost Optional. New incoming channel post of any kind - text, photo, sticker, etc. ChannelPost *Message `json:"channel_post,omitempty"` // Since: Bot API 2.3 // EditedChannelPost Optional. New version of a channel post that is known to the bot and was edited. This // update may at times be triggered by changes to message fields that are either unavailable or not actively // used by your bot. EditedChannelPost *Message `json:"edited_channel_post,omitempty"` // Since: Bot API 2.3 // BusinessConnection Optional. The bot was connected to or disconnected from a business account, or a user // edited an existing connection with the bot BusinessConnection *BusinessConnection `json:"business_connection,omitempty"` // Since: Bot API 7.2 // BusinessMessage Optional. New message from a connected business account BusinessMessage *Message `json:"business_message,omitempty"` // Since: Bot API 7.2 // EditedBusinessMessage Optional. New version of a message from a connected business account EditedBusinessMessage *Message `json:"edited_business_message,omitempty"` // Since: Bot API 7.2 // DeletedBusinessMessages Optional. Messages were deleted from a connected business account DeletedBusinessMessages *BusinessMessagesDeleted `json:"deleted_business_messages,omitempty"` // Since: Bot API 7.2 // GuestMessage Optional. New guest message. The bot can use the field Message.guest_query_id and the method // answerGuestQuery to send a message in response. GuestMessage *Message `json:"guest_message,omitempty"` // Since: Bot API 10.0 // MessageReaction Optional. A reaction to a message was changed by a user. The bot must be an administrator // in the chat and must explicitly specify "message_reaction" in the list of allowed_updates to receive // these updates. The update isn't received for reactions set by bots. MessageReaction *MessageReactionUpdated `json:"message_reaction,omitempty"` // Since: Bot API 7.0 // MessageReactionCount Optional. Reactions to a message with anonymous reactions were changed. The bot must // be an administrator in the chat and must explicitly specify "message_reaction_count" in the list of // allowed_updates to receive these updates. The updates are grouped and can be sent with delay up to a few // minutes. MessageReactionCount *MessageReactionCountUpdated `json:"message_reaction_count,omitempty"` // Since: Bot API 7.0 // InlineQuery Optional. New incoming inline query InlineQuery *InlineQuery `json:"inline_query,omitempty"` // Since: Bot API 1.7 // ChosenInlineResult Optional. The result of an inline query that was chosen by a user and sent to their // chat partner. Please see our documentation on the feedback collecting for details on how to enable these // updates for your bot. ChosenInlineResult *ChosenInlineResult `json:"chosen_inline_result,omitempty"` // Since: Bot API 1.8 // CallbackQuery Optional. New incoming callback query CallbackQuery *CallbackQuery `json:"callback_query,omitempty"` // Since: Bot API 2.0 // ShippingQuery Optional. New incoming shipping query. Only for invoices with flexible price. ShippingQuery *ShippingQuery `json:"shipping_query,omitempty"` // Since: Bot API 3.0 // PreCheckoutQuery Optional. New incoming pre-checkout query. Contains full information about checkout. PreCheckoutQuery *PreCheckoutQuery `json:"pre_checkout_query,omitempty"` // Since: Bot API 3.0 // PurchasedPaidMedia Optional. A user purchased paid media with a non-empty payload sent by the bot in a // non-channel chat PurchasedPaidMedia *PaidMediaPurchased `json:"purchased_paid_media,omitempty"` // Since: Bot API 7.10 // Poll Optional. New poll state. Bots receive only updates about manually stopped polls and polls, which // are sent by the bot. Poll *Poll `json:"poll,omitempty"` // Since: Bot API 4.2 // PollAnswer Optional. A user changed their answer in a non-anonymous poll. Bots receive new votes only in // polls that were sent by the bot itself. PollAnswer *PollAnswer `json:"poll_answer,omitempty"` // Since: Bot API 4.6 // MyChatMember Optional. 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. MyChatMember *ChatMemberUpdated `json:"my_chat_member,omitempty"` // Since: Bot API 5.1 // ChatMember Optional. 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. ChatMember *ChatMemberUpdated `json:"chat_member,omitempty"` // Since: Bot API 5.1 // ChatJoinRequest Optional. A request to join the chat has been sent. The bot must have the // can_invite_users administrator right in the chat to receive these updates. ChatJoinRequest *ChatJoinRequest `json:"chat_join_request,omitempty"` // Since: Bot API 5.4 // ChatBoost Optional. A chat boost was added or changed. The bot must be an administrator in the chat to // receive these updates. ChatBoost *ChatBoostUpdated `json:"chat_boost,omitempty"` // Since: Bot API 7.0 // RemovedChatBoost Optional. A boost was removed from a chat. The bot must be an administrator in the chat // to receive these updates. RemovedChatBoost *ChatBoostRemoved `json:"removed_chat_boost,omitempty"` // Since: Bot API 7.0 // ManagedBot Optional. A new bot was created to be managed by the bot, or token or owner of a managed bot // was changed ManagedBot *ManagedBotUpdated `json:"managed_bot,omitempty"` // Since: Bot API 9.6 // Subscription contains a bot subscription update. Subscription *BotSubscriptionUpdated `json:"subscription,omitempty"` // Since: Bot API 10.2 } // UnmarshalJSON decodes an update and derives its Type from the populated payload field. func (u *Update) UnmarshalJSON(data []byte) error { type Alias Update var aux Alias if err := json.Unmarshal(data, &aux); err != nil { return err } *u = Update(aux) switch { case u.Message != nil: u.Type = UpdateTypeMessage case u.EditedMessage != nil: u.Type = UpdateTypeEditedMessage case u.ChannelPost != nil: u.Type = UpdateTypeChannelPost case u.EditedChannelPost != nil: u.Type = UpdateTypeEditedChannelPost case u.BusinessConnection != nil: u.Type = UpdateTypeBusinessConnection case u.BusinessMessage != nil: u.Type = UpdateTypeBusinessMessage case u.EditedBusinessMessage != nil: u.Type = UpdateTypeEditedBusinessMessage case u.DeletedBusinessMessages != nil: u.Type = UpdateTypeDeletedBusinessMessages case u.GuestMessage != nil: u.Type = UpdateTypeGuestMessage case u.MessageReaction != nil: u.Type = UpdateTypeMessageReaction case u.MessageReactionCount != nil: u.Type = UpdateTypeMessageReactionCount case u.InlineQuery != nil: u.Type = UpdateTypeInlineQuery case u.ChosenInlineResult != nil: u.Type = UpdateTypeChosenInlineResult case u.CallbackQuery != nil: u.Type = UpdateTypeCallbackQuery case u.ShippingQuery != nil: u.Type = UpdateTypeShippingQuery case u.PreCheckoutQuery != nil: u.Type = UpdateTypePreCheckoutQuery case u.PurchasedPaidMedia != nil: u.Type = UpdateTypePurchasedPaidMedia case u.Poll != nil: u.Type = UpdateTypePoll case u.PollAnswer != nil: u.Type = UpdateTypePollAnswer case u.MyChatMember != nil: u.Type = UpdateTypeMyChatMember case u.ChatMember != nil: u.Type = UpdateTypeChatMember case u.ChatJoinRequest != nil: u.Type = UpdateTypeChatJoinRequest case u.ChatBoost != nil: u.Type = UpdateTypeChatBoost case u.RemovedChatBoost != nil: u.Type = UpdateTypeRemovedChatBoost case u.ManagedBot != nil: u.Type = UpdateTypeManagedBot case u.Subscription != nil: u.Type = UpdateTypeSubscription default: u.Type = UpdateTypeUnknown } return nil } // WebhookInfo describes the current webhook status. // Since: Bot API 2.2 // See https://core.telegram.org/bots/api#webhookinfo type WebhookInfo struct { // URL Webhook URL, may be empty if webhook is not set up URL string `json:"url"` // HasCustomCertificate True, if a custom certificate was provided for webhook certificate checks HasCustomCertificate bool `json:"has_custom_certificate"` // PendingUpdateCount Number of updates awaiting delivery PendingUpdateCount int `json:"pending_update_count"` // IPAddress Optional. Currently used webhook IP address IPAddress string `json:"ip_address,omitempty"` // LastErrorDate Optional. Unix time for the most recent error that happened when trying to deliver an // update via webhook LastErrorDate int `json:"last_error_date,omitempty"` // LastErrorMessage Optional. Error message in human-readable format for the most recent error that happened // when trying to deliver an update via webhook LastErrorMessage string `json:"last_error_message,omitempty"` // LastSynchronizationErrorDate Optional. Unix time of the most recent error that happened when trying to // synchronize available updates with Telegram datacenters LastSynchronizationErrorDate int `json:"last_synchronization_error_date,omitempty"` // MaxConnections Optional. The maximum allowed number of simultaneous HTTPS connections to the webhook for // update delivery MaxConnections int `json:"max_connections,omitempty"` // AllowedUpdates Optional. A list of update types the bot is subscribed to. Defaults to all update types // except chat_member, message_reaction, and message_reaction_count. AllowedUpdates []string `json:"allowed_updates,omitempty"` } // ProximityAlertTriggered represents the content of a service message sent when a user triggers a proximity alert. // Since: Bot API 5.0 type ProximityAlertTriggered struct { // Traveler User that triggered the alert Traveler User `json:"traveler"` // Watcher User that set the alert Watcher User `json:"watcher"` // Distance The distance between the users Distance int `json:"distance"` } // InlineQuery represents an incoming inline query. // Since: Bot API 1.7 // See https://core.telegram.org/bots/api#inlinequery type InlineQuery struct { // ID Unique identifier for this query ID string `json:"id"` // From Sender From User `json:"from"` // Query Text of the query (up to 256 characters) Query string `json:"query"` // Offset Offset of the results to be returned, can be controlled by the bot Offset string `json:"offset"` // ChatType Optional. Type of the chat from which the inline query was sent. Can be either “sender” for // a private chat with the inline query sender, “private”, “group”, “supergroup”, or // “channel”. The chat type should be always known for requests sent from official clients and most // third-party clients, unless the request was sent from a secret chat. ChatType *ChatType `json:"chat_type,omitempty"` // Location Optional. Sender location, only for bots that request user location Location *Location `json:"location,omitempty"` } // ChosenInlineResult represents a result of an inline query that was chosen by the user. // Since: Bot API 1.8 // See https://core.telegram.org/bots/api#choseninlineresult type ChosenInlineResult struct { // ResultID The unique identifier for the result that was chosen ResultID string `json:"result_id"` // From The user that chose the result From User `json:"from"` // Location Optional. Sender location, only for bots that require user location Location *Location `json:"location,omitempty"` // InlineMessageID Optional. Identifier of the sent inline message. Available only if there is an inline // keyboard attached to the message. Will be also received in callback queries and can be used to edit the // message. InlineMessageID string `json:"inline_message_id"` // Query The query that was used to obtain the result Query string `json:"query"` } // File represents a file ready to be downloaded. // Since: Bot API 1.0 // See https://core.telegram.org/bots/api#file type File struct { // FileID Identifier for this file, which can be used to download or reuse the file FileID string `json:"file_id"` // FileUniqueID Unique identifier for this file, which is supposed to be the same over time and for // different bots. Can't be used to download or reuse the file. FileUniqueID string `json:"file_unique_id"` // FileSize Optional. File size in bytes. It can be bigger than 2^31 and some programming languages may have // difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit // integer or double-precision float type are safe for storing this value. FileSize int64 `json:"file_size,omitempty"` // FilePath Optional. File path. Use https://api.telegram.org/file/bot/ to get the file. FilePath string `json:"file_path,omitempty"` } // ChatMemberUpdated represents changes in the status of a chat member. // Since: Bot API 5.1 // See https://core.telegram.org/bots/api#chatmemberupdated type ChatMemberUpdated struct { // Chat Chat the user belongs to Chat Chat `json:"chat"` // From Performer of the action, which resulted in the change From User `json:"from"` // Date Date the change was done in Unix time Date int64 `json:"date"` // OldChatMember Previous information about the chat member OldChatMember ChatMember `json:"old_chat_member"` // NewChatMember New information about the chat member NewChatMember ChatMember `json:"new_chat_member"` // InviteLink Optional. Chat invite link, which was used by the user to join the chat; for joining by invite // link events only InviteLink *ChatInviteLink `json:"invite_link,omitempty"` // ViaJoinRequest Optional. True, if the user joined the chat after sending a direct join request without // using an invite link and being approved by an administrator ViaJoinRequest *bool `json:"via_join_request,omitempty"` // ViaChatFolderInviteLink Optional. True, if the user joined the chat via a chat folder invite link ViaChatFolderInviteLink *bool `json:"via_chat_folder_invite_link,omitempty"` } // ChatJoinRequest represents a join request sent to a chat. // Since: Bot API 5.4 // See https://core.telegram.org/bots/api#chatjoinrequest type ChatJoinRequest struct { // Chat Chat to which the request was sent Chat Chat `json:"chat"` // From User that sent the join request From User `json:"from"` // UserChatID Identifier of a private chat with the user who sent the join request. This number may have // more than 32 significant bits and some programming languages may have difficulty/silent defects in // interpreting it. But it has at most 52 significant bits, so a 64-bit integer or double-precision float // type are safe for storing this identifier. The bot can use this identifier for 5 minutes to send messages // until the join request is processed, assuming no other administrator contacted the user. UserChatID int64 `json:"user_chat_id"` // Date Date the request was sent in Unix time Date int64 `json:"date"` // Bio Optional. Bio of the user Bio *string `json:"bio,omitempty"` // InviteLink Optional. Chat invite link that was used by the user to send the join request InviteLink *ChatInviteLink `json:"invite_link,omitempty"` // QueryID identifies the join request query; present only for bots // assigned to process join requests. When set, the bot must call // SendChatJoinRequestWebApp or AnswerChatJoinRequestQuery within 10 seconds. QueryID *string `json:"query_id,omitempty"` // Since: Bot API 10.1 } // Location represents a point on the map. // Since: Bot API 1.0 // See https://core.telegram.org/bots/api#location type Location struct { // Latitude Latitude as defined by the sender Latitude float64 `json:"latitude"` // Longitude Longitude as defined by the sender Longitude float64 `json:"longitude"` // HorizontalAccuracy Optional. The radius of uncertainty for the location, measured in meters; 0-1500 HorizontalAccuracy float64 `json:"horizontal_accuracy"` // LivePeriod Optional. Time relative to the message sending date, during which the location can be updated; // in seconds. For active live locations only. LivePeriod int `json:"live_period"` // Heading Optional. The direction in which user is moving, in degrees; 1-360. For active live locations // only. Heading int `json:"heading"` // ProximityAlertRadius Optional. The maximum distance for proximity alerts about approaching another chat // member, in meters. For sent live locations only. ProximityAlertRadius int `json:"proximity_alert_radius"` } // LocationAddress represents a human-readable address of a location. // Since: Bot API 8.0 type LocationAddress struct { // CountryCode The two-letter ISO 3166-1 alpha-2 country code of the country where the location is located CountryCode string `json:"country_code"` // State Optional. State of the location State *string `json:"state,omitempty"` // City Optional. City of the location City *string `json:"city,omitempty"` // Street Optional. Street address of the location Street *string `json:"street,omitempty"` } // Venue represents a venue. // Since: Bot API 2.0 // See https://core.telegram.org/bots/api#venue type Venue struct { // Location Venue location. Can't be a live location. Location Location `json:"location"` // Title Name of the venue Title string `json:"title"` // Address Address of the venue Address string `json:"address"` // FoursquareID Optional. Foursquare identifier of the venue FoursquareID string `json:"foursquare_id,omitempty"` // FoursquareType Optional. Foursquare type of the venue. (For example, “arts_entertainment/default”, // “arts_entertainment/aquarium” or “food/icecream”.) FoursquareType string `json:"foursquare_type,omitempty"` // GooglePlaceID Optional. Google Places identifier of the venue GooglePlaceID string `json:"google_place_id,omitempty"` // GooglePlaceType Optional. Google Places type of the venue. (See supported types.) GooglePlaceType string `json:"google_place_type,omitempty"` } // WebAppInfo contains information about a Web App. // Since: Bot API 6.0 // See https://core.telegram.org/bots/api#webappinfo type WebAppInfo struct { // URL An HTTPS URL of a Web App to be opened with additional data as specified in Initializing Web Apps URL string `json:"url"` } // WebAppData represents data sent from a Web App to the bot. // Since: Bot API 6.0 type WebAppData struct { // Data The data. Be aware that a bad client can send arbitrary data in this field. Data string `json:"data"` // ButtonText Text of the web_app keyboard button from which the Web App was opened. Be aware that a bad // client can send arbitrary data in this field. ButtonText string `json:"button_text"` } // StarAmount represents an amount of Telegram Stars. // Since: Bot API 7.5 type StarAmount struct { // Amount Integer amount of Telegram Stars, rounded to 0; can be negative Amount int `json:"amount"` // NanostarAmount Optional. The number of 1/1000000000 shares of Telegram Stars; from -999999999 to // 999999999; can be negative if and only if amount is non-positive NanostarAmount int `json:"nanostar_amount"` } // AcceptedGiftTypes represents the types of gifts accepted by a user or chat. // Since: Bot API 9.0 type AcceptedGiftTypes struct { // UnlimitedGifts True, if unlimited regular gifts are accepted UnlimitedGifts bool `json:"unlimited_gifts"` // LimitedGifts True, if limited regular gifts are accepted LimitedGifts bool `json:"limited_gifts"` // UniqueGifts True, if unique gifts or gifts that can be upgraded to unique for free are accepted UniqueGifts bool `json:"unique_gifts"` // PremiumSubscription True, if a Telegram Premium subscription is accepted PremiumSubscription bool `json:"premium_subscription"` // GiftsFromChannels True, if transfers of unique gifts from channels are accepted GiftsFromChannels bool `json:"gifts_from_channels"` } // GiftBackground represents the background of a gift. // Since: Bot API 9.0 type GiftBackground struct { // CenterColor Center color of the background in RGB format CenterColor int `json:"center_color"` // EdgeColor Edge color of the background in RGB format EdgeColor int `json:"edge_color"` // TextColor Text color of the background in RGB format TextColor int `json:"text_color"` } // Gift represents a gift that can be sent. // Since: Bot API 9.0 type Gift struct { // ID Unique identifier of the gift ID string `json:"id"` // Sticker The sticker that represents the gift Sticker Sticker `json:"sticker"` // StarCount The number of Telegram Stars that must be paid to send the sticker StarCount int `json:"star_count"` // UpdateStarCount is the number of Stars required to upgrade the gift. UpdateStarCount *int `json:"update_star_count,omitempty"` // IsPremium Optional. True, if the gift can only be purchased by Telegram Premium subscribers IsPremium *bool `json:"is_premium,omitempty"` // HasColors Optional. True, if the gift can be used (after being upgraded) to customize a user's appearance HasColors *bool `json:"has_colors,omitempty"` // TotalCount Optional. The total number of gifts of this type that can be sent by all users; for limited // gifts only TotalCount *int `json:"total_count,omitempty"` // RemainingCount Optional. The number of remaining gifts of this type that can be sent by all users; for // limited gifts only RemainingCount *int `json:"remaining_count,omitempty"` // PersonalTotalCount Optional. The total number of gifts of this type that can be sent by the bot; for // limited gifts only PersonalTotalCount *int `json:"personal_total_count,omitempty"` // PersonalRemainingCount Optional. The number of remaining gifts of this type that can be sent by the bot; // for limited gifts only PersonalRemainingCount *int `json:"personal_remaining_count,omitempty"` // Background Optional. Background of the gift Background *GiftBackground `json:"background,omitempty"` // UniqueGiftVariantColor identifies the color used by unique variants of the gift. UniqueGiftVariantColor *int `json:"unique_gift_variant_color,omitempty"` // PublisherChat Optional. Information about the chat that published the gift PublisherChat *Chat `json:"publisher_chat,omitempty"` } // Gifts represents a list of gifts. // Since: Bot API 9.0 type Gifts struct { // Gifts The list of gifts Gifts []Gift `json:"gifts"` } // UniqueGiftModel describes the model component of a unique gift. // Since: Bot API 9.0 type UniqueGiftModel struct { // Name Name of the model Name string `json:"name"` // Sticker The sticker that represents the unique gift Sticker Sticker `json:"sticker"` // RarityPerMille The number of unique gifts that receive this model for every 1000 gift upgrades. Always 0 // for crafted gifts. RarityPerMille int `json:"rarity_per_mille"` // Rarity Optional. Rarity of the model if it is a crafted model. Currently, can be “uncommon”, // “rare”, “epic”, or “legendary”. Rarity string `json:"rarity,omitempty"` } // UniqueGiftSymbol describes the symbol component of a unique gift. // Since: Bot API 9.0 type UniqueGiftSymbol struct { // Name Name of the symbol Name string `json:"name"` // Sticker The sticker that represents the unique gift Sticker Sticker `json:"sticker"` // RarityPerMille The number of unique gifts that receive this model for every 1000 gifts upgraded RarityPerMille int `json:"rarity_per_mille"` } // UniqueGiftBackdropColors describes the colors of a unique gift backdrop. // Since: Bot API 9.0 type UniqueGiftBackdropColors struct { // CenterColor The color in the center of the backdrop in RGB format CenterColor int `json:"center_color"` // EdgeColor The color on the edges of the backdrop in RGB format EdgeColor int `json:"edge_color"` // SymbolColor The color to be applied to the symbol in RGB format SymbolColor int `json:"symbol_color"` // TextColor The color for the text on the backdrop in RGB format TextColor int `json:"text_color"` } // UniqueGiftBackdrop describes the backdrop of a unique gift. // Since: Bot API 9.0 type UniqueGiftBackdrop struct { // Name Name of the backdrop Name string `json:"name"` // Colors Colors of the backdrop Colors UniqueGiftBackdropColors `json:"colors"` // RarityPerMille The number of unique gifts that receive this backdrop for every 1000 gifts upgraded RarityPerMille int `json:"rarity_per_mille"` } // UniqueGiftColors represents color information for a unique gift. // Since: Bot API 9.3 type UniqueGiftColors struct { // ModelCustomEmojiID Custom emoji identifier of the unique gift's model ModelCustomEmojiID string `json:"model_custom_emoji_id"` // SymbolCustomEmojiID Custom emoji identifier of the unique gift's symbol SymbolCustomEmojiID string `json:"symbol_custom_emoji_id"` // LightThemeMainColor Main color used in light themes; RGB format LightThemeMainColor int `json:"light_theme_main_color"` // LightThemeOtherColors List of 1-3 additional colors used in light themes; RGB format LightThemeOtherColors []int `json:"light_theme_other_colors"` // DarkThemeMainColor Main color used in dark themes; RGB format DarkThemeMainColor int `json:"dark_theme_main_color"` // DarkThemeOtherColors List of 1-3 additional colors used in dark themes; RGB format DarkThemeOtherColors []int `json:"dark_theme_other_colors"` } // UniqueGift represents a unique gift. // Since: Bot API 9.0 type UniqueGift struct { // GiftID Identifier of the regular gift from which the gift was upgraded GiftID string `json:"gift_id"` // BaseName Human-readable name of the regular gift from which this unique gift was upgraded BaseName string `json:"base_name"` // Name Unique name of the gift. This name can be used in https://t.me/nft/... links and story areas. Name string `json:"name"` // Number Unique number of the upgraded gift among gifts upgraded from the same regular gift Number int `json:"number"` // Model Model of the gift Model UniqueGiftModel `json:"model"` // Symbol Symbol of the gift Symbol UniqueGiftSymbol `json:"symbol"` // Backdrop Backdrop of the gift Backdrop UniqueGiftBackdrop `json:"backdrop"` // IsPremium Optional. True, if the original regular gift was exclusively purchaseable by Telegram Premium // subscribers IsPremium bool `json:"is_premium,omitempty"` // IsBurned Optional. True, if the gift was used to craft another gift and isn't available anymore IsBurned bool `json:"is_burned,omitempty"` // IsFromBlockchain Optional. True, if the gift is assigned from the TON blockchain and can't be resold or // transferred in Telegram IsFromBlockchain bool `json:"is_from_blockchain,omitempty"` // Colors Optional. The color scheme that can be used by the gift's owner for the chat's name, replies to // messages and link previews; for business account gifts and gifts that are currently on sale only Colors *UniqueGiftColors `json:"colors,omitempty"` // PublisherChat Optional. Information about the chat that published the gift PublisherChat *Chat `json:"publisher_chat,omitempty"` } // GiftInfo contains information about a received gift. // Since: Bot API 9.0 type GiftInfo struct { // Gift Information about the gift Gift Gift `json:"gift"` // OwnedGiftID Optional. Unique identifier of the received gift for the bot; only present for gifts received // on behalf of business accounts OwnedGiftID string `json:"owned_gift_id,omitempty"` // ConvertStarCount Optional. Number of Telegram Stars that can be claimed by the receiver by converting the // gift; omitted if conversion to Telegram Stars is impossible ConvertStarCount int `json:"convert_star_count,omitempty"` // PrepaidUpgradeStarCount Optional. Number of Telegram Stars that were prepaid for the ability to upgrade // the gift PrepaidUpgradeStarCount int `json:"prepaid_upgrade_star_count,omitempty"` // IsUpgradeSeparate Optional. True, if the gift's upgrade was purchased after the gift was sent IsUpgradeSeparate bool `json:"is_upgrade_separate,omitempty"` // CanBeUpgraded Optional. True, if the gift can be upgraded to a unique gift CanBeUpgraded bool `json:"can_be_upgraded,omitempty"` // Text Optional. Text of the message that was added to the gift Text string `json:"text,omitempty"` // Entities Optional. Special entities that appear in the text Entities []MessageEntity `json:"entities,omitempty"` // IsPrivate Optional. True, if the sender and gift text are shown only to the gift receiver; otherwise, // everyone will be able to see them IsPrivate bool `json:"is_private,omitempty"` // UniqueGiftNumber Optional. Unique number reserved for this gift when upgraded. See the number field in // UniqueGift. UniqueGiftNumber int `json:"unique_gift_number,omitempty"` } // UniqueGiftInfo contains information about a received unique gift. // Since: Bot API 9.0 type UniqueGiftInfo struct { // Gift Information about the gift Gift UniqueGift `json:"gift"` // Origin Origin of the gift. Currently, either “upgrade” for gifts upgraded from regular gifts, // “transfer” for gifts transferred from other users or channels, “resale” for gifts bought from // other users, “gifted_upgrade” for upgrades purchased after the gift was sent, or “offer” for // gifts bought or sold through gift purchase offers. Origin string `json:"origin"` // LastResaleCurrency Optional. For gifts bought from other users, the currency in which the payment for the // gift was done. Currently, one of “XTR” for Telegram Stars or “TON” for TON grams. LastResaleCurrency string `json:"last_resale_currency,omitempty"` // LastResaleAmount Optional. For gifts bought from other users, the price paid for the gift in either // Telegram Stars or nanograms LastResaleAmount int `json:"last_resale_amount,omitempty"` // OwnedGiftID Optional. Unique identifier of the received gift for the bot; only present for gifts received // on behalf of business accounts OwnedGiftID string `json:"owned_gift_id,omitempty"` // TransferStarCount Optional. Number of Telegram Stars that must be paid to transfer the gift; omitted if // the bot cannot transfer the gift TransferStarCount int `json:"transfer_star_count,omitempty"` // NextTransferDate Optional. Point in time (Unix timestamp) when the gift can be transferred. If it is in // the past, then the gift can be transferred now. NextTransferDate int `json:"next_transfer_date,omitempty"` } // OwnedGiftType represents the type of an owned gift. // Since: Bot API 9.0 type OwnedGiftType string const ( // OwnedGiftRegularType identifies a regular owned gift. OwnedGiftRegularType OwnedGiftType = "regular" // OwnedGiftUniqueType identifies a unique owned gift. OwnedGiftUniqueType OwnedGiftType = "unique" ) // OwnedGift represents a gift owned by a user or chat. // Since: Bot API 9.0 type OwnedGift struct { // Type identifies the regular or unique owned-gift variant. Type OwnedGiftType `json:"type"` // OwnedGiftID uniquely identifies a business account's owned gift when available. OwnedGiftID string `json:"owned_gift_id,omitempty"` // SendDate Date the gift was sent in Unix time SendDate int `json:"send_date,omitempty"` // IsSaved Optional. True, if the gift is displayed on the account's profile page; for gifts received on // behalf of business accounts only IsSaved bool `json:"is_saved,omitempty"` // Gift contains the regular gift for the regular variant. // Fields specific to "regular" type Gift Gift `json:"gift"` // SenderUser Optional. Sender of the gift if it is a known user SenderUser *User `json:"sender_user,omitempty"` // Text Optional. Text of the message that was added to the gift Text string `json:"text,omitempty"` // Entities Optional. Special entities that appear in the text Entities []MessageEntity `json:"entities,omitempty"` // IsPrivate Optional. True, if the sender and gift text are shown only to the gift receiver; otherwise, // everyone will be able to see them IsPrivate bool `json:"is_private,omitempty"` // CanBeUpgraded Optional. True, if the gift can be upgraded to a unique gift; for gifts received on behalf // of business accounts only CanBeUpgraded bool `json:"can_be_upgraded,omitempty"` // WasRefunded Optional. True, if the gift was refunded and isn't available anymore WasRefunded bool `json:"was_refunded,omitempty"` // ConvertStarCount Optional. Number of Telegram Stars that can be claimed by the receiver instead of the // gift; omitted if the gift cannot be converted to Telegram Stars; for gifts received on behalf of business // accounts only ConvertStarCount int `json:"convert_star_count,omitempty"` // PrepaidUpgradeStarCount Optional. Number of Telegram Stars that were paid for the ability to upgrade the // gift PrepaidUpgradeStarCount int `json:"prepaid_upgrade_star_count,omitempty"` // IsUpgradeSeparate Optional. True, if the gift's upgrade was purchased after the gift was sent; for gifts // received on behalf of business accounts only IsUpgradeSeparate bool `json:"is_upgrade_separate,omitempty"` // UniqueGiftNumber Optional. Unique number reserved for this gift when upgraded. See the number field in // UniqueGift. UniqueGiftNumber int `json:"unique_gift_number,omitempty"` // CanBeTransferred Optional. True, if the gift can be transferred to another owner; for gifts received on // behalf of business accounts only // Fields specific to "unique" type CanBeTransferred bool `json:"can_be_transferred,omitempty"` // TransferStarCount Optional. Number of Telegram Stars that must be paid to transfer the gift; omitted if // the bot cannot transfer the gift TransferStarCount int `json:"transfer_star_count,omitempty"` // NextTransferDate Optional. Point in time (Unix timestamp) when the gift can be transferred. If it is in // the past, then the gift can be transferred now. NextTransferDate int `json:"next_transfer_date,omitempty"` } // OwnedGifts represents a list of owned gifts with pagination. // Since: Bot API 9.0 type OwnedGifts struct { // TotalCount The total number of gifts owned by the user or the chat TotalCount int `json:"total_count"` // Gifts The list of gifts Gifts []OwnedGift `json:"gifts"` // NextOffset Optional. Offset for the next request. If empty, then there are no more results. NextOffset string `json:"next_offset"` } // GiveawayCreated represents a service message about a giveaway being created. // Since: Bot API 7.0 type GiveawayCreated struct { // PrizeStarCount Optional. The number of Telegram Stars to be split between giveaway winners; for Telegram // Star giveaways only PrizeStarCount int `json:"prize_star_count,omitempty"` } // Giveaway represents a message about a scheduled giveaway. // Since: Bot API 7.0 type Giveaway struct { // Chats The list of chats which the user must join to participate in the giveaway Chats []Chat `json:"chats"` // WinnersSelectionDate Point in time (Unix timestamp) when winners of the giveaway will be selected WinnersSelectionDate int `json:"winners_selection_date"` // WinnerCount The number of users which are supposed to be selected as winners of the giveaway WinnerCount int `json:"winner_count"` // OnlyNewMembers Optional. True, if only users who join the chats after the giveaway started should be // eligible to win OnlyNewMembers bool `json:"only_new_members,omitempty"` // HasPublicWinners Optional. True, if the list of giveaway winners will be visible to everyone HasPublicWinners bool `json:"has_public_winners,omitempty"` // PrizeDescription Optional. Description of additional giveaway prize PrizeDescription string `json:"prize_description,omitempty"` // CountryCodes Optional. A list of two-letter ISO 3166-1 alpha-2 country codes indicating the countries // from which eligible users for the giveaway must come. If empty, then all users can participate in the // giveaway. Users with a phone number that was bought on Fragment can always participate in giveaways. CountryCodes []string `json:"country_codes,omitempty"` // PrizeStarCount Optional. The number of Telegram Stars to be split between giveaway winners; for Telegram // Star giveaways only PrizeStarCount int `json:"prize_star_count,omitempty"` // PremiumSubscriptionMonthCount Optional. The number of months the Telegram Premium subscription won from // the giveaway will be active for; for Telegram Premium giveaways only PremiumSubscriptionMonthCount int `json:"premium_subscription_month_count,omitempty"` } // GiveawayWinners represents a message about the completion of a giveaway with public winners. // Since: Bot API 7.0 type GiveawayWinners struct { // Chat The chat that created the giveaway Chat Chat `json:"chat"` // GiveawayMessageID Identifier of the message with the giveaway in the chat GiveawayMessageID int `json:"giveaway_message_id"` // WinnersSelectionDate Point in time (Unix timestamp) when winners of the giveaway were selected WinnersSelectionDate int `json:"winners_selection_date"` // WinnerCount Total number of winners in the giveaway WinnerCount int `json:"winner_count"` // Winners List of up to 100 winners of the giveaway Winners []User `json:"winners"` // AdditionalChatCount Optional. The number of other chats the user had to join in order to be eligible for // the giveaway AdditionalChatCount int `json:"additional_chat_count,omitempty"` // PrizeStarCount Optional. The number of Telegram Stars that were split between giveaway winners; for // Telegram Star giveaways only PrizeStarCount int `json:"prize_star_count,omitempty"` // PremiumSubscriptionMonthCount Optional. The number of months the Telegram Premium subscription won from // the giveaway will be active for; for Telegram Premium giveaways only PremiumSubscriptionMonthCount int `json:"premium_subscription_month_count,omitempty"` // UnclaimedPrizeCount Optional. Number of undistributed prizes UnclaimedPrizeCount int `json:"unclaimed_prize_count,omitempty"` // OnlyNewMembers Optional. True, if only users who had joined the chats after the giveaway started were // eligible to win OnlyNewMembers bool `json:"only_new_members,omitempty"` // WasRefunded Optional. True, if the giveaway was canceled because the payment for it was refunded WasRefunded bool `json:"was_refunded,omitempty"` // PrizeDescription Optional. Description of additional giveaway prize PrizeDescription string `json:"prize_description,omitempty"` } // GiveawayCompleted represents a service message about the completion of a giveaway without public winners. // Since: Bot API 7.0 type GiveawayCompleted struct { // WinnerCount Number of winners in the giveaway WinnerCount int `json:"winner_count"` // UnclaimedPrizeCount Optional. Number of undistributed prizes UnclaimedPrizeCount int `json:"unclaimed_prize_count,omitempty"` // GiveawayMessage Optional. Message with the giveaway that was completed, if it wasn't deleted GiveawayMessage *Message `json:"giveaway_message,omitempty"` // IsStarGiveaway Optional. True, if the giveaway is a Telegram Star giveaway. Otherwise, currently, the // giveaway is a Telegram Premium giveaway. IsStarGiveaway bool `json:"is_star_giveaway,omitempty"` } // WriteAccessAllowed represents a service message about a user allowing a bot to write messages. // Since: Bot API 6.4 type WriteAccessAllowed struct { // FromRequest Optional. True, if the access was granted after the user accepted an explicit request from a // Web App sent by the method requestWriteAccess FromRequest bool `json:"from_request,omitempty"` // WebAppName Optional. Name of the Web App, if the access was granted when the Web App was launched from a // link WebAppName string `json:"web_app_name,omitempty"` // FromAttachmentMenu Optional. True, if the access was granted when the bot was added to the attachment or // side menu FromAttachmentMenu bool `json:"from_attachment_menu,omitempty"` } // BackgroundFillType represents the type of a background fill. // Since: Bot API 7.5 type BackgroundFillType string const ( // BackgroundFillSolidType identifies a solid fill. BackgroundFillSolidType BackgroundFillType = "solid" // BackgroundFillGradientType identifies a two-color gradient. BackgroundFillGradientType BackgroundFillType = "gradient" // BackgroundFillFreeformGradientType identifies a freeform gradient. BackgroundFillFreeformGradientType BackgroundFillType = "freeform_gradient" ) // BackgroundFill describes the way a background is filled. // Since: Bot API 7.5 type BackgroundFill struct { // Type identifies the concrete fill variant. Type BackgroundFillType `json:"type"` // Color The color of the background fill in the RGB24 format Color int `json:"color,omitempty"` // TopColor Top color of the gradient in the RGB24 format TopColor int `json:"top_color,omitempty"` // BottomColor Bottom color of the gradient in the RGB24 format BottomColor int `json:"bottom_color,omitempty"` // RotationAngle Clockwise rotation angle of the background fill in degrees; 0-359 RotationAngle int `json:"rotation_angle,omitempty"` // Colors 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,omitempty"` } // BackgroundTypeType represents the type of a chat background. // Since: Bot API 7.5 type BackgroundTypeType string const ( // BackgroundTypeFillType identifies a generated fill. BackgroundTypeFillType BackgroundTypeType = "fill" // BackgroundTypeWallpaperType identifies a wallpaper. BackgroundTypeWallpaperType BackgroundTypeType = "wallpaper" // BackgroundTypePatternType identifies a pattern. BackgroundTypePatternType BackgroundTypeType = "pattern" // BackgroundTypeChatThemeType identifies a chat theme. BackgroundTypeChatThemeType BackgroundTypeType = "chat_theme" ) // BackgroundType describes the type of a background. // Since: Bot API 7.5 type BackgroundType struct { // Type identifies the concrete background variant. Type BackgroundTypeType `json:"type"` // Fill contains the background fill for fill and pattern variants. Fill *BackgroundFill `json:"fill,omitempty"` // DarkThemeDimming Dimming of the background in dark themes, as a percentage; 0-100 DarkThemeDimming int `json:"dark_theme_dimming,omitempty"` // Document contains the wallpaper or pattern document for document-backed variants. Document *Document `json:"document,omitempty"` // IsBlurred Optional. True, if the wallpaper is downscaled to fit in a 450x450 square and then box-blurred // with radius 12 IsBlurred bool `json:"is_blurred,omitempty"` // IsMoving Optional. True, if the background moves slightly when the device is tilted IsMoving bool `json:"is_moving,omitempty"` // Intensity Intensity of the pattern when it is shown above the filled background; 0-100 Intensity int `json:"intensity,omitempty"` // IsInverted Optional. 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. IsInverted bool `json:"is_inverted,omitempty"` // ThemeName Name of the chat theme, which is usually an emoji ThemeName string `json:"theme_name,omitempty"` } // BotSubscriptionState identifies the state of a user's subscription to the bot. // // Since: Bot API 10.2 type BotSubscriptionState string const ( // BotSubscriptionCanceledState indicates that the user canceled the subscription. BotSubscriptionCanceledState BotSubscriptionState = "canceled" // BotSubscriptionActiveState indicates that the user re-enabled the subscription. BotSubscriptionActiveState BotSubscriptionState = "active" // BotSubscriptionFailedState indicates that subscription payment failed. BotSubscriptionFailedState BotSubscriptionState = "failed" ) // BotSubscriptionUpdated describes a change to a user's payment subscription to the bot. // // Since: Bot API 10.2 type BotSubscriptionUpdated struct { // User contains the user associated with the value. User User `json:"user"` // InvoicePayload contains the bot-defined subscription invoice payload. InvoicePayload string `json:"invoice_payload"` // State is the new subscription state. State BotSubscriptionState `json:"state"` }