optional pass parameter

closes #5
This commit is contained in:
blackbeard420 2020-09-01 22:50:39 -04:00
parent dbfd78d4e1
commit 3c49159982
2 changed files with 5 additions and 3 deletions

6
irc.go
View File

@ -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
}

View File

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