package ircclient_test import ( "fmt" ircclient "git.red-green.com/RedGreen/irc-client" ) func ExampleIRCClient_Connect() { var FromIRC chan ircclient.IRCMsg = make(chan ircclient.IRCMsg) var config ircclient.IRCConfig = ircclient.IRCConfig{Port: 6667, Hostname: "irc.libera.chat", Nick: "go-bot-test", Username: "gobot", Realname: "Bot Testing", AutoJoin: []string{"##bugz"}, } var irc ircclient.IRCClient = ircclient.IRCClient{IRCConfig: config, ReadChannel: FromIRC} irc.Connect() defer irc.Close() var Msg ircclient.IRCMsg for Msg = range irc.ReadChannel { // View all the commands: // fmt.Printf("%#v\n", Msg) switch Msg.Cmd { case "EndMOTD": // Ok! we're connected. fmt.Println("Connected") break case "333": // Joined channel, say something and quit. irc.Msg("##bugz", "Hello!") irc.WriteTo("", "QUIT") break case "PRIVMSG": break } } // Uncomment to test connection // Output: Connected }