From 0c7c53eee105ffc730bd33daba10fb632404319c Mon Sep 17 00:00:00 2001 From: "Andreas Renberg (IQAndreas)" Date: Sat, 13 Dec 2014 16:16:08 -0600 Subject: [PATCH 1/3] Use 'sysmsg' for private message system messages That way it gets nice and pretty colors --- client.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/client.go b/client.go index 27cba79..cf9a314 100644 --- a/client.go +++ b/client.go @@ -78,7 +78,7 @@ func NewClient(server *Server, conn *ssh.ServerConn) *Client { func (c *Client) ColoredName() string { return ColorString(c.Color, c.Name) } - +v func (c *Client) SysMsg(msg string, args ...interface{}) { c.Msg <- ContinuousFormat(SYSTEM_MESSAGE_FORMAT, "-> "+fmt.Sprintf(msg, args...)) } @@ -301,15 +301,15 @@ func (c *Client) handleShell(channel ssh.Channel) { case "/msg": /* Send a PM */ /* Make sure we have a recipient and a message */ if len(parts) < 2 { - c.Msg <- fmt.Sprintf("-> Missing $NAME from: /msg $NAME $MESSAGE") + c.SysMsg("Missing $NAME from: /msg $NAME $MESSAGE") break } else if len(parts) < 3 { - c.Msg <- fmt.Sprintf("-> Missing $MESSAGE from: /msg $NAME $MESSAGE") + c.SysMsg("Missing $MESSAGE from: /msg $NAME $MESSAGE") break } /* Ask the server to send the message */ if err := c.Server.Privmsg(parts[1], parts[2], c); nil != err { - c.Msg <- fmt.Sprintf("Unable to send message to %v: %v", parts[1], err) + c.SysMsg("Unable to send message to %v: %v", parts[1], err) } default: @@ -321,7 +321,7 @@ func (c *Client) handleShell(channel ssh.Channel) { msg := fmt.Sprintf("%s: %s", c.ColoredName(), line) /* Rate limit */ if time.Now().Sub(c.lastTX) < REQUIRED_WAIT { - c.Msg <- fmt.Sprintf("-> Rate limiting in effect.") + c.SysMsg("Rate limiting in effect.") continue } if c.IsSilenced() || len(msg) > 1000 || len(msg) == 0 { From 0632204304d50011e469bf7f684390e561eac819 Mon Sep 17 00:00:00 2001 From: "Andreas Renberg (IQAndreas)" Date: Sat, 13 Dec 2014 17:48:08 -0600 Subject: [PATCH 2/3] Use different formatting for private messages --- server.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server.go b/server.go index 0d1ec71..c84e8de 100644 --- a/server.go +++ b/server.go @@ -17,6 +17,7 @@ const MAX_NAME_LENGTH = 32 const HISTORY_LEN = 20 const SYSTEM_MESSAGE_FORMAT string = "\033[1;3;90m" +const PRIVATE_MESSAGE_FORMAT string = "\033[3m" const BEEP string = "\007" var RE_STRIP_TEXT = regexp.MustCompile("[^0-9A-Za-z_.-]") @@ -105,7 +106,7 @@ func (s *Server) Privmsg(nick, message string, sender *Client) error { return fmt.Errorf("no client with that nick") } /* Send the message */ - target.Msg <- fmt.Sprintf(BEEP+"[PM from %v] %v", sender.Name, message) + target.Msg <- fmt.Sprintf(BEEP+"[PM from %v] %s%v%s", sender.ColoredName(), PRIVATE_MESSAGE_FORMAT, message, RESET) logger.Debugf("PM from %v to %v: %v", sender.Name, nick, message) return nil } From 928f9ca4efe7a75a9f8dad3f480aec0993995a3c Mon Sep 17 00:00:00 2001 From: "Andreas Renberg (IQAndreas)" Date: Sat, 13 Dec 2014 17:50:12 -0600 Subject: [PATCH 3/3] Typo When did that get there? --- client.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client.go b/client.go index cf9a314..5e684f2 100644 --- a/client.go +++ b/client.go @@ -78,7 +78,7 @@ func NewClient(server *Server, conn *ssh.ServerConn) *Client { func (c *Client) ColoredName() string { return ColorString(c.Color, c.Name) } -v + func (c *Client) SysMsg(msg string, args ...interface{}) { c.Msg <- ContinuousFormat(SYSTEM_MESSAGE_FORMAT, "-> "+fmt.Sprintf(msg, args...)) }