From 15ef0a57b20437078d1c1d67740d0ff059da2d42 Mon Sep 17 00:00:00 2001 From: Leon Klingele Date: Sun, 4 Jan 2015 11:15:55 +0100 Subject: [PATCH 1/4] Added /unban command to unban a banned fingerprint --- client.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/client.go b/client.go index 2a14455..7f738a2 100644 --- a/client.go +++ b/client.go @@ -309,6 +309,21 @@ func (c *Client) handleShell(channel ssh.Channel) { c.Server.Broadcast(fmt.Sprintf("* %s was banned by %s", parts[1], c.ColoredName()), nil) } } + case "/unban": + if !c.Server.IsOp(c) { + c.SysMsg("You're not an admin.") + } else if len(parts) != 2 { + c.SysMsg("Missing $FINGERPRINT from: /unban $FINGERPRINT") + } else { + fingerprint := parts[1] + isBanned := c.Server.IsBanned(fingerprint) + if !isBanned { + c.SysMsg("No such banned fingerprint: %s", fingerprint) + } else { + c.Server.Unban(fingerprint) + c.Server.Broadcast(fmt.Sprintf("* %s was unbanned by %s", fingerprint, c.ColoredName()), nil) + } + } case "/op": if !c.Server.IsOp(c) { c.SysMsg("You're not an admin.") From 8a68cc51d9b5b5b3224440400559cbb58079c832 Mon Sep 17 00:00:00 2001 From: Leon Klingele Date: Sun, 4 Jan 2015 11:16:38 +0100 Subject: [PATCH 2/4] Added /banned command to list banned fingerprints --- client.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/client.go b/client.go index 7f738a2..50f503c 100644 --- a/client.go +++ b/client.go @@ -324,6 +324,16 @@ func (c *Client) handleShell(channel ssh.Channel) { c.Server.Broadcast(fmt.Sprintf("* %s was unbanned by %s", fingerprint, c.ColoredName()), nil) } } + case "/banned": + if !c.Server.IsOp(c) { + c.SysMsg("You're not an admin.") + } else if len(parts) != 1 { + c.SysMsg("Too many arguments for /banned") + } else { + for fingerprint, _ := range c.Server.bannedPK { + c.SysMsg("Banned fingerprint: %s", fingerprint) + } + } case "/op": if !c.Server.IsOp(c) { c.SysMsg("You're not an admin.") From c244efe3d3e3222b6daa30c39fb4372b2a5e967d Mon Sep 17 00:00:00 2001 From: Leon Klingele Date: Sun, 4 Jan 2015 12:21:48 +0100 Subject: [PATCH 3/4] gofmt --- client.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client.go b/client.go index 50f503c..7905316 100644 --- a/client.go +++ b/client.go @@ -330,7 +330,7 @@ func (c *Client) handleShell(channel ssh.Channel) { } else if len(parts) != 1 { c.SysMsg("Too many arguments for /banned") } else { - for fingerprint, _ := range c.Server.bannedPK { + for fingerprint := range c.Server.bannedPK { c.SysMsg("Banned fingerprint: %s", fingerprint) } } From cc42f0aa7a9434c38836a1e3e1e47995acc7ce33 Mon Sep 17 00:00:00 2001 From: Leon Klingele Date: Sun, 4 Jan 2015 12:23:35 +0100 Subject: [PATCH 4/4] Added HelpText for new commands --- client.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/client.go b/client.go index 7905316..d29b5b6 100644 --- a/client.go +++ b/client.go @@ -37,6 +37,8 @@ const ( // OpHelpText is the additional text returned by /help if the client is an Op OpHelpText string = `Available operator commands: /ban $NAME - Banish a user from the chat + /unban $FINGERPRINT - Unban a fingerprint + /banned - List all banned fingerprints /kick $NAME - Kick em' out. /op $NAME - Promote a user to server operator. /silence $NAME - Revoke a user's ability to speak.