mirror of
https://github.com/shazow/ssh-chat.git
synced 2025-07-23 14:04:40 +02: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,
|
Server: server,
|
||||||
Conn: conn,
|
Conn: conn,
|
||||||
Name: conn.User(),
|
Name: conn.User(),
|
||||||
Color: RandomColor(),
|
Color: RandomColor256(),
|
||||||
Msg: make(chan string, MSG_BUFFER),
|
Msg: make(chan string, MSG_BUFFER),
|
||||||
ready: make(chan struct{}, 1),
|
ready: make(chan struct{}, 1),
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"time"
|
"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" }
|
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 {
|
func RandomColor() string {
|
||||||
rand.Seed(time.Now().UTC().UnixNano())
|
rand.Seed(time.Now().UTC().UnixNano())
|
||||||
return colors[rand.Intn(len(colors))]
|
return colors[rand.Intn(len(colors))]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user