From 820372a975b8ff498ea5c2aa1947a63d68e2c8b7 Mon Sep 17 00:00:00 2001 From: Andrey Petrov Date: Sat, 13 Dec 2014 11:25:54 -0800 Subject: [PATCH] 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.")