diff --git a/client/commands.go b/client/commands.go index 20e3a66..164e04e 100644 --- a/client/commands.go +++ b/client/commands.go @@ -96,8 +96,14 @@ func (conn *Conn) User(ident, name string) { conn.Raw(USER + " " + ident + " 12 * :" + name) } -// Join() sends a JOIN command to the server -func (conn *Conn) Join(channel string) { conn.Raw(JOIN + " " + channel) } +// Join() sends a JOIN command to the server with an optional key +func (conn *Conn) Join(channel string, key ...string) { + k := "" + if len(key) > 0 { + k = " " + key[0] + } + conn.Raw(JOIN + " " + channel + k) +} // Part() sends a PART command to the server with an optional part message func (conn *Conn) Part(channel string, message ...string) { diff --git a/client/commands_test.go b/client/commands_test.go index dabaf61..a4d457e 100644 --- a/client/commands_test.go +++ b/client/commands_test.go @@ -97,6 +97,8 @@ func TestClientCommands(t *testing.T) { c.Join("#foo") s.nc.Expect("JOIN #foo") + c.Join("#foo bar") + s.nc.Expect("JOIN #foo bar") c.Part("#foo") s.nc.Expect("PART #foo")