global badge/class fix

This commit is contained in:
Luxferre
2024-09-20 13:44:13 +03:00
parent b6200db5de
commit 9f298cba52
6 changed files with 18 additions and 21 deletions
+2 -2
View File
@@ -119,14 +119,14 @@ func kk_process_message(rawmsg map[string]interface{}) {
/* process username color preference */
if _, ok := metadata["color"]; ok && len(metadata["color"].(string)) > 0 {
out_message.Type += "-color" + metadata["color"].(string)
out_message.Type += "^color" + metadata["color"].(string)
}
/* process username badges */
if _, ok := metadata["badges"]; ok && len(metadata["badges"].([]interface{})) > 0 {
for _, badge := range metadata["badges"].([]interface{}) {
if badge.(map[string]interface{})["active"].(bool) {
out_message.Type += "-" + strings.ToLower(badge.(map[string]interface{})["text"].(string))
out_message.Type += "^" + strings.ToLower(badge.(map[string]interface{})["text"].(string))
}
}
}
+3 -4
View File
@@ -74,7 +74,6 @@ func oc_process_message(rawmsg map[string]interface{}) {
author["displayName"] = "System"
}
/* convert the timestamp */
sent_dt, _ := time.Parse("2006-01-02T15:04:05.000000000Z", rawmsg["timestamp"].(string))
@@ -93,19 +92,19 @@ func oc_process_message(rawmsg map[string]interface{}) {
/* check for authenticated role */
if _, ok := author["authenticated"]; ok && author["authenticated"].(bool) == true {
out_message.Type += "-authenticated"
out_message.Type += "^authenticated"
}
/* check for bot role */
if _, ok := author["isBot"]; ok && author["isBot"].(bool) == true {
out_message.Type += "-bot"
out_message.Type += "^bot"
}
/* add display color hint */
if _, ok := author["displayColor"]; ok {
dcolor := int(author["displayColor"].(float64))
if dcolor > 0 {
out_message.Type += fmt.Sprintf("-occolor%d", dcolor)
out_message.Type += fmt.Sprintf("^occolor%d", dcolor)
}
}
+5 -3
View File
@@ -197,19 +197,21 @@ func tw_process_message(rawmsg string) {
if len(badges) > 0 { /* process badge names */
for _, badge := range badges { /* extract the badge name and version */
bname, bver, _ := strings.Cut(badge, "/")
out_message.Type += "-" + bname + "-badgetw" + bname + "_" + bver
if len(bname) > 0 {
out_message.Type += "^" + bname + "^badgetw" + bname + "_" + bver
}
}
}
}
/* process username color preference */
if _, ok := metadata["color"]; ok && len(metadata["color"]) > 0 {
out_message.Type += "-color" + metadata["color"]
out_message.Type += "^color" + metadata["color"]
}
/* process third-party action */
if strings.HasPrefix(out_message.Text, "/me") {
out_message.Type += "-me"
out_message.Type += "^me"
out_message.Text = strings.TrimSpace(out_message.Text[4:])
}
+4 -4
View File
@@ -137,20 +137,20 @@ func yt_inner_action_to_chatitem(action map[string]interface{}) ChatMessage {
if _, ok := badge["customThumbnail"]; !ok { /* custom badges not supported yet */
switch badge["icon"].(map[string]interface{})["iconType"].(string) {
case "OWNER":
out_message.Type += "-broadcaster"
out_message.Type += "^broadcaster"
break
case "MODERATOR":
out_message.Type += "-moderator"
out_message.Type += "^moderator"
break
case "VERIFIED":
out_message.Type += "-verified"
out_message.Type += "^verified"
break
}
}
}
}
if _, ok := renderer["purchaseAmountText"]; ok {
out_message.Type += "-sponsor"
out_message.Type += "^sponsor"
}
return out_message