import ( "github.com/fluffle/goirc/client" "fmt" ) func main() { cfg := client.NewConfig("nickname") cfg.Server = "irc.freenode.net:6667" cfg.NewNick = func(n string) string { return n + "^" } c := client.New(cfg) c.HandleFunc("connected", func(conn *client.Conn, line *client.Line) { conn.Join("#channel") }) err := c.Connect() if err != nil { fmt.Printf("Connection error: %s\n", err.Error()) } defer c.Quit() <-make(chan struct{}) }
import ( "github.com/fluffle/goirc/client" "fmt" ) func main() { cfg := client.NewConfig("nickname") cfg.Server = "irc.freenode.net:6667" c := client.New(cfg) c.HandleFunc("connected", func(conn *client.Conn, line *client.Line) { conn.Join("#channel") }) c.HandleFunc("PRIVMSG", func(conn *client.Conn, line *client.Line) { fmt.Printf("[%s] %s: %s\n", line.Target(), line.Nick, line.Args[1]) }) err := c.Connect() if err != nil { fmt.Printf("Connection error: %s\n", err.Error()) } defer c.Quit() <-make(chan struct{}) }This example connects to an IRC server, joins a channel, and prints out any messages received in the channel. It uses the "PRIVMSG" event handler to handle "privmsg" messages.