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 + } } }