Merge pull request #951 from trheyi/main

fix: Add support for attachments in message mapping
This commit is contained in:
Max 2025-05-12 14:39:02 +08:00 committed by GitHub
commit c3b30a018e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

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
}