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...")