Add support for server PASSWORD
This commit is contained in:
parent
bcec3b6f11
commit
998e1c3050
8
irc.go
8
irc.go
@ -58,7 +58,7 @@ func reader(irc *IRCConnection) {
|
|||||||
func writer(irc *IRCConnection) {
|
func writer(irc *IRCConnection) {
|
||||||
for {
|
for {
|
||||||
b := []byte(<-irc.pwrite)
|
b := []byte(<-irc.pwrite)
|
||||||
if b == nil {
|
if b == nil || irc.socket == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
_, err := irc.socket.Write(b)
|
_, err := irc.socket.Write(b)
|
||||||
@ -145,10 +145,13 @@ func (i *IRCConnection) Connect(server string) os.Error {
|
|||||||
go pinger(i)
|
go pinger(i)
|
||||||
i.pwrite <- fmt.Sprintf("NICK %s\r\n", i.nick)
|
i.pwrite <- fmt.Sprintf("NICK %s\r\n", i.nick)
|
||||||
i.pwrite <- fmt.Sprintf("USER %s 0.0.0.0 0.0.0.0 :%s\r\n", i.user, i.user)
|
i.pwrite <- fmt.Sprintf("USER %s 0.0.0.0 0.0.0.0 :%s\r\n", i.user, i.user)
|
||||||
|
if len(i.password) > 0 {
|
||||||
|
i.pwrite <- fmt.Sprintf("PASS %s\r\n", i.password)
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func IRC(nick string, user string) *IRCConnection {
|
func IRC(nick, user, password string) *IRCConnection {
|
||||||
irc := new(IRCConnection)
|
irc := new(IRCConnection)
|
||||||
irc.registered = false
|
irc.registered = false
|
||||||
irc.pread = make(chan string, 100)
|
irc.pread = make(chan string, 100)
|
||||||
@ -156,6 +159,7 @@ func IRC(nick string, user string) *IRCConnection {
|
|||||||
irc.Error = make(chan os.Error)
|
irc.Error = make(chan os.Error)
|
||||||
irc.nick = nick
|
irc.nick = nick
|
||||||
irc.user = user
|
irc.user = user
|
||||||
|
irc.password = password
|
||||||
irc.setupCallbacks()
|
irc.setupCallbacks()
|
||||||
return irc
|
return irc
|
||||||
}
|
}
|
||||||
|
@ -17,12 +17,13 @@ type IRCConnection struct {
|
|||||||
user string
|
user string
|
||||||
registered bool
|
registered bool
|
||||||
server string
|
server string
|
||||||
|
password string
|
||||||
|
|
||||||
events map[string][]func(*IRCEvent)
|
events map[string][]func(*IRCEvent)
|
||||||
|
|
||||||
lastMessage int64;
|
lastMessage int64
|
||||||
ticker <-chan int64;
|
ticker <-chan int64
|
||||||
ticker2 <-chan int64;
|
ticker2 <-chan int64
|
||||||
}
|
}
|
||||||
|
|
||||||
type IRCEvent struct {
|
type IRCEvent struct {
|
||||||
|
Loading…
Reference in New Issue
Block a user