From 25dc161348d7ea224bd6a744cf8f6430ddc95990 Mon Sep 17 00:00:00 2001 From: Ken Piper Date: Sat, 13 Dec 2014 10:57:38 -0500 Subject: [PATCH 1/2] Block the broadcast of an empty message --- client.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client.go b/client.go index 33bd4f7..7b41907 100644 --- a/client.go +++ b/client.go @@ -56,7 +56,7 @@ func NewClient(server *Server, conn *ssh.ServerConn) *Client { } func (c *Client) ColoredName() string { - return ColorString(c.Color, c.Name) + return ColorString(c.Color, c.Name) } func (c *Client) Write(msg string) { @@ -229,7 +229,7 @@ func (c *Client) handleShell(channel ssh.Channel) { } msg := fmt.Sprintf("%s: %s", c.ColoredName(), line) - if c.IsSilenced() || len(msg) > 1000 { + if c.IsSilenced() || len(msg) > 1000 || len(line) < 1 { c.Msg <- fmt.Sprintf("-> Message rejected.") continue } From 273b61c21b85e1ef92ab26b67c8902910303a03e Mon Sep 17 00:00:00 2001 From: Ken Piper Date: Sat, 13 Dec 2014 11:30:54 -0500 Subject: [PATCH 2/2] Better documentation for /help Also added op help text if the user issuing the command is an op --- client.go | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/client.go b/client.go index 7b41907..7bafe31 100644 --- a/client.go +++ b/client.go @@ -12,12 +12,18 @@ import ( const MSG_BUFFER int = 10 const HELP_TEXT string = `-> Available commands: - /about - /exit - /help - /list - /nick $NAME - /whois $NAME + /about - About this chat + /exit - Exit the chat + /help - Show this help text + /list - List the users that are currently connected + /me $ACTION - Show yourself doing an action + /nick $NAME - Rename yourself to a new name + /whois $NAME - Display information about another connected user +` +const OP_HELP_TEXT string = `-> Available operator commands: + /ban $NAME - Banish a user from the chat + /op $NAME - Promote a user to server operator + /silence $NAME - Revoke a user's ability to speak ` const ABOUT_TEXT string = `-> ssh-chat is made by @shazow. @@ -132,6 +138,9 @@ func (c *Client) handleShell(channel ssh.Channel) { channel.Close() case "/help": c.WriteLines(strings.Split(HELP_TEXT, "\n")) + if c.Server.IsOp(c) { + c.WriteLines(strings.Split(OP_HELP_TEXT, "\n")) + } case "/about": c.WriteLines(strings.Split(ABOUT_TEXT, "\n")) case "/me":