mirror of https://github.com/fluffle/goirc
Merge pull request #68 from ripcurld00d/readme_update
Update the README.md file to reflect current reality.
This commit is contained in:
commit
2c26d1db08
19
README.md
19
README.md
|
@ -16,7 +16,13 @@ old `go1` API.
|
||||||
|
|
||||||
Synopsis:
|
Synopsis:
|
||||||
|
|
||||||
import irc "github.com/fluffle/goirc/client"
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
irc "github.com/fluffle/goirc/client"
|
||||||
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
// Creating a simple IRC client is simple.
|
// Creating a simple IRC client is simple.
|
||||||
|
@ -27,20 +33,20 @@ Synopsis:
|
||||||
cfg.SSL = true
|
cfg.SSL = true
|
||||||
cfg.Server = "irc.freenode.net:7000"
|
cfg.Server = "irc.freenode.net:7000"
|
||||||
cfg.NewNick = func(n string) string { return n + "^" }
|
cfg.NewNick = func(n string) string { return n + "^" }
|
||||||
c := irc.Client(cfg)
|
c = irc.Client(cfg)
|
||||||
|
|
||||||
// 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.HandleFunc("connected",
|
c.HandleFunc(irc.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
|
// And a signal on disconnect
|
||||||
quit := make(chan bool)
|
quit := make(chan bool)
|
||||||
c.HandleFunc("disconnected",
|
c.HandleFunc(irc.DISCONNECTED,
|
||||||
func(conn *irc.Conn, line *irc.Line) { quit <- true })
|
func(conn *irc.Conn, line *irc.Line) { quit <- true })
|
||||||
|
|
||||||
// Tell client to connect.
|
// Tell client to connect.
|
||||||
if err := c.Connect(); err != nil {
|
if err := c.Connect(); err != nil {
|
||||||
fmt.Printf("Connection error: %s\n", err.String())
|
fmt.Printf("Connection error: %s\n", err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
// With a "simple" client, set Server before calling Connect...
|
// With a "simple" client, set Server before calling Connect...
|
||||||
|
@ -48,7 +54,7 @@ Synopsis:
|
||||||
|
|
||||||
// ... or, use ConnectTo instead.
|
// ... or, use ConnectTo instead.
|
||||||
if err := c.ConnectTo("irc.freenode.net"); err != nil {
|
if err := c.ConnectTo("irc.freenode.net"); err != nil {
|
||||||
fmt.Printf("Connection error: %s\n", err.String())
|
fmt.Printf("Connection error: %s\n", err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait for disconnect
|
// Wait for disconnect
|
||||||
|
@ -94,4 +100,3 @@ Contributions gratefully received from:
|
||||||
- [StalkR](https://github.com/StalkR)
|
- [StalkR](https://github.com/StalkR)
|
||||||
- [sztanpet](https://github.com/sztanpet)
|
- [sztanpet](https://github.com/sztanpet)
|
||||||
- [wathiede](https://github.com/wathiede)
|
- [wathiede](https://github.com/wathiede)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue