From 3fc8380afbd0c2a4fdacf23a2ad189372064361b Mon Sep 17 00:00:00 2001 From: kyle Date: Mon, 22 Dec 2014 13:28:43 +0200 Subject: [PATCH] Add support to join a channel with a given key --- client/commands.go | 5 ++++- client/commands_test.go | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/client/commands.go b/client/commands.go index 20e3a66..9584dbe 100644 --- a/client/commands.go +++ b/client/commands.go @@ -72,7 +72,7 @@ func splitMessage(msg string, splitLen int) (msgs []string) { if idx < 0 { idx = splitLen } - msgs = append(msgs, msg[:idx] + "...") + msgs = append(msgs, msg[:idx]+"...") msg = msg[idx:] } return append(msgs, msg) @@ -99,6 +99,9 @@ func (conn *Conn) User(ident, name string) { // Join() sends a JOIN command to the server func (conn *Conn) Join(channel string) { conn.Raw(JOIN + " " + channel) } +// JoinKey() sends a JOIN command to the server with a key +func (conn *Conn) JoinKey(channel string, key string) { conn.Raw(JOIN + " " + channel + " " + key) } + // Part() sends a PART command to the server with an optional part message func (conn *Conn) Part(channel string, message ...string) { msg := strings.Join(message, " ") diff --git a/client/commands_test.go b/client/commands_test.go index dabaf61..bfd88ba 100644 --- a/client/commands_test.go +++ b/client/commands_test.go @@ -98,6 +98,9 @@ func TestClientCommands(t *testing.T) { c.Join("#foo") s.nc.Expect("JOIN #foo") + c.JoinKey("#foo", "bar") + s.nc.Expect("JOIN #foo bar") + c.Part("#foo") s.nc.Expect("PART #foo") c.Part("#foo", "Screw you guys...")