diff --git a/src/owncast.go b/src/owncast.go index 05f2aa9..a6f5fde 100644 --- a/src/owncast.go +++ b/src/owncast.go @@ -72,7 +72,14 @@ func oc_process_message(rawmsg map[string]interface{}) { /* if the message came from a real user, this is the one we should process */ if rawmsg["type"] == "CHAT" { if !slices.Contains(oc_msg_id_cache, rawmsg["id"].(string)) { /* we have a fresh message here */ - author := rawmsg["user"].(map[string]interface{}) + var author map[string]interface{} + /* check if the "user" field is present */ + if _, ok := rawmsg["user"]; ok { + author = rawmsg["user"].(map[string]interface{}) + } else { + author["displayName"] = "System" + } + /* convert the timestamp */ sent_dt, _ := time.Parse("2006-01-02T15:04:05.000000000Z", rawmsg["timestamp"].(string)) @@ -101,9 +108,11 @@ func oc_process_message(rawmsg map[string]interface{}) { } /* add display color hint */ - dcolor := int(author["displayColor"].(float64)) - if dcolor > 0 { - out_message.Type += fmt.Sprintf("-occolor%d", dcolor) + if _, ok := author["displayColor"]; ok { + dcolor := int(author["displayColor"].(float64)) + if dcolor > 0 { + out_message.Type += fmt.Sprintf("-occolor%d", dcolor) + } } /* finally, send it to the message broker via the message_transport channel */