diff --git a/client.go b/client.go index 5ab330d..4909d97 100644 --- a/client.go +++ b/client.go @@ -20,10 +20,12 @@ 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: /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 ` @@ -54,6 +56,7 @@ type Client struct { termHeight int silencedUntil time.Time lastTX time.Time + beepMe bool } func NewClient(server *Server, conn *ssh.ServerConn) *Client { @@ -160,6 +163,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 == "" { @@ -227,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.") diff --git a/server.go b/server.go index 4ff328d..c7c9aef 100644 --- a/server.go +++ b/server.go @@ -94,7 +94,7 @@ func (s *Server) Broadcast(msg string, except *Client) { continue } /* Add an ascii BEL to ding clients when they're mentioned */ - if strings.HasPrefix(msg, fmt.Sprintf("%s:", client.Name)) { + if client.beepMe && strings.Contains(msg, client.Name) { client.Msg <- msg + BEEP } else { client.Msg <- msg