Allow Join command to take an optional key.

This commit is contained in:
Alex Bramley 2014-12-23 18:21:53 +00:00
parent 57eecccd1b
commit 2e39250355
2 changed files with 10 additions and 2 deletions

View File

@ -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) {

View File

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