fix: Add support for attachments in message mapping

- Implemented functionality to handle attachments in the Map method of the Message struct.
- Added JSON parsing for attachments, ensuring proper error handling and feedback during the process.
This commit is contained in:
Max 2025-05-12 14:38:37 +08:00
parent 8b7d56a83d
commit 15f3f0adf8

View file

@ -497,6 +497,16 @@ func (m *Message) Map(msg map[string]interface{}) *Message {
}
}
// attachments
if attachments, has := msg["attachments"]; has {
raw, _ := jsoniter.Marshal(attachments)
m.Attachments = []Attachment{}
if err := jsoniter.Unmarshal(raw, &m.Attachments); err != nil {
color.Red("JSON parse error: %s", err.Error())
color.White(string(raw))
}
}
if role, ok := msg["role"].(string); ok {
m.Role = role
}