From 460b81be2eccdeda0c4950445423c08ff76fdbd6 Mon Sep 17 00:00:00 2001 From: Andrey Petrov Date: Sat, 13 Dec 2014 11:16:47 -0800 Subject: [PATCH 1/3] Removing beeps for now. --- server.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/server.go b/server.go index 4ff328d..b457e97 100644 --- a/server.go +++ b/server.go @@ -93,12 +93,7 @@ func (s *Server) Broadcast(msg string, except *Client) { if except != nil && client == except { continue } - /* Add an ascii BEL to ding clients when they're mentioned */ - if strings.HasPrefix(msg, fmt.Sprintf("%s:", client.Name)) { - client.Msg <- msg + BEEP - } else { - client.Msg <- msg - } + client.Msg <- msg } } From 8b4f05b344396301586ff4fc0eea3dd326571f58 Mon Sep 17 00:00:00 2001 From: Andrey Petrov Date: Sat, 13 Dec 2014 11:22:43 -0800 Subject: [PATCH 2/3] Beep command. --- client.go | 9 +++++++++ server.go | 7 ++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/client.go b/client.go index 5ab330d..99e8477 100644 --- a/client.go +++ b/client.go @@ -20,6 +20,7 @@ const HELP_TEXT string = SYSTEM_MESSAGE_FORMAT + `-> Available commands: /nick $NAME - Rename yourself to a new name /whois $NAME - Display information about another connected user /msg $NAME $MESSAGE + /beep - Enable BEL notifications on mention. ` + RESET const OP_HELP_TEXT string = SYSTEM_MESSAGE_FORMAT + `-> Available operator commands: @@ -54,6 +55,7 @@ type Client struct { termHeight int silencedUntil time.Time lastTX time.Time + beepMe bool } func NewClient(server *Server, conn *ssh.ServerConn) *Client { @@ -160,6 +162,13 @@ func (c *Client) handleShell(channel ssh.Channel) { c.WriteLines(strings.Split(ABOUT_TEXT, "\n")) case "/uptime": c.Write(c.Server.Uptime()) + case "/beep": + c.beepMe = !c.beepMe + if c.beepMe { + c.SysMsg("I'll beep you good.") + } else { + c.SysMsg("No more beeps. :(") + } case "/me": me := strings.TrimLeft(line, "/me") if me == "" { diff --git a/server.go b/server.go index b457e97..c7c9aef 100644 --- a/server.go +++ b/server.go @@ -93,7 +93,12 @@ func (s *Server) Broadcast(msg string, except *Client) { if except != nil && client == except { continue } - client.Msg <- msg + /* Add an ascii BEL to ding clients when they're mentioned */ + if client.beepMe && strings.Contains(msg, client.Name) { + client.Msg <- msg + BEEP + } else { + client.Msg <- msg + } } } From 820372a975b8ff498ea5c2aa1947a63d68e2c8b7 Mon Sep 17 00:00:00 2001 From: Andrey Petrov Date: Sat, 13 Dec 2014 11:25:54 -0800 Subject: [PATCH 3/3] A kick in the pants. --- client.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/client.go b/client.go index 99e8477..4909d97 100644 --- a/client.go +++ b/client.go @@ -25,6 +25,7 @@ const HELP_TEXT string = SYSTEM_MESSAGE_FORMAT + `-> Available commands: const OP_HELP_TEXT string = SYSTEM_MESSAGE_FORMAT + `-> Available operator commands: /ban $NAME - Banish a user from the chat + /kick $NAME - Kick em' out. /op $NAME - Promote a user to server operator /silence $NAME - Revoke a user's ability to speak ` @@ -236,6 +237,21 @@ func (c *Client) handleShell(channel ssh.Channel) { c.Server.Op(fingerprint) } } + case "/kick": + if !c.Server.IsOp(c) { + c.SysMsg("You're not an admin.") + } else if len(parts) != 2 { + c.SysMsg("Missing $NAME from: /kick $NAME") + } else { + client := c.Server.Who(parts[1]) + if client == nil { + c.SysMsg("No such name: %s", parts[1]) + } else { + client.SysMsg2("Kicked by %s.", c.ColoredName()) + client.Conn.Close() + c.Server.Broadcast(fmt.Sprintf("* %s was kicked by %s", parts[1], c.ColoredName()), nil) + } + } case "/silence": if !c.Server.IsOp(c) { c.SysMsg("You're not an admin.")