The algorithm @george posted doesn’t seem to work anymore, and I haven’t found it in the source. (It’s not the fact that Green is now #008000). Some names return the same color although they are represented different in the original Twitch chat.
The users Swaggsurfnn and BobdeBouwerMC didn’t have a color tag but were represented in the original chat as BlueViolet and Blue respectively. The table shows calculations done on their names the way they are displayed, capital first letter and only lower case.
Swaggsurfn | Swaggsurfnn | swaggsurfnn
n 193 193 225
i 13 13 0
BlueViolet BlueViolet Red
BobdeBouwerMC | Bobdebouwermc | bobdebouwermc
n 133 165 197
i 13 0 2
BlueViolet Red Green
This is my adaptation in Go:
func colorFromName(name string) string {
n := int(name[0]) + int(name[len(name)-1])
return default_colors[n%len(default_colors)][1]
}
My application is supposed to work in conjunction with the original chat, so it would be nice if it had the same colors. Does anyone know the correct algorithm, or a different order of the array?