Update example client.

This commit is contained in:
Alex Bramley 2011-11-06 05:08:28 +00:00
parent 85097043cf
commit 2389f03d45
1 changed files with 9 additions and 3 deletions

View File

@ -2,17 +2,23 @@ package main
import ( import (
irc "github.com/fluffle/goirc/client" irc "github.com/fluffle/goirc/client"
"flag"
"fmt" "fmt"
"os" "os"
"bufio" "bufio"
"strings" "strings"
) )
var host *string = flag.String("host", "irc.freenode.net", "IRC server")
var channel *string = flag.String("channel", "#go-nuts", "IRC channel")
func main() { func main() {
flag.Parse()
// create new IRC connection // create new IRC connection
c := irc.New("GoTest", "gotest", "GoBot") c := irc.New("GoTest", "gotest", "GoBot", true, nil, nil)
c.AddHandler("connected", c.AddHandler("connected",
func(conn *irc.Conn, line *irc.Line) { conn.Join("#go-nuts") }) func(conn *irc.Conn, line *irc.Line) { conn.Join(*channel) })
// Set up a handler to notify of disconnect events. // Set up a handler to notify of disconnect events.
quit := make(chan bool) quit := make(chan bool)
@ -74,7 +80,7 @@ func main() {
for !reallyquit { for !reallyquit {
// connect to server // connect to server
if err := c.Connect("irc.freenode.net"); err != nil { if err := c.Connect(*host); err != nil {
fmt.Printf("Connection error: %s\n", err) fmt.Printf("Connection error: %s\n", err)
return return
} }