diff --git a/client.go b/client.go index 7cc7fce..53bdd61 100644 --- a/client.go +++ b/client.go @@ -119,6 +119,9 @@ func (c *Client) handleShell(channel ssh.Channel) { if isCmd { // TODO: Factor this out. switch parts[0] { + case "/test-colors": // Shh, this command is a secret! + c.Write(ColorString("32", "Lorem ipsum dolor sit amet,")) + c.Write("consectetur " + ColorString("31;1", "adipiscing") + " elit.") case "/exit": channel.Close() case "/help": diff --git a/colors.go b/colors.go new file mode 100644 index 0000000..16e8ad9 --- /dev/null +++ b/colors.go @@ -0,0 +1,24 @@ +package main + +import ( + "math/rand" + "time" +) + +const RESET string = "\033[0m" +const BOLD string = "\033[1m" +const DIM string = "\033[2m" +const UNDERLINE string = "\033[4m" +const BLINK string = "\033[5m" +const INVERT string = "\033[7m" + +var colors = []string { "31", "32", "33", "34", "35", "36", "37", "91", "92", "93", "94", "95", "96", "97" } + +func RandomColor() string { + rand.Seed(time.Now().UTC().UnixNano()) + return colors[rand.Intn(len(colors))] +} + +func ColorString(format string, msg string) string { + return BOLD + "\033[" + format + "m" + msg + RESET +}