Removed dark names, dont color join mesages.

This commit is contained in:
Andrey Petrov 2014-12-14 22:51:22 -08:00
parent 6c8f76f08d
commit 9a2d14066c
2 changed files with 15 additions and 4 deletions

View File

@ -42,9 +42,20 @@ func DeColorString(s string) string {
return s
}
func randomReadableColor() int {
for {
i := rand.Intn(256)
if (16 <= i && i <= 18) || (232 <= i && i <= 237) {
// Remove the ones near black, this is kinda sadpanda.
continue
}
return i
}
}
// RandomColor256 returns a random (of 256) color
func RandomColor256() string {
return fmt.Sprintf("38;05;%d", rand.Intn(256))
return fmt.Sprintf("38;05;%d", randomReadableColor())
}
// RandomColor returns a random color

View File

@ -167,7 +167,7 @@ func (s *Server) Add(client *Client) {
newName, err := s.proposeName(client.Name)
if err != nil {
client.SysMsg("Your name '%s' is not available, renamed to '%s'. Use /nick <name> to change it.", client.ColoredName(), ColorString(client.Color, newName))
client.SysMsg("Your name '%s' is not available, renamed to '%s'. Use /nick <name> to change it.", client.Name, ColorString(client.Color, newName))
}
client.Rename(newName)
@ -175,7 +175,7 @@ func (s *Server) Add(client *Client) {
num := len(s.clients)
s.Unlock()
s.Broadcast(ContinuousFormat(systemMessageFormat, fmt.Sprintf(" * %s joined. (Total connected: %d)", client.ColoredName(), num)), client)
s.Broadcast(ContinuousFormat(systemMessageFormat, fmt.Sprintf(" * %s joined. (Total connected: %d)", client.Name, num)), client)
}
// Remove removes the given client from the list of clients
@ -184,7 +184,7 @@ func (s *Server) Remove(client *Client) {
delete(s.clients, strings.ToLower(client.Name))
s.Unlock()
s.SysMsg("%s left.", client.ColoredName())
s.SysMsg("%s left.", client.Name)
}
func (s *Server) proposeName(name string) (string, error) {