mirror of https://github.com/fluffle/goirc
Update README.md with external Connected var.
This commit is contained in:
parent
f3a2cf6fa6
commit
5c347008fb
|
@ -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())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue