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

@ -72,7 +72,7 @@ func splitMessage(msg string, splitLen int) (msgs []string) {
if idx < 0 { if idx < 0 {
idx = splitLen idx = splitLen
} }
msgs = append(msgs, msg[:idx] + "...") msgs = append(msgs, msg[:idx]+"...")
msg = msg[idx:] msg = msg[idx:]
} }
return append(msgs, msg) return append(msgs, msg)
@ -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...")