From a7120e7b07599b0ab5b4efc88b37ab5602bacf65 Mon Sep 17 00:00:00 2001 From: Liam Stanley Date: Sun, 5 Feb 2017 05:23:37 -0500 Subject: [PATCH] remove third example --- client_test.go | 76 -------------------------------------------------- 1 file changed, 76 deletions(-) diff --git a/client_test.go b/client_test.go index 0bd62db..9b99256 100644 --- a/client_test.go +++ b/client_test.go @@ -5,10 +5,7 @@ package girc_test import ( - "bufio" - "fmt" "log" - "os" "strings" "github.com/lrstanley/girc" @@ -86,76 +83,3 @@ func Example_commands() { client.Loop() } - -// A slightly more complex example which adds a terminal-based prompt where -// one can enter raw IRC commands, which will then be sent to the server. -func Example_prompt() { - conf := girc.Config{ - Server: "irc.byteirc.org", - Port: 6667, - Nick: "test", - User: "user", - Name: "Example bot", - } - channels := []string{"#dev"} - - client := girc.New(conf) - - client.Callbacks.Add(girc.CONNECTED, func(c *girc.Client, e girc.Event) { - c.Join(channels...) - }) - - client.Callbacks.Add(girc.PRIVMSG, func(c *girc.Client, e girc.Event) { - if strings.HasPrefix(e.Trailing, "!stop") { - c.Message(e.Params[0], "hello world!") - return - } - - if strings.HasPrefix(e.Trailing, "!stop") { - c.Quit("goodbye!") - c.Stop() - return - } - - if strings.HasPrefix(e.Trailing, "!restart") { - c.Reconnect() - return - } - }) - - if err := client.Connect(); err != nil { - log.Fatalf("an error occurred while attempting to connect to %s: %s", client.Server(), err) - } - - go client.Loop() - - // Everything after this line is just for fancy prompt stuff. Not needed. - reader := bufio.NewReader(os.Stdin) - - client.Callbacks.Add(girc.ALLEVENTS, func(c *girc.Client, e girc.Event) { - fmt.Print("\r> ") - }) - - for { - fmt.Print("\r> ") - input, _ := reader.ReadString('\n') - input = strings.TrimSpace(input) - if len(input) == 0 { - continue - } - - if input == "quit" { - client.Quit("g'day") - client.Stop() - os.Exit(0) - } - - e := girc.ParseEvent(input) - if e == nil { - fmt.Println("ERRONOUS INPUT") - continue - } - - client.Send(e) - } -}