Update README.md with external Connected var.

This commit is contained in:
Alex Bramley 2011-08-22 17:16:32 +01:00
parent f3a2cf6fa6
commit 5c347008fb
1 changed files with 4 additions and 5 deletions

View File

@ -27,10 +27,9 @@ Synopsis:
c.SSL = true c.SSL = true
// Add handlers to do things here! // Add handlers to do things here!
// e.g. watching for disconnection from the server. // e.g. join a channel on connect.
connected := true c.AddHandler("connected",
c.AddHandler("disconnected", func(conn *irc.Conn, line *irc.Line) { conn.Join("#channel") })
func(conn *irc.Conn, line *irc.Line) { connected = false })
// Tell client to connect // Tell client to connect
if err := c.Connect("irc.freenode.net"); err != nil { if err := c.Connect("irc.freenode.net"); err != nil {
@ -38,7 +37,7 @@ Synopsis:
} }
// Loop until client gets disconnected, printing any errors // Loop until client gets disconnected, printing any errors
for connected { for c.Connected {
if err := <-c.Err; err != nil { if err := <-c.Err; err != nil {
fmt.Printf("goirc error: %s", err.String()) fmt.Printf("goirc error: %s", err.String())
} }