mirror of
https://github.com/shazow/ssh-chat.git
synced 2025-04-20 02:37:41 +03:00
Allow for 256 different colors for username colors
I have heard this should be fairly well supported, so I'm hoping these colors will all show up nicely for everyone.
This commit is contained in:
parent
46d00b3e55
commit
6d8d533bed
@ -51,7 +51,7 @@ func NewClient(server *Server, conn *ssh.ServerConn) *Client {
|
||||
Server: server,
|
||||
Conn: conn,
|
||||
Name: conn.User(),
|
||||
Color: RandomColor(),
|
||||
Color: RandomColor256(),
|
||||
Msg: make(chan string, MSG_BUFFER),
|
||||
ready: make(chan struct{}, 1),
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"math/rand"
|
||||
"time"
|
||||
@ -16,6 +17,11 @@ const INVERT string = "\033[7m"
|
||||
|
||||
var colors = []string { "31", "32", "33", "34", "35", "36", "37", "91", "92", "93", "94", "95", "96", "97" }
|
||||
|
||||
func RandomColor256() string {
|
||||
rand.Seed(time.Now().UTC().UnixNano())
|
||||
return fmt.Sprintf("38;05;%d", rand.Intn(256))
|
||||
}
|
||||
|
||||
func RandomColor() string {
|
||||
rand.Seed(time.Now().UTC().UnixNano())
|
||||
return colors[rand.Intn(len(colors))]
|
||||
|
Loading…
x
Reference in New Issue
Block a user