diff --git a/go.mod b/go.mod index ce871f3..2f1132e 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/YukariExpress/pgb go 1.26 require ( - github.com/go-telegram/bot v1.21.0 + github.com/go-telegram/bot v1.22.0 github.com/sethvargo/go-envconfig v1.3.0 github.com/stretchr/testify v1.11.1 ) diff --git a/go.sum b/go.sum index e1343c6..e2ad12c 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,7 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/go-telegram/bot v1.21.0 h1:Va/PbGc2vBDdv57GCUEEVV6ROlHWiC6SklJY9Hvhzps= -github.com/go-telegram/bot v1.21.0/go.mod h1:i2TRs7fXWIeaceF3z7KzsMt/he0TwkVC680mvdTFYeM= +github.com/go-telegram/bot v1.22.0 h1:zK29OoTYMmR5emJrCtGa2SjaGleeZiUB/C1i7kc2lXE= +github.com/go-telegram/bot v1.22.0/go.mod h1:i2TRs7fXWIeaceF3z7KzsMt/he0TwkVC680mvdTFYeM= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= diff --git a/vendor/github.com/go-telegram/bot/CHANGELOG.md b/vendor/github.com/go-telegram/bot/CHANGELOG.md index dcd50ed..7713e1d 100644 --- a/vendor/github.com/go-telegram/bot/CHANGELOG.md +++ b/vendor/github.com/go-telegram/bot/CHANGELOG.md @@ -1,5 +1,17 @@ # Changelog +## v1.22.0 (2026-06-30) + +- Support Bot API 10.1 (June 11, 2026 update) — Rich Messages: + - Methods: `sendRichMessage`, `sendRichMessageDraft`, and a `rich_message` + parameter on `editMessageText`. + - Send types: `InputRichMessage` (carries `` for reasoning), + `InputRichMessageContent`. + - Receive types: `RichMessage` (+ `rich_message` field on `Message`), the + `RichBlock` union (21 blocks incl. `RichBlockThinking`) and the polymorphic + `RichText` union (string | array | 25 tagged variants), plus `RichBlockCaption`, + `RichBlockListItem`, `RichBlockTableCell`. + ## v1.21.0 (2026-05-22) - Support Bot API 9.6 & 10.0, multipart fixes — closes #279 #280, fixes #273 #274 #271 #277 (#281) diff --git a/vendor/github.com/go-telegram/bot/README.md b/vendor/github.com/go-telegram/bot/README.md index 18c6f34..f17005e 100644 --- a/vendor/github.com/go-telegram/bot/README.md +++ b/vendor/github.com/go-telegram/bot/README.md @@ -6,7 +6,7 @@ > [Telegram Group](https://t.me/gotelegrambotui) -> Supports Bot API version: [10.0](https://core.telegram.org/bots/api#may-8-2026) from May 8, 2026 +> Supports Bot API version: [10.1](https://core.telegram.org/bots/api#june-11-2026) from June 11, 2026 It's a Go zero-dependencies telegram bot framework diff --git a/vendor/github.com/go-telegram/bot/methods.go b/vendor/github.com/go-telegram/bot/methods.go index 352d95a..4f6d8d7 100644 --- a/vendor/github.com/go-telegram/bot/methods.go +++ b/vendor/github.com/go-telegram/bot/methods.go @@ -1114,6 +1114,20 @@ func (b *Bot) SendMessageDraft(ctx context.Context, params *SendMessageDraftPara return result, err } +// SendRichMessage https://core.telegram.org/bots/api#sendrichmessage +func (b *Bot) SendRichMessage(ctx context.Context, params *SendRichMessageParams) (*models.Message, error) { + result := &models.Message{} + err := b.rawRequest(ctx, "sendRichMessage", params, result) + return result, err +} + +// SendRichMessageDraft https://core.telegram.org/bots/api#sendrichmessagedraft +func (b *Bot) SendRichMessageDraft(ctx context.Context, params *SendRichMessageDraftParams) (bool, error) { + var result bool + err := b.rawRequest(ctx, "sendRichMessageDraft", params, &result) + return result, err +} + // RepostStory https://core.telegram.org/bots/api#repoststory func (b *Bot) RepostStory(ctx context.Context, params *RepostStoryParams) (*models.Story, error) { result := &models.Story{} diff --git a/vendor/github.com/go-telegram/bot/methods_params.go b/vendor/github.com/go-telegram/bot/methods_params.go index f3d3098..a0b77dc 100644 --- a/vendor/github.com/go-telegram/bot/methods_params.go +++ b/vendor/github.com/go-telegram/bot/methods_params.go @@ -799,6 +799,7 @@ type EditMessageTextParams struct { ParseMode models.ParseMode `json:"parse_mode,omitempty"` Entities []models.MessageEntity `json:"entities,omitempty"` LinkPreviewOptions *models.LinkPreviewOptions `json:"link_preview_options,omitempty"` + RichMessage *models.InputRichMessage `json:"rich_message,omitempty"` ReplyMarkup models.ReplyMarkup `json:"reply_markup,omitempty"` } @@ -1320,6 +1321,30 @@ type SendMessageDraftParams struct { Entities []models.MessageEntity `json:"entities,omitempty"` } +// SendRichMessageParams https://core.telegram.org/bots/api#sendrichmessage +type SendRichMessageParams struct { + BusinessConnectionID string `json:"business_connection_id,omitempty"` + ChatID any `json:"chat_id"` + MessageThreadID int `json:"message_thread_id,omitempty"` + DirectMessagesTopicID int `json:"direct_messages_topic_id,omitempty"` + RichMessage models.InputRichMessage `json:"rich_message"` + DisableNotification bool `json:"disable_notification,omitempty"` + ProtectContent bool `json:"protect_content,omitempty"` + AllowPaidBroadcast bool `json:"allow_paid_broadcast,omitempty"` + MessageEffectID string `json:"message_effect_id,omitempty"` + SuggestedPostParameters *models.SuggestedPostParameters `json:"suggested_post_parameters,omitempty"` + ReplyParameters *models.ReplyParameters `json:"reply_parameters,omitempty"` + ReplyMarkup models.ReplyMarkup `json:"reply_markup,omitempty"` +} + +// SendRichMessageDraftParams https://core.telegram.org/bots/api#sendrichmessagedraft +type SendRichMessageDraftParams struct { + ChatID any `json:"chat_id"` + MessageThreadID int `json:"message_thread_id,omitempty"` + DraftID int `json:"draft_id"` + RichMessage models.InputRichMessage `json:"rich_message"` +} + // RepostStoryParams https://core.telegram.org/bots/api#repoststory type RepostStoryParams struct { BusinessConnectionID string `json:"business_connection_id"` diff --git a/vendor/github.com/go-telegram/bot/models/message.go b/vendor/github.com/go-telegram/bot/models/message.go index e7e172c..8632c69 100644 --- a/vendor/github.com/go-telegram/bot/models/message.go +++ b/vendor/github.com/go-telegram/bot/models/message.go @@ -109,6 +109,7 @@ type Message struct { PaidStarCount int `json:"paid_star_count,omitempty"` Text string `json:"text,omitempty"` Entities []MessageEntity `json:"entities,omitempty"` + RichMessage *RichMessage `json:"rich_message,omitempty"` LinkPreviewOptions *LinkPreviewOptions `json:"link_preview_options,omitempty"` SuggestedPostInfo *SuggestedPostInfo `json:"suggested_post_info,omitempty"` EffectID string `json:"effect_id,omitempty"` diff --git a/vendor/github.com/go-telegram/bot/models/rich_block.go b/vendor/github.com/go-telegram/bot/models/rich_block.go new file mode 100644 index 0000000..fed7ea1 --- /dev/null +++ b/vendor/github.com/go-telegram/bot/models/rich_block.go @@ -0,0 +1,384 @@ +package models + +import ( + "encoding/json" + "fmt" +) + +// RichBlockType https://core.telegram.org/bots/api#richblock +type RichBlockType string + +const ( + RichBlockTypeParagraph RichBlockType = "paragraph" + RichBlockTypeSectionHeading RichBlockType = "heading" + RichBlockTypePreformatted RichBlockType = "pre" + RichBlockTypeFooter RichBlockType = "footer" + RichBlockTypeDivider RichBlockType = "divider" + RichBlockTypeMathematicalExpression RichBlockType = "mathematical_expression" + RichBlockTypeAnchor RichBlockType = "anchor" + RichBlockTypeList RichBlockType = "list" + RichBlockTypeBlockQuotation RichBlockType = "blockquote" + RichBlockTypePullQuotation RichBlockType = "pullquote" + RichBlockTypeCollage RichBlockType = "collage" + RichBlockTypeSlideshow RichBlockType = "slideshow" + RichBlockTypeTable RichBlockType = "table" + RichBlockTypeDetails RichBlockType = "details" + RichBlockTypeMap RichBlockType = "map" + RichBlockTypeAnimation RichBlockType = "animation" + RichBlockTypeAudio RichBlockType = "audio" + RichBlockTypePhoto RichBlockType = "photo" + RichBlockTypeVideo RichBlockType = "video" + RichBlockTypeVoiceNote RichBlockType = "voice_note" + RichBlockTypeThinking RichBlockType = "thinking" +) + +// RichBlock https://core.telegram.org/bots/api#richblock +// +// RichBlock is a tagged union; Type holds the discriminator and the matching +// variant pointer is populated. +type RichBlock struct { + Type RichBlockType + + RichBlockParagraph *RichBlockParagraph + RichBlockSectionHeading *RichBlockSectionHeading + RichBlockPreformatted *RichBlockPreformatted + RichBlockFooter *RichBlockFooter + RichBlockDivider *RichBlockDivider + RichBlockMathematicalExpression *RichBlockMathematicalExpression + RichBlockAnchor *RichBlockAnchor + RichBlockList *RichBlockList + RichBlockBlockQuotation *RichBlockBlockQuotation + RichBlockPullQuotation *RichBlockPullQuotation + RichBlockCollage *RichBlockCollage + RichBlockSlideshow *RichBlockSlideshow + RichBlockTable *RichBlockTable + RichBlockDetails *RichBlockDetails + RichBlockMap *RichBlockMap + RichBlockAnimation *RichBlockAnimation + RichBlockAudio *RichBlockAudio + RichBlockPhoto *RichBlockPhoto + RichBlockVideo *RichBlockVideo + RichBlockVoiceNote *RichBlockVoiceNote + RichBlockThinking *RichBlockThinking +} + +// MarshalJSON implements json.Marshaler. The value receiver ensures the encoding +// is applied even when a RichBlock is reached as a (non-pointer) struct field. +func (rb RichBlock) MarshalJSON() ([]byte, error) { + switch rb.Type { + case RichBlockTypeParagraph: + rb.RichBlockParagraph.Type = RichBlockTypeParagraph + return json.Marshal(rb.RichBlockParagraph) + case RichBlockTypeSectionHeading: + rb.RichBlockSectionHeading.Type = RichBlockTypeSectionHeading + return json.Marshal(rb.RichBlockSectionHeading) + case RichBlockTypePreformatted: + rb.RichBlockPreformatted.Type = RichBlockTypePreformatted + return json.Marshal(rb.RichBlockPreformatted) + case RichBlockTypeFooter: + rb.RichBlockFooter.Type = RichBlockTypeFooter + return json.Marshal(rb.RichBlockFooter) + case RichBlockTypeDivider: + rb.RichBlockDivider.Type = RichBlockTypeDivider + return json.Marshal(rb.RichBlockDivider) + case RichBlockTypeMathematicalExpression: + rb.RichBlockMathematicalExpression.Type = RichBlockTypeMathematicalExpression + return json.Marshal(rb.RichBlockMathematicalExpression) + case RichBlockTypeAnchor: + rb.RichBlockAnchor.Type = RichBlockTypeAnchor + return json.Marshal(rb.RichBlockAnchor) + case RichBlockTypeList: + rb.RichBlockList.Type = RichBlockTypeList + return json.Marshal(rb.RichBlockList) + case RichBlockTypeBlockQuotation: + rb.RichBlockBlockQuotation.Type = RichBlockTypeBlockQuotation + return json.Marshal(rb.RichBlockBlockQuotation) + case RichBlockTypePullQuotation: + rb.RichBlockPullQuotation.Type = RichBlockTypePullQuotation + return json.Marshal(rb.RichBlockPullQuotation) + case RichBlockTypeCollage: + rb.RichBlockCollage.Type = RichBlockTypeCollage + return json.Marshal(rb.RichBlockCollage) + case RichBlockTypeSlideshow: + rb.RichBlockSlideshow.Type = RichBlockTypeSlideshow + return json.Marshal(rb.RichBlockSlideshow) + case RichBlockTypeTable: + rb.RichBlockTable.Type = RichBlockTypeTable + return json.Marshal(rb.RichBlockTable) + case RichBlockTypeDetails: + rb.RichBlockDetails.Type = RichBlockTypeDetails + return json.Marshal(rb.RichBlockDetails) + case RichBlockTypeMap: + rb.RichBlockMap.Type = RichBlockTypeMap + return json.Marshal(rb.RichBlockMap) + case RichBlockTypeAnimation: + rb.RichBlockAnimation.Type = RichBlockTypeAnimation + return json.Marshal(rb.RichBlockAnimation) + case RichBlockTypeAudio: + rb.RichBlockAudio.Type = RichBlockTypeAudio + return json.Marshal(rb.RichBlockAudio) + case RichBlockTypePhoto: + rb.RichBlockPhoto.Type = RichBlockTypePhoto + return json.Marshal(rb.RichBlockPhoto) + case RichBlockTypeVideo: + rb.RichBlockVideo.Type = RichBlockTypeVideo + return json.Marshal(rb.RichBlockVideo) + case RichBlockTypeVoiceNote: + rb.RichBlockVoiceNote.Type = RichBlockTypeVoiceNote + return json.Marshal(rb.RichBlockVoiceNote) + case RichBlockTypeThinking: + rb.RichBlockThinking.Type = RichBlockTypeThinking + return json.Marshal(rb.RichBlockThinking) + } + + return nil, fmt.Errorf("unsupported RichBlock type %q", rb.Type) +} + +func (rb *RichBlock) UnmarshalJSON(data []byte) error { + v := struct { + Type RichBlockType `json:"type"` + }{} + if err := json.Unmarshal(data, &v); err != nil { + return err + } + + switch v.Type { + case RichBlockTypeParagraph: + rb.Type = RichBlockTypeParagraph + rb.RichBlockParagraph = &RichBlockParagraph{} + return json.Unmarshal(data, rb.RichBlockParagraph) + case RichBlockTypeSectionHeading: + rb.Type = RichBlockTypeSectionHeading + rb.RichBlockSectionHeading = &RichBlockSectionHeading{} + return json.Unmarshal(data, rb.RichBlockSectionHeading) + case RichBlockTypePreformatted: + rb.Type = RichBlockTypePreformatted + rb.RichBlockPreformatted = &RichBlockPreformatted{} + return json.Unmarshal(data, rb.RichBlockPreformatted) + case RichBlockTypeFooter: + rb.Type = RichBlockTypeFooter + rb.RichBlockFooter = &RichBlockFooter{} + return json.Unmarshal(data, rb.RichBlockFooter) + case RichBlockTypeDivider: + rb.Type = RichBlockTypeDivider + rb.RichBlockDivider = &RichBlockDivider{} + return json.Unmarshal(data, rb.RichBlockDivider) + case RichBlockTypeMathematicalExpression: + rb.Type = RichBlockTypeMathematicalExpression + rb.RichBlockMathematicalExpression = &RichBlockMathematicalExpression{} + return json.Unmarshal(data, rb.RichBlockMathematicalExpression) + case RichBlockTypeAnchor: + rb.Type = RichBlockTypeAnchor + rb.RichBlockAnchor = &RichBlockAnchor{} + return json.Unmarshal(data, rb.RichBlockAnchor) + case RichBlockTypeList: + rb.Type = RichBlockTypeList + rb.RichBlockList = &RichBlockList{} + return json.Unmarshal(data, rb.RichBlockList) + case RichBlockTypeBlockQuotation: + rb.Type = RichBlockTypeBlockQuotation + rb.RichBlockBlockQuotation = &RichBlockBlockQuotation{} + return json.Unmarshal(data, rb.RichBlockBlockQuotation) + case RichBlockTypePullQuotation: + rb.Type = RichBlockTypePullQuotation + rb.RichBlockPullQuotation = &RichBlockPullQuotation{} + return json.Unmarshal(data, rb.RichBlockPullQuotation) + case RichBlockTypeCollage: + rb.Type = RichBlockTypeCollage + rb.RichBlockCollage = &RichBlockCollage{} + return json.Unmarshal(data, rb.RichBlockCollage) + case RichBlockTypeSlideshow: + rb.Type = RichBlockTypeSlideshow + rb.RichBlockSlideshow = &RichBlockSlideshow{} + return json.Unmarshal(data, rb.RichBlockSlideshow) + case RichBlockTypeTable: + rb.Type = RichBlockTypeTable + rb.RichBlockTable = &RichBlockTable{} + return json.Unmarshal(data, rb.RichBlockTable) + case RichBlockTypeDetails: + rb.Type = RichBlockTypeDetails + rb.RichBlockDetails = &RichBlockDetails{} + return json.Unmarshal(data, rb.RichBlockDetails) + case RichBlockTypeMap: + rb.Type = RichBlockTypeMap + rb.RichBlockMap = &RichBlockMap{} + return json.Unmarshal(data, rb.RichBlockMap) + case RichBlockTypeAnimation: + rb.Type = RichBlockTypeAnimation + rb.RichBlockAnimation = &RichBlockAnimation{} + return json.Unmarshal(data, rb.RichBlockAnimation) + case RichBlockTypeAudio: + rb.Type = RichBlockTypeAudio + rb.RichBlockAudio = &RichBlockAudio{} + return json.Unmarshal(data, rb.RichBlockAudio) + case RichBlockTypePhoto: + rb.Type = RichBlockTypePhoto + rb.RichBlockPhoto = &RichBlockPhoto{} + return json.Unmarshal(data, rb.RichBlockPhoto) + case RichBlockTypeVideo: + rb.Type = RichBlockTypeVideo + rb.RichBlockVideo = &RichBlockVideo{} + return json.Unmarshal(data, rb.RichBlockVideo) + case RichBlockTypeVoiceNote: + rb.Type = RichBlockTypeVoiceNote + rb.RichBlockVoiceNote = &RichBlockVoiceNote{} + return json.Unmarshal(data, rb.RichBlockVoiceNote) + case RichBlockTypeThinking: + rb.Type = RichBlockTypeThinking + rb.RichBlockThinking = &RichBlockThinking{} + return json.Unmarshal(data, rb.RichBlockThinking) + } + + return fmt.Errorf("unsupported RichBlock type %q", v.Type) +} + +// RichBlockParagraph https://core.telegram.org/bots/api#richblockparagraph +type RichBlockParagraph struct { + Type RichBlockType `json:"type"` + Text RichText `json:"text"` +} + +// RichBlockSectionHeading https://core.telegram.org/bots/api#richblocksectionheading +type RichBlockSectionHeading struct { + Type RichBlockType `json:"type"` + Text RichText `json:"text"` + Size int `json:"size"` +} + +// RichBlockPreformatted https://core.telegram.org/bots/api#richblockpreformatted +type RichBlockPreformatted struct { + Type RichBlockType `json:"type"` + Text RichText `json:"text"` + Language string `json:"language,omitempty"` +} + +// RichBlockFooter https://core.telegram.org/bots/api#richblockfooter +type RichBlockFooter struct { + Type RichBlockType `json:"type"` + Text RichText `json:"text"` +} + +// RichBlockDivider https://core.telegram.org/bots/api#richblockdivider +type RichBlockDivider struct { + Type RichBlockType `json:"type"` +} + +// RichBlockMathematicalExpression https://core.telegram.org/bots/api#richblockmathematicalexpression +type RichBlockMathematicalExpression struct { + Type RichBlockType `json:"type"` + Expression string `json:"expression"` +} + +// RichBlockAnchor https://core.telegram.org/bots/api#richblockanchor +type RichBlockAnchor struct { + Type RichBlockType `json:"type"` + Name string `json:"name"` +} + +// RichBlockList https://core.telegram.org/bots/api#richblocklist +type RichBlockList struct { + Type RichBlockType `json:"type"` + Items []RichBlockListItem `json:"items"` +} + +// RichBlockBlockQuotation https://core.telegram.org/bots/api#richblockblockquotation +type RichBlockBlockQuotation struct { + Type RichBlockType `json:"type"` + Blocks []RichBlock `json:"blocks"` + Credit *RichText `json:"credit,omitempty"` +} + +// RichBlockPullQuotation https://core.telegram.org/bots/api#richblockpullquotation +type RichBlockPullQuotation struct { + Type RichBlockType `json:"type"` + Text RichText `json:"text"` + Credit *RichText `json:"credit,omitempty"` +} + +// RichBlockCollage https://core.telegram.org/bots/api#richblockcollage +type RichBlockCollage struct { + Type RichBlockType `json:"type"` + Blocks []RichBlock `json:"blocks"` + Caption *RichBlockCaption `json:"caption,omitempty"` +} + +// RichBlockSlideshow https://core.telegram.org/bots/api#richblockslideshow +type RichBlockSlideshow struct { + Type RichBlockType `json:"type"` + Blocks []RichBlock `json:"blocks"` + Caption *RichBlockCaption `json:"caption,omitempty"` +} + +// RichBlockTable https://core.telegram.org/bots/api#richblocktable +type RichBlockTable struct { + Type RichBlockType `json:"type"` + Cells [][]RichBlockTableCell `json:"cells"` + IsBordered bool `json:"is_bordered,omitempty"` + IsStriped bool `json:"is_striped,omitempty"` + Caption *RichText `json:"caption,omitempty"` +} + +// RichBlockDetails https://core.telegram.org/bots/api#richblockdetails +type RichBlockDetails struct { + Type RichBlockType `json:"type"` + Summary RichText `json:"summary"` + Blocks []RichBlock `json:"blocks"` + IsOpen bool `json:"is_open,omitempty"` +} + +// RichBlockMap https://core.telegram.org/bots/api#richblockmap +type RichBlockMap struct { + Type RichBlockType `json:"type"` + Location Location `json:"location"` + Zoom int `json:"zoom"` + Width int `json:"width"` + Height int `json:"height"` + Caption *RichBlockCaption `json:"caption,omitempty"` +} + +// RichBlockAnimation https://core.telegram.org/bots/api#richblockanimation +type RichBlockAnimation struct { + Type RichBlockType `json:"type"` + Animation Animation `json:"animation"` + HasSpoiler bool `json:"has_spoiler,omitempty"` + Caption *RichBlockCaption `json:"caption,omitempty"` +} + +// RichBlockAudio https://core.telegram.org/bots/api#richblockaudio +type RichBlockAudio struct { + Type RichBlockType `json:"type"` + Audio Audio `json:"audio"` + Caption *RichBlockCaption `json:"caption,omitempty"` +} + +// RichBlockPhoto https://core.telegram.org/bots/api#richblockphoto +type RichBlockPhoto struct { + Type RichBlockType `json:"type"` + Photo []PhotoSize `json:"photo"` + HasSpoiler bool `json:"has_spoiler,omitempty"` + Caption *RichBlockCaption `json:"caption,omitempty"` +} + +// RichBlockVideo https://core.telegram.org/bots/api#richblockvideo +type RichBlockVideo struct { + Type RichBlockType `json:"type"` + Video Video `json:"video"` + HasSpoiler bool `json:"has_spoiler,omitempty"` + Caption *RichBlockCaption `json:"caption,omitempty"` +} + +// RichBlockVoiceNote https://core.telegram.org/bots/api#richblockvoicenote +type RichBlockVoiceNote struct { + Type RichBlockType `json:"type"` + VoiceNote Voice `json:"voice_note"` + Caption *RichBlockCaption `json:"caption,omitempty"` +} + +// RichBlockThinking https://core.telegram.org/bots/api#richblockthinking +// +// A block with a "Thinking..." placeholder, corresponding to the custom HTML tag +// . +type RichBlockThinking struct { + Type RichBlockType `json:"type"` + Text RichText `json:"text"` +} diff --git a/vendor/github.com/go-telegram/bot/models/rich_message.go b/vendor/github.com/go-telegram/bot/models/rich_message.go new file mode 100644 index 0000000..4dabdc9 --- /dev/null +++ b/vendor/github.com/go-telegram/bot/models/rich_message.go @@ -0,0 +1,60 @@ +package models + +// RichMessage https://core.telegram.org/bots/api#richmessage +// +// Describes a rich formatted message. +type RichMessage struct { + Blocks []RichBlock `json:"blocks"` + IsRTL bool `json:"is_rtl,omitempty"` +} + +// InputRichMessage https://core.telegram.org/bots/api#inputrichmessage +// +// Describes a rich formatted message to be sent. The thinking block is expressed +// by the custom HTML tag within HTML. +type InputRichMessage struct { + HTML string `json:"html,omitempty"` + Markdown string `json:"markdown,omitempty"` + IsRTL bool `json:"is_rtl,omitempty"` + SkipEntityDetection bool `json:"skip_entity_detection,omitempty"` +} + +// InputRichMessageContent https://core.telegram.org/bots/api#inputrichmessagecontent +// +// Represents the content of a rich message to be sent as the result of an inline +// query. +type InputRichMessageContent struct { + RichMessage InputRichMessage `json:"rich_message"` +} + +// RichBlockCaption https://core.telegram.org/bots/api#richblockcaption +// +// Caption of a rich formatted block. +type RichBlockCaption struct { + Text RichText `json:"text"` + Credit *RichText `json:"credit,omitempty"` +} + +// RichBlockListItem https://core.telegram.org/bots/api#richblocklistitem +// +// An item of a list. +type RichBlockListItem struct { + Label string `json:"label"` + Blocks []RichBlock `json:"blocks"` + HasCheckbox bool `json:"has_checkbox,omitempty"` + IsChecked bool `json:"is_checked,omitempty"` + Value int `json:"value,omitempty"` + Type string `json:"type,omitempty"` +} + +// RichBlockTableCell https://core.telegram.org/bots/api#richblocktablecell +// +// Cell in a table. +type RichBlockTableCell struct { + Text *RichText `json:"text,omitempty"` + IsHeader bool `json:"is_header,omitempty"` + Colspan int `json:"colspan,omitempty"` + Rowspan int `json:"rowspan,omitempty"` + Align string `json:"align"` + Valign string `json:"valign"` +} diff --git a/vendor/github.com/go-telegram/bot/models/rich_text.go b/vendor/github.com/go-telegram/bot/models/rich_text.go new file mode 100644 index 0000000..c02e751 --- /dev/null +++ b/vendor/github.com/go-telegram/bot/models/rich_text.go @@ -0,0 +1,464 @@ +package models + +import ( + "bytes" + "encoding/json" + "fmt" +) + +// RichTextType https://core.telegram.org/bots/api#richtext +type RichTextType string + +const ( + RichTextTypeBold RichTextType = "bold" + RichTextTypeItalic RichTextType = "italic" + RichTextTypeUnderline RichTextType = "underline" + RichTextTypeStrikethrough RichTextType = "strikethrough" + RichTextTypeSpoiler RichTextType = "spoiler" + RichTextTypeDateTime RichTextType = "date_time" + RichTextTypeTextMention RichTextType = "text_mention" + RichTextTypeSubscript RichTextType = "subscript" + RichTextTypeSuperscript RichTextType = "superscript" + RichTextTypeMarked RichTextType = "marked" + RichTextTypeCode RichTextType = "code" + RichTextTypeCustomEmoji RichTextType = "custom_emoji" + RichTextTypeMathematicalExpression RichTextType = "mathematical_expression" + RichTextTypeURL RichTextType = "url" + RichTextTypeEmailAddress RichTextType = "email_address" + RichTextTypePhoneNumber RichTextType = "phone_number" + RichTextTypeBankCardNumber RichTextType = "bank_card_number" + RichTextTypeMention RichTextType = "mention" + RichTextTypeHashtag RichTextType = "hashtag" + RichTextTypeCashtag RichTextType = "cashtag" + RichTextTypeBotCommand RichTextType = "bot_command" + RichTextTypeAnchor RichTextType = "anchor" + RichTextTypeAnchorLink RichTextType = "anchor_link" + RichTextTypeReference RichTextType = "reference" + RichTextTypeReferenceLink RichTextType = "reference_link" +) + +// RichText https://core.telegram.org/bots/api#richtext +// +// RichText is polymorphic: a rich text value is encoded by Telegram as a bare +// JSON string, a JSON array of RichText (a sequence), or a tagged object with a +// "type" discriminator. The form is recorded in Type: it is the empty string for +// the plain-string and array forms, set in PlainText and Array respectively, and +// otherwise holds the discriminator with the matching variant pointer populated. +type RichText struct { + Type RichTextType + PlainText string + Array []RichText + + RichTextBold *RichTextBold + RichTextItalic *RichTextItalic + RichTextUnderline *RichTextUnderline + RichTextStrikethrough *RichTextStrikethrough + RichTextSpoiler *RichTextSpoiler + RichTextDateTime *RichTextDateTime + RichTextTextMention *RichTextTextMention + RichTextSubscript *RichTextSubscript + RichTextSuperscript *RichTextSuperscript + RichTextMarked *RichTextMarked + RichTextCode *RichTextCode + RichTextCustomEmoji *RichTextCustomEmoji + RichTextMathematicalExpression *RichTextMathematicalExpression + RichTextURL *RichTextURL + RichTextEmailAddress *RichTextEmailAddress + RichTextPhoneNumber *RichTextPhoneNumber + RichTextBankCardNumber *RichTextBankCardNumber + RichTextMention *RichTextMention + RichTextHashtag *RichTextHashtag + RichTextCashtag *RichTextCashtag + RichTextBotCommand *RichTextBotCommand + RichTextAnchor *RichTextAnchor + RichTextAnchorLink *RichTextAnchorLink + RichTextReference *RichTextReference + RichTextReferenceLink *RichTextReferenceLink +} + +// MarshalJSON implements json.Marshaler. The value receiver ensures the encoding +// is applied even when a RichText is reached as a (non-pointer) struct field. +func (rt RichText) MarshalJSON() ([]byte, error) { + if rt.Array != nil { + return json.Marshal(rt.Array) + } + + switch rt.Type { + case "": + return json.Marshal(rt.PlainText) + case RichTextTypeBold: + rt.RichTextBold.Type = RichTextTypeBold + return json.Marshal(rt.RichTextBold) + case RichTextTypeItalic: + rt.RichTextItalic.Type = RichTextTypeItalic + return json.Marshal(rt.RichTextItalic) + case RichTextTypeUnderline: + rt.RichTextUnderline.Type = RichTextTypeUnderline + return json.Marshal(rt.RichTextUnderline) + case RichTextTypeStrikethrough: + rt.RichTextStrikethrough.Type = RichTextTypeStrikethrough + return json.Marshal(rt.RichTextStrikethrough) + case RichTextTypeSpoiler: + rt.RichTextSpoiler.Type = RichTextTypeSpoiler + return json.Marshal(rt.RichTextSpoiler) + case RichTextTypeDateTime: + rt.RichTextDateTime.Type = RichTextTypeDateTime + return json.Marshal(rt.RichTextDateTime) + case RichTextTypeTextMention: + rt.RichTextTextMention.Type = RichTextTypeTextMention + return json.Marshal(rt.RichTextTextMention) + case RichTextTypeSubscript: + rt.RichTextSubscript.Type = RichTextTypeSubscript + return json.Marshal(rt.RichTextSubscript) + case RichTextTypeSuperscript: + rt.RichTextSuperscript.Type = RichTextTypeSuperscript + return json.Marshal(rt.RichTextSuperscript) + case RichTextTypeMarked: + rt.RichTextMarked.Type = RichTextTypeMarked + return json.Marshal(rt.RichTextMarked) + case RichTextTypeCode: + rt.RichTextCode.Type = RichTextTypeCode + return json.Marshal(rt.RichTextCode) + case RichTextTypeCustomEmoji: + rt.RichTextCustomEmoji.Type = RichTextTypeCustomEmoji + return json.Marshal(rt.RichTextCustomEmoji) + case RichTextTypeMathematicalExpression: + rt.RichTextMathematicalExpression.Type = RichTextTypeMathematicalExpression + return json.Marshal(rt.RichTextMathematicalExpression) + case RichTextTypeURL: + rt.RichTextURL.Type = RichTextTypeURL + return json.Marshal(rt.RichTextURL) + case RichTextTypeEmailAddress: + rt.RichTextEmailAddress.Type = RichTextTypeEmailAddress + return json.Marshal(rt.RichTextEmailAddress) + case RichTextTypePhoneNumber: + rt.RichTextPhoneNumber.Type = RichTextTypePhoneNumber + return json.Marshal(rt.RichTextPhoneNumber) + case RichTextTypeBankCardNumber: + rt.RichTextBankCardNumber.Type = RichTextTypeBankCardNumber + return json.Marshal(rt.RichTextBankCardNumber) + case RichTextTypeMention: + rt.RichTextMention.Type = RichTextTypeMention + return json.Marshal(rt.RichTextMention) + case RichTextTypeHashtag: + rt.RichTextHashtag.Type = RichTextTypeHashtag + return json.Marshal(rt.RichTextHashtag) + case RichTextTypeCashtag: + rt.RichTextCashtag.Type = RichTextTypeCashtag + return json.Marshal(rt.RichTextCashtag) + case RichTextTypeBotCommand: + rt.RichTextBotCommand.Type = RichTextTypeBotCommand + return json.Marshal(rt.RichTextBotCommand) + case RichTextTypeAnchor: + rt.RichTextAnchor.Type = RichTextTypeAnchor + return json.Marshal(rt.RichTextAnchor) + case RichTextTypeAnchorLink: + rt.RichTextAnchorLink.Type = RichTextTypeAnchorLink + return json.Marshal(rt.RichTextAnchorLink) + case RichTextTypeReference: + rt.RichTextReference.Type = RichTextTypeReference + return json.Marshal(rt.RichTextReference) + case RichTextTypeReferenceLink: + rt.RichTextReferenceLink.Type = RichTextTypeReferenceLink + return json.Marshal(rt.RichTextReferenceLink) + } + + return nil, fmt.Errorf("unsupported RichText type %q", rt.Type) +} + +func (rt *RichText) UnmarshalJSON(data []byte) error { + trimmed := bytes.TrimSpace(data) + if len(trimmed) == 0 || bytes.Equal(trimmed, []byte("null")) { + return nil + } + + switch trimmed[0] { + case '"': + rt.Type = "" + return json.Unmarshal(trimmed, &rt.PlainText) + case '[': + rt.Type = "" + return json.Unmarshal(trimmed, &rt.Array) + case '{': + // fall through to the tagged-object dispatch below + default: + return fmt.Errorf("unexpected RichText JSON: %s", trimmed) + } + + v := struct { + Type RichTextType `json:"type"` + }{} + if err := json.Unmarshal(trimmed, &v); err != nil { + return err + } + + switch v.Type { + case RichTextTypeBold: + rt.Type = RichTextTypeBold + rt.RichTextBold = &RichTextBold{} + return json.Unmarshal(trimmed, rt.RichTextBold) + case RichTextTypeItalic: + rt.Type = RichTextTypeItalic + rt.RichTextItalic = &RichTextItalic{} + return json.Unmarshal(trimmed, rt.RichTextItalic) + case RichTextTypeUnderline: + rt.Type = RichTextTypeUnderline + rt.RichTextUnderline = &RichTextUnderline{} + return json.Unmarshal(trimmed, rt.RichTextUnderline) + case RichTextTypeStrikethrough: + rt.Type = RichTextTypeStrikethrough + rt.RichTextStrikethrough = &RichTextStrikethrough{} + return json.Unmarshal(trimmed, rt.RichTextStrikethrough) + case RichTextTypeSpoiler: + rt.Type = RichTextTypeSpoiler + rt.RichTextSpoiler = &RichTextSpoiler{} + return json.Unmarshal(trimmed, rt.RichTextSpoiler) + case RichTextTypeDateTime: + rt.Type = RichTextTypeDateTime + rt.RichTextDateTime = &RichTextDateTime{} + return json.Unmarshal(trimmed, rt.RichTextDateTime) + case RichTextTypeTextMention: + rt.Type = RichTextTypeTextMention + rt.RichTextTextMention = &RichTextTextMention{} + return json.Unmarshal(trimmed, rt.RichTextTextMention) + case RichTextTypeSubscript: + rt.Type = RichTextTypeSubscript + rt.RichTextSubscript = &RichTextSubscript{} + return json.Unmarshal(trimmed, rt.RichTextSubscript) + case RichTextTypeSuperscript: + rt.Type = RichTextTypeSuperscript + rt.RichTextSuperscript = &RichTextSuperscript{} + return json.Unmarshal(trimmed, rt.RichTextSuperscript) + case RichTextTypeMarked: + rt.Type = RichTextTypeMarked + rt.RichTextMarked = &RichTextMarked{} + return json.Unmarshal(trimmed, rt.RichTextMarked) + case RichTextTypeCode: + rt.Type = RichTextTypeCode + rt.RichTextCode = &RichTextCode{} + return json.Unmarshal(trimmed, rt.RichTextCode) + case RichTextTypeCustomEmoji: + rt.Type = RichTextTypeCustomEmoji + rt.RichTextCustomEmoji = &RichTextCustomEmoji{} + return json.Unmarshal(trimmed, rt.RichTextCustomEmoji) + case RichTextTypeMathematicalExpression: + rt.Type = RichTextTypeMathematicalExpression + rt.RichTextMathematicalExpression = &RichTextMathematicalExpression{} + return json.Unmarshal(trimmed, rt.RichTextMathematicalExpression) + case RichTextTypeURL: + rt.Type = RichTextTypeURL + rt.RichTextURL = &RichTextURL{} + return json.Unmarshal(trimmed, rt.RichTextURL) + case RichTextTypeEmailAddress: + rt.Type = RichTextTypeEmailAddress + rt.RichTextEmailAddress = &RichTextEmailAddress{} + return json.Unmarshal(trimmed, rt.RichTextEmailAddress) + case RichTextTypePhoneNumber: + rt.Type = RichTextTypePhoneNumber + rt.RichTextPhoneNumber = &RichTextPhoneNumber{} + return json.Unmarshal(trimmed, rt.RichTextPhoneNumber) + case RichTextTypeBankCardNumber: + rt.Type = RichTextTypeBankCardNumber + rt.RichTextBankCardNumber = &RichTextBankCardNumber{} + return json.Unmarshal(trimmed, rt.RichTextBankCardNumber) + case RichTextTypeMention: + rt.Type = RichTextTypeMention + rt.RichTextMention = &RichTextMention{} + return json.Unmarshal(trimmed, rt.RichTextMention) + case RichTextTypeHashtag: + rt.Type = RichTextTypeHashtag + rt.RichTextHashtag = &RichTextHashtag{} + return json.Unmarshal(trimmed, rt.RichTextHashtag) + case RichTextTypeCashtag: + rt.Type = RichTextTypeCashtag + rt.RichTextCashtag = &RichTextCashtag{} + return json.Unmarshal(trimmed, rt.RichTextCashtag) + case RichTextTypeBotCommand: + rt.Type = RichTextTypeBotCommand + rt.RichTextBotCommand = &RichTextBotCommand{} + return json.Unmarshal(trimmed, rt.RichTextBotCommand) + case RichTextTypeAnchor: + rt.Type = RichTextTypeAnchor + rt.RichTextAnchor = &RichTextAnchor{} + return json.Unmarshal(trimmed, rt.RichTextAnchor) + case RichTextTypeAnchorLink: + rt.Type = RichTextTypeAnchorLink + rt.RichTextAnchorLink = &RichTextAnchorLink{} + return json.Unmarshal(trimmed, rt.RichTextAnchorLink) + case RichTextTypeReference: + rt.Type = RichTextTypeReference + rt.RichTextReference = &RichTextReference{} + return json.Unmarshal(trimmed, rt.RichTextReference) + case RichTextTypeReferenceLink: + rt.Type = RichTextTypeReferenceLink + rt.RichTextReferenceLink = &RichTextReferenceLink{} + return json.Unmarshal(trimmed, rt.RichTextReferenceLink) + } + + return fmt.Errorf("unsupported RichText type %q", v.Type) +} + +// RichTextBold https://core.telegram.org/bots/api#richtextbold +type RichTextBold struct { + Type RichTextType `json:"type"` + Text RichText `json:"text"` +} + +// RichTextItalic https://core.telegram.org/bots/api#richtextitalic +type RichTextItalic struct { + Type RichTextType `json:"type"` + Text RichText `json:"text"` +} + +// RichTextUnderline https://core.telegram.org/bots/api#richtextunderline +type RichTextUnderline struct { + Type RichTextType `json:"type"` + Text RichText `json:"text"` +} + +// RichTextStrikethrough https://core.telegram.org/bots/api#richtextstrikethrough +type RichTextStrikethrough struct { + Type RichTextType `json:"type"` + Text RichText `json:"text"` +} + +// RichTextSpoiler https://core.telegram.org/bots/api#richtextspoiler +type RichTextSpoiler struct { + Type RichTextType `json:"type"` + Text RichText `json:"text"` +} + +// RichTextDateTime https://core.telegram.org/bots/api#richtextdatetime +type RichTextDateTime struct { + Type RichTextType `json:"type"` + Text RichText `json:"text"` + UnixTime int `json:"unix_time"` + DateTimeFormat string `json:"date_time_format"` +} + +// RichTextTextMention https://core.telegram.org/bots/api#richtexttextmention +type RichTextTextMention struct { + Type RichTextType `json:"type"` + Text RichText `json:"text"` + User *User `json:"user"` +} + +// RichTextSubscript https://core.telegram.org/bots/api#richtextsubscript +type RichTextSubscript struct { + Type RichTextType `json:"type"` + Text RichText `json:"text"` +} + +// RichTextSuperscript https://core.telegram.org/bots/api#richtextsuperscript +type RichTextSuperscript struct { + Type RichTextType `json:"type"` + Text RichText `json:"text"` +} + +// RichTextMarked https://core.telegram.org/bots/api#richtextmarked +type RichTextMarked struct { + Type RichTextType `json:"type"` + Text RichText `json:"text"` +} + +// RichTextCode https://core.telegram.org/bots/api#richtextcode +type RichTextCode struct { + Type RichTextType `json:"type"` + Text RichText `json:"text"` +} + +// RichTextCustomEmoji https://core.telegram.org/bots/api#richtextcustomemoji +type RichTextCustomEmoji struct { + Type RichTextType `json:"type"` + CustomEmojiID string `json:"custom_emoji_id"` + AlternativeText string `json:"alternative_text"` +} + +// RichTextMathematicalExpression https://core.telegram.org/bots/api#richtextmathematicalexpression +type RichTextMathematicalExpression struct { + Type RichTextType `json:"type"` + Expression string `json:"expression"` +} + +// RichTextURL https://core.telegram.org/bots/api#richtexturl +type RichTextURL struct { + Type RichTextType `json:"type"` + Text RichText `json:"text"` + URL string `json:"url"` +} + +// RichTextEmailAddress https://core.telegram.org/bots/api#richtextemailaddress +type RichTextEmailAddress struct { + Type RichTextType `json:"type"` + Text RichText `json:"text"` + EmailAddress string `json:"email_address"` +} + +// RichTextPhoneNumber https://core.telegram.org/bots/api#richtextphonenumber +type RichTextPhoneNumber struct { + Type RichTextType `json:"type"` + Text RichText `json:"text"` + PhoneNumber string `json:"phone_number"` +} + +// RichTextBankCardNumber https://core.telegram.org/bots/api#richtextbankcardnumber +type RichTextBankCardNumber struct { + Type RichTextType `json:"type"` + Text RichText `json:"text"` + BankCardNumber string `json:"bank_card_number"` +} + +// RichTextMention https://core.telegram.org/bots/api#richtextmention +type RichTextMention struct { + Type RichTextType `json:"type"` + Text RichText `json:"text"` + Username string `json:"username"` +} + +// RichTextHashtag https://core.telegram.org/bots/api#richtexthashtag +type RichTextHashtag struct { + Type RichTextType `json:"type"` + Text RichText `json:"text"` + Hashtag string `json:"hashtag"` +} + +// RichTextCashtag https://core.telegram.org/bots/api#richtextcashtag +type RichTextCashtag struct { + Type RichTextType `json:"type"` + Text RichText `json:"text"` + Cashtag string `json:"cashtag"` +} + +// RichTextBotCommand https://core.telegram.org/bots/api#richtextbotcommand +type RichTextBotCommand struct { + Type RichTextType `json:"type"` + Text RichText `json:"text"` + BotCommand string `json:"bot_command"` +} + +// RichTextAnchor https://core.telegram.org/bots/api#richtextanchor +type RichTextAnchor struct { + Type RichTextType `json:"type"` + Name string `json:"name"` +} + +// RichTextAnchorLink https://core.telegram.org/bots/api#richtextanchorlink +type RichTextAnchorLink struct { + Type RichTextType `json:"type"` + Text RichText `json:"text"` + AnchorName string `json:"anchor_name"` +} + +// RichTextReference https://core.telegram.org/bots/api#richtextreference +type RichTextReference struct { + Type RichTextType `json:"type"` + Text RichText `json:"text"` + Name string `json:"name"` +} + +// RichTextReferenceLink https://core.telegram.org/bots/api#richtextreferencelink +type RichTextReferenceLink struct { + Type RichTextType `json:"type"` + Text RichText `json:"text"` + ReferenceName string `json:"reference_name"` +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 795ff13..a93ddc9 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1,7 +1,7 @@ # github.com/davecgh/go-spew v1.1.1 ## explicit github.com/davecgh/go-spew/spew -# github.com/go-telegram/bot v1.21.0 +# github.com/go-telegram/bot v1.22.0 ## explicit; go 1.18 github.com/go-telegram/bot github.com/go-telegram/bot/models