parent
dbfd78d4e1
commit
3c49159982
6
irc.go
6
irc.go
@ -100,7 +100,7 @@ func (c *Connection) DelayedSend(sock net.Conn, dur time.Duration, channel, msg
|
|||||||
}
|
}
|
||||||
|
|
||||||
//NewConnection creates and connects an Connection
|
//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{}}
|
irc := &Connection{channels: chans, userList: map[string][]string{}}
|
||||||
|
|
||||||
sock, err := net.Dial("tcp", server)
|
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.Sock.Write([]byte(fmt.Sprintf("USER %s * * :%s\n", user, user)))
|
||||||
irc.SendNick(nick)
|
irc.SendNick(nick)
|
||||||
irc.curNick = 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
|
return irc
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestSimpleIrc(t *testing.T) {
|
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()
|
go con.Run()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user