@@ -1188,19 +1188,38 @@ var Subcommands = map[string]Subcommand{
11881188 cursor = edge
11891189 cursor = cursor .(Object )["node" ]
11901190 cursor = cursor .(Object )["commenter" ]
1191+ var commenter string
11911192 if cursor != nil {
11921193 cursor = cursor .(Object )["login" ]
1193- fmt . Printf ( "%s," , cursor .(string ) )
1194+ commenter = cursor .(string )
11941195 } else {
11951196 // Apparent this may happen if the account got deleted after the stream
1196- fmt . Printf ( "<DELETED>," )
1197+ commenter = "<DELETED>"
11971198 }
1199+ fmt .Printf ("%s," , commenter )
11981200
1199- // cursor = edge
1200- // cursor = cursor.(Object)["node"]
1201- // cursor = cursor.(Object)["message"]
1202- // cursor = cursor.(Object)["userColor"]
1203- fmt .Printf ("#FF0000," ) // We don't need the color, but https://twitchchatdownloader.com/ prints it so our parser expects it
1201+ cursor = edge
1202+ cursor = cursor .(Object )["node" ]
1203+ cursor = cursor .(Object )["message" ]
1204+ cursor = cursor .(Object )["userColor" ]
1205+ var color string
1206+ if cursor != nil {
1207+ color = cursor .(string );
1208+ } else {
1209+ // Taken from https://discuss.dev.twitch.com/t/default-user-color-in-chat/385
1210+ // I don't know if it's still accurate, but I don't care, we just need some sort of
1211+ // default color
1212+ defaultColors := []string {
1213+ "#FF0000" , "#0000FF" , "#00FF00" ,
1214+ "#B22222" , "#FF7F50" , "#9ACD32" ,
1215+ "#FF4500" , "#2E8B57" , "#DAA520" ,
1216+ "#D2691E" , "#5F9EA0" , "#1E90FF" ,
1217+ "#FF69B4" , "#8A2BE2" , "#00FF7F" ,
1218+ }
1219+ index := int (commenter [0 ] + commenter [len (commenter )- 1 ])
1220+ color = defaultColors [index % len (defaultColors )]
1221+ }
1222+ fmt .Printf ("%s," , color )
12041223
12051224 cursor = edge
12061225 cursor = cursor .(Object )["node" ]
0 commit comments