Improved potential system message handling for Owncast
This commit is contained in:
+13
-4
@@ -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 the message came from a real user, this is the one we should process */
|
||||||
if rawmsg["type"] == "CHAT" {
|
if rawmsg["type"] == "CHAT" {
|
||||||
if !slices.Contains(oc_msg_id_cache, rawmsg["id"].(string)) { /* we have a fresh message here */
|
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 */
|
/* convert the timestamp */
|
||||||
sent_dt, _ := time.Parse("2006-01-02T15:04:05.000000000Z", rawmsg["timestamp"].(string))
|
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 */
|
/* add display color hint */
|
||||||
dcolor := int(author["displayColor"].(float64))
|
if _, ok := author["displayColor"]; ok {
|
||||||
if dcolor > 0 {
|
dcolor := int(author["displayColor"].(float64))
|
||||||
out_message.Type += fmt.Sprintf("-occolor%d", dcolor)
|
if dcolor > 0 {
|
||||||
|
out_message.Type += fmt.Sprintf("-occolor%d", dcolor)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* finally, send it to the message broker via the message_transport channel */
|
/* finally, send it to the message broker via the message_transport channel */
|
||||||
|
|||||||
Reference in New Issue
Block a user