(new): rich message support
Golang lint / lint (pull_request) Successful in 1m20s
Golang lint / lint (push) Successful in 4m8s

(fix): runtime reliability
(tests): regression coverage
(doc): v1.1 release notes
This commit is contained in:
2026-08-12 16:34:44 +03:00
parent 48ddf66540
commit f03a081ed6
83 changed files with 6122 additions and 1925 deletions
+53 -17
View File
@@ -23,10 +23,14 @@ type DirectMessageTopic struct {
type MessageOriginType string
const (
MessageOriginUserType = "user"
// MessageOriginUserType identifies a known user origin.
MessageOriginUserType = "user"
// MessageOriginHiddenUserType identifies a hidden user origin.
MessageOriginHiddenUserType = "hidden_user"
MessageOriginChatType = "chat"
MessageOriginChannel = "channel"
// MessageOriginChatType identifies a chat origin.
MessageOriginChatType = "chat"
// MessageOriginChannel identifies a channel origin.
MessageOriginChannel = "channel"
)
// MessageOrigin describes the origin of a message.
@@ -115,10 +119,14 @@ type Message struct {
DirectMessageTopic *DirectMessageTopic `json:"direct_message_topic,omitempty"` // Since: Bot API 9.2
From *User `json:"from,omitempty"`
SenderChat *Chat `json:"sender_chat,omitempty"` // Since: Bot API 5.0
SenderBoostCount int `json:"sender_boost_count,omitempty"` // Since: Bot API 7.1
SenderBusinessBot *User `json:"sender_business_bot,omitempty"` // Since: Bot API 7.2
SenderTag string `json:"sender_tag,omitempty"` // Since: Bot API 9.5
SenderChat *Chat `json:"sender_chat,omitempty"` // Since: Bot API 5.0
SenderBoostCount int `json:"sender_boost_count,omitempty"` // Since: Bot API 7.1
SenderBusinessBot *User `json:"sender_business_bot,omitempty"` // Since: Bot API 7.2
SenderTag string `json:"sender_tag,omitempty"` // Since: Bot API 9.5
// ReceiverUser identifies the user who can see the ephemeral message.
ReceiverUser *User `json:"receiver_user,omitempty"` // Since: Bot API 10.2
// EphemeralMessageID identifies the ephemeral message.
EphemeralMessageID int64 `json:"ephemeral_message_id,omitempty"` // Since: Bot API 10.2
Date int `json:"date"`
GuestQueryID string `json:"guest_query_id,omitempty"` // Since: Bot API 10.0
BusinessConnectionID string `json:"business_connection_id,omitempty"` // Since: Bot API 7.2
@@ -151,6 +159,7 @@ type Message struct {
SuggestedPostInfo *SuggestedPostInfo `json:"suggested_post_info,omitempty"` // Since: Bot API 9.1
EffectID string `json:"effect_id,omitempty"` // Since: Bot API 7.4
// RichMessage contains structured rich-message content.
RichMessage *RichMessage `json:"rich_message,omitempty"` // Since: Bot API 10.1
Animation *Animation `json:"animation,omitempty"` // Since: Bot API 4.0
Audio *Audio `json:"audio,omitempty"`
@@ -206,8 +215,12 @@ type Message struct {
BoostAdded *ChatBoostAdded `json:"boost_added,omitempty"` // Since: Bot API 7.1
ChatBackgroundSet *ChatBackground `json:"chat_background_set,omitempty"` // Since: Bot API 7.5
ChecklistTaskDone *ChecklistTaskDone `json:"checklist_task_done,omitempty"` // Since: Bot API 9.1
ChecklistTasksAdded *ChecklistTasksAdded `json:"checklist_tasks_added,omitempty"` // Since: Bot API 9.1
ChecklistTaskDone *ChecklistTaskDone `json:"checklist_task_done,omitempty"` // Since: Bot API 9.1
ChecklistTasksAdded *ChecklistTasksAdded `json:"checklist_tasks_added,omitempty"` // Since: Bot API 9.1
// CommunityChatAdded describes a community chat addition service message.
CommunityChatAdded *CommunityChatAdded `json:"community_chat_added,omitempty"` // Since: Bot API 10.2
// CommunityChatRemoved describes a community chat removal service message.
CommunityChatRemoved *CommunityChatRemoved `json:"community_chat_removed,omitempty"` // Since: Bot API 10.2
DirectMessagePriceChanged *DirectMessagePriceChanged `json:"direct_message_price_changed,omitempty"` // Since: Bot API 9.1
PaidMessagePriceChanged *PaidMessagePriceChanged `json:"paid_message_price_changed,omitempty"` // Since: Bot API 9.x
ForumTopicCreated *ForumTopicCreated `json:"forum_topic_created,omitempty"` // Since: Bot API 6.3
@@ -395,8 +408,10 @@ type MessageEntity struct {
// Since: Bot API 7.0
// See https://core.telegram.org/bots/api#replyparameters
type ReplyParameters struct {
MessageID int `json:"message_id"`
MessageID int `json:"message_id,omitempty"`
ChatID int64 `json:"chat_id,omitempty"`
// EphemeralMessageID identifies the ephemeral message.
EphemeralMessageID int64 `json:"ephemeral_message_id,omitempty"` // Since: Bot API 10.2
AllowSendingWithoutReply bool `json:"allow_sending_without_reply,omitempty"`
Quote string `json:"quote,omitempty"`
@@ -750,18 +765,39 @@ type SentGuestMessage struct {
InlineMessageID string `json:"inline_message_id"`
}
// RichMessage Rich formatted message.
// RichMessage represents a received rich-formatted message.
// Since: Bot API 10.1
type RichMessage struct {
// Blocks contains the nested rich-message blocks.
Blocks []RichBlock `json:"blocks"`
IsRTL bool `json:"is_rtl,omitempty"`
// IsRTL requests right-to-left rich-message layout.
IsRTL bool `json:"is_rtl,omitempty"`
}
// InputRichMessage Describes a rich message to be sent. Exactly one of the fields html or markdown must be used.
// InputRichMessageMedia describes media embedded in outgoing rich-message HTML or Markdown.
//
// Since: Bot API 10.2
type InputRichMessageMedia struct {
// ID uniquely identifies the value within its containing object.
ID string `json:"id"`
// Media contains or identifies media associated with the value.
Media InputMedia `json:"media"`
}
// InputRichMessage describes a rich message to be sent. Exactly one of HTML, Markdown, or Blocks must be used.
//
// Since: Bot API 10.1
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"`
// Blocks contains the nested rich-message blocks.
Blocks []InputRichBlock `json:"blocks,omitempty"` // Since: Bot API 10.2
// HTML contains rich-message content in Telegram HTML syntax.
HTML string `json:"html,omitempty"`
// Markdown contains rich-message content in Telegram Markdown syntax.
Markdown string `json:"markdown,omitempty"`
// Media contains or identifies media associated with the value.
Media []InputRichMessageMedia `json:"media,omitempty"` // Since: Bot API 10.2
// IsRTL requests right-to-left rich-message layout.
IsRTL bool `json:"is_rtl,omitempty"`
// SkipEntityDetection disables automatic detection of links, mentions, hashtags, commands, phone numbers, and bank cards.
SkipEntityDetection bool `json:"skip_entity_detection,omitempty"`
}