Update README, fix whitespace fail.

This commit is contained in:
Alex Bramley 2011-10-06 21:33:02 +01:00
parent d119e6bca0
commit a4ac0dd1b7
1 changed files with 17 additions and 17 deletions

View File

@ -18,31 +18,31 @@ This will connect to freenode and join `#go-nuts` by default, so be careful ;-)
Synopsis: Synopsis:
import irc "github.com/fluffle/goirc/client" import irc "github.com/fluffle/goirc/client"
func main() { func main() {
c := irc.New("nick", "ident", "real name") c := irc.New("nick", "ident", "real name")
// Optionally, turn on debugging // Optionally, turn on debugging
c.Debug = true c.Debug = true
// Optionally, enable SSL // Optionally, enable SSL
c.SSL = true c.SSL = true
// Add handlers to do things here! // Add handlers to do things here!
// e.g. join a channel on connect. // e.g. join a channel on connect.
c.AddHandler("connected", c.AddHandler("connected",
func(conn *irc.Conn, line *irc.Line) { conn.Join("#channel") }) func(conn *irc.Conn, line *irc.Line) { conn.Join("#channel") })
// And a signal on disconnect
quit := make(chan bool)
c.AddHandler("disconnected),
func(conn *irc.Conn, line *irc.Line) { quit <- true }
// 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 {
fmt.Printf("Connection error: %s\n", err.String()) fmt.Printf("Connection error: %s\n", err.String())
} }
// Loop until client gets disconnected, printing any errors // Wait for disconnect
for c.Connected { <-quit
if err := <-c.Err; err != nil { }
fmt.Printf("goirc error: %s", err.String())
}
}
}
The test client provides a good (if basic) example of how to use the framework. The test client provides a good (if basic) example of how to use the framework.
Reading `client/handlers.go` gives a more in-depth look at how handlers can be Reading `client/handlers.go` gives a more in-depth look at how handlers can be