@@ -40,7 +40,9 @@ func (c *GChatClient) HandleMatrixMessage(ctx context.Context, msg *bridgev2.Mat
40
40
}
41
41
42
42
var annotations []* proto.Annotation
43
- var messageInfo * proto.MessageInfo
43
+ messageInfo := & proto.MessageInfo {
44
+ AcceptFormatAnnotations : true ,
45
+ }
44
46
45
47
if msg .Content .MsgType .IsMedia () {
46
48
data , err := c .userLogin .Bridge .Bot .DownloadMedia (ctx , msg .Content .URL , msg .Content .File )
@@ -68,35 +70,35 @@ func (c *GChatClient) HandleMatrixMessage(ctx context.Context, msg *bridgev2.Mat
68
70
if msg .ThreadRoot != nil {
69
71
topicId = string (msg .ThreadRoot .ID )
70
72
}
71
- messageInfo = & proto.MessageInfo {
72
- AcceptFormatAnnotations : true ,
73
- ReplyTo : & proto.SendReplyTarget {
74
- Id : & proto.MessageId {
75
- ParentId : & proto.MessageParentId {
76
- Parent : & proto.MessageParentId_TopicId {
77
- TopicId : & proto.TopicId {
78
- GroupId : groupId ,
79
- TopicId : topicId ,
80
- },
73
+ messageInfo .ReplyTo = & proto.SendReplyTarget {
74
+ Id : & proto.MessageId {
75
+ ParentId : & proto.MessageParentId {
76
+ Parent : & proto.MessageParentId_TopicId {
77
+ TopicId : & proto.TopicId {
78
+ GroupId : groupId ,
79
+ TopicId : topicId ,
81
80
},
82
81
},
83
- MessageId : replyToId ,
84
82
},
85
- CreateTime : msg . ReplyTo . Timestamp . UnixMicro () ,
83
+ MessageId : replyToId ,
86
84
},
85
+ CreateTime : msg .ReplyTo .Timestamp .UnixMicro (),
87
86
}
88
87
}
89
88
90
89
var msgID string
91
90
var timestamp int64
92
91
92
+ textBody := msg .Content .Body
93
+ text , entities := c .msgConv .ToGChat (ctx , msg .Content )
94
+
95
+ if entities != nil {
96
+ textBody = text
97
+ annotations = entities
98
+ }
99
+
93
100
if msg .ThreadRoot != nil {
94
101
threadId := string (msg .ThreadRoot .ID )
95
- if messageInfo == nil {
96
- messageInfo = & proto.MessageInfo {
97
- AcceptFormatAnnotations : true ,
98
- }
99
- }
100
102
req := & proto.CreateMessageRequest {
101
103
ParentId : & proto.MessageParentId {
102
104
Parent : & proto.MessageParentId_TopicId {
@@ -107,7 +109,7 @@ func (c *GChatClient) HandleMatrixMessage(ctx context.Context, msg *bridgev2.Mat
107
109
},
108
110
},
109
111
LocalId : string (msg .Event .ID ),
110
- TextBody : msg . Content . Body ,
112
+ TextBody : textBody ,
111
113
Annotations : annotations ,
112
114
MessageInfo : messageInfo ,
113
115
}
@@ -120,7 +122,7 @@ func (c *GChatClient) HandleMatrixMessage(ctx context.Context, msg *bridgev2.Mat
120
122
} else {
121
123
req := & proto.CreateTopicRequest {
122
124
GroupId : groupId ,
123
- TextBody : msg . Content . Body ,
125
+ TextBody : textBody ,
124
126
Annotations : annotations ,
125
127
MessageInfo : messageInfo ,
126
128
}
0 commit comments