Add support to join a channel with a given key

This commit is contained in:
kyle 2014-12-22 13:28:43 +02:00
parent 5e5f5f0253
commit 3fc8380afb
2 changed files with 7 additions and 1 deletions

View File

@ -99,6 +99,9 @@ func (conn *Conn) User(ident, name string) {
// Join() sends a JOIN command to the server // Join() sends a JOIN command to the server
func (conn *Conn) Join(channel string) { conn.Raw(JOIN + " " + channel) } 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 // Part() sends a PART command to the server with an optional part message
func (conn *Conn) Part(channel string, message ...string) { func (conn *Conn) Part(channel string, message ...string) {
msg := strings.Join(message, " ") msg := strings.Join(message, " ")

View File

@ -98,6 +98,9 @@ func TestClientCommands(t *testing.T) {
c.Join("#foo") c.Join("#foo")
s.nc.Expect("JOIN #foo") s.nc.Expect("JOIN #foo")
c.JoinKey("#foo", "bar")
s.nc.Expect("JOIN #foo bar")
c.Part("#foo") c.Part("#foo")
s.nc.Expect("PART #foo") s.nc.Expect("PART #foo")
c.Part("#foo", "Screw you guys...") c.Part("#foo", "Screw you guys...")