feat: sync rich text message support

This commit is contained in:
A 2026-07-04 21:15:35 +08:00
parent 4d3bbeabd8
commit 7c9d8dda16
41 changed files with 1164 additions and 94 deletions

View file

@ -602,6 +602,8 @@ type ChannelMessage struct {
Reactions *ChannelMessageReactions
Action *ChannelMessageAction
Media *MessageMedia
// RichMessage 是 Layer 227 富文本消息(richMessage)快照,可选;普通消息恒 nil。
RichMessage *MessageRichMessage
// FromBoostsApplied 是发送时的 sender boost 数快照(message.from_boosts_applied)。
FromBoostsApplied int
TTLPeriod int
@ -1373,6 +1375,7 @@ type SendChannelMessageRequest struct {
// GroupedID 相册分组 id(sendMultiMedia 同组共享非零值,非相册恒 0)。
GroupedID int64
ReplyMarkup *MessageReplyMarkup
RichMessage *MessageRichMessage
SendAs *Peer
Action *ChannelMessageAction
Date int
@ -1615,6 +1618,9 @@ type EditChannelMessageRequest struct {
// SetReplyMarkup 置位时替换 reply_markup(ReplyMarkup 为 nil/空 = 清空键盘)。
SetReplyMarkup bool
ReplyMarkup *MessageReplyMarkup
// SetRichMessage 置位时替换 rich_message(RichMessage nil/空 = 清空富文本)。
SetRichMessage bool
RichMessage *MessageRichMessage
// ViaBotEditBotID 非零时要求目标消息 via_bot_id 匹配对应 bot。
ViaBotEditBotID int64
// AllowTodoParticipantMutation 允许非作者普通成员在 checklist 的

View file

@ -9,7 +9,7 @@ func ChannelBannedRightsBlockMessage(req SendChannelMessageRequest, channel Chan
return false
}
if req.Media.IsZero() {
if strings.TrimSpace(req.Message) == "" {
if strings.TrimSpace(req.Message) == "" && req.RichMessage.IsZero() {
return false
}
return channelBannedRightsBlockWithBoost(channel, member.BannedRights.SendPlain, channel.DefaultBannedRights.SendPlain, selfBoostsApplied)

View file

@ -113,6 +113,7 @@ type DialogDraft struct {
ReplyTo *MessageReply
WebPage *DialogDraftWebPage
Effect int64
RichMessage *MessageRichMessage
}
// Empty reports whether this draft should clear the cloud draft slot.
@ -124,7 +125,8 @@ func (d DialogDraft) Empty() bool {
len(d.Entities) == 0 &&
(d.ReplyTo == nil || replyOnlyTopic) &&
d.WebPage == nil &&
d.Effect == 0
d.Effect == 0 &&
d.RichMessage.IsZero()
}
// DialogArchiveSummary 聚合归档(folder_id=1)状态,供主列表 getDialogs

View file

@ -418,6 +418,10 @@ type EditMessageRequest struct {
// 未置位则保留原 markup。仅 bot 编辑自己消息时由 RPC 层置位(P3)。
SetReplyMarkup bool
ReplyMarkup *MessageReplyMarkup
// SetRichMessage 置位时替换 rich_message(RichMessage nil/空 = 清空富文本)。
// TDesktop EditRichMessage 只带 f_rich_message,不带 f_message;store 不能把它误判为空编辑。
SetRichMessage bool
RichMessage *MessageRichMessage
// ViaBotEditBotID 非零时允许对应 bot 编辑经由它发送的 inline 私聊消息。
ViaBotEditBotID int64
// AllowTodoParticipantMutation 允许 checklist 参与者在 others_can_* 授权下通过
@ -598,6 +602,7 @@ type ScheduledMessage struct {
Message string
Entities []MessageEntity
Media *MessageMedia
RichMessage *MessageRichMessage
Silent bool
NoForwards bool
ReplyTo *MessageReply
@ -626,6 +631,7 @@ type ScheduleMessageRequest struct {
Message string
Entities []MessageEntity
Media *MessageMedia
RichMessage *MessageRichMessage
Silent bool
NoForwards bool
ReplyTo *MessageReply
@ -639,14 +645,16 @@ type ScheduleMessageRequest struct {
// EditScheduledMessageRequest updates one pending scheduled message before it
// enters normal history.
type EditScheduledMessageRequest struct {
OwnerUserID int64
Peer Peer
ID int
SetMessage bool
Message string
Entities []MessageEntity
ScheduleDate int
Date int
OwnerUserID int64
Peer Peer
ID int
SetMessage bool
Message string
Entities []MessageEntity
SetRichMessage bool
RichMessage *MessageRichMessage
ScheduleDate int
Date int
}
// ScheduledMessageFilter selects scheduled messages for one owner/peer.