| 1 | // See https://github.com/42wim/matterbridge/issues/881 |
| 2 | // Generates a colored nick for each msgUsername, with example to filter specific codes |
| 3 | |
| 4 | text := import("text") |
| 5 | fmt := import("fmt") |
| 6 | if outProtocol == "irc" { |
| 7 | // generate a color for a nick, make sure it isn't 0 or 15 |
| 8 | colorCode := len(msgUsername)+bytes(msgUsername)[0]%14 + 2 |
| 9 | // example if we want to use colorCode 3 when we have calculated colorcode 14 |
| 10 | if colorCode == 14 { |
| 11 | colorCode = 3 |
| 12 | } |
| 13 | msgUsername=fmt.sprintf("\x03%02d%s\x0F", colorCode, msgUsername) |
| 14 | } |
| 15 | |