diff --git a/irc.go b/irc.go index 343b814..8ea21b5 100644 --- a/irc.go +++ b/irc.go @@ -100,7 +100,7 @@ func (c *Connection) DelayedSend(sock net.Conn, dur time.Duration, channel, msg } //NewConnection creates and connects an Connection -func NewConnection(server, nick, user, pass string, chans []string) *Connection { +func NewConnection(server, nick, user string, pass *string, chans []string) *Connection { irc := &Connection{channels: chans, userList: map[string][]string{}} sock, err := net.Dial("tcp", server) @@ -111,7 +111,9 @@ func NewConnection(server, nick, user, pass string, chans []string) *Connection irc.Sock.Write([]byte(fmt.Sprintf("USER %s * * :%s\n", user, user))) irc.SendNick(nick) irc.curNick = nick - irc.Sock.Write([]byte(fmt.Sprintf("PASS %s\n", pass))) + if pass != nil { + irc.Sock.Write([]byte(fmt.Sprintf("PASS %s\n", *pass))) + } return irc } diff --git a/irc_test.go b/irc_test.go index 6064a51..96be70a 100644 --- a/irc_test.go +++ b/irc_test.go @@ -8,7 +8,7 @@ import ( ) func TestSimpleIrc(t *testing.T) { - con := NewConnection("thc420.xyz:6667", "irc-go", "irc-go", "", []string{"#freedom"}) + con := NewConnection("thc420.xyz:6667", "irc-go", "irc-go", nil, []string{"#freedom"}) go con.Run()