GetContent 获取消息内容,优先返回 Content,如果为空则从 ContentBlocks 提取
()
| 203 | |
| 204 | // GetContent 获取消息内容,优先返回 Content,如果为空则从 ContentBlocks 提取 |
| 205 | func (m *Message) GetContent() string { |
| 206 | if m.Content != "" { |
| 207 | return m.Content |
| 208 | } |
| 209 | // 从 ContentBlocks 提取文本 |
| 210 | for _, block := range m.ContentBlocks { |
| 211 | if tb, ok := block.(*TextBlock); ok { |
| 212 | return tb.Text |
| 213 | } |
| 214 | } |
| 215 | return "" |
| 216 | } |
| 217 | |
| 218 | // SetContent 设置消息内容(简单文本格式) |
| 219 | func (m *Message) SetContent(content string) { |
no outgoing calls
no test coverage detected