update exampes to use reply methods

This commit is contained in:
Liam Stanley 2017-06-07 06:49:13 -04:00
parent 6c8215c842
commit 42c9c3d687

@ -5,7 +5,6 @@
package girc_test package girc_test
import ( import (
"fmt"
"log" "log"
"os" "os"
"strings" "strings"
@ -62,7 +61,8 @@ func Example_simple() {
client.Handlers.Add(girc.PRIVMSG, func(c *girc.Client, e girc.Event) { client.Handlers.Add(girc.PRIVMSG, func(c *girc.Client, e girc.Event) {
if strings.Contains(e.Trailing, "hello") { if strings.Contains(e.Trailing, "hello") {
c.Commands.Message(e.Params[0], "hello world!") c.Commands.ReplyTo(e, "hello world!")
return
} }
if strings.Contains(e.Trailing, "quit") { if strings.Contains(e.Trailing, "quit") {
@ -101,7 +101,7 @@ func Example_commands() {
client.Handlers.Add(girc.PRIVMSG, func(c *girc.Client, e girc.Event) { client.Handlers.Add(girc.PRIVMSG, func(c *girc.Client, e girc.Event) {
if strings.HasPrefix(e.Trailing, "!hello") { if strings.HasPrefix(e.Trailing, "!hello") {
c.Commands.Message(e.Params[0], "hello world!") c.Commands.ReplyTo(e, girc.Fmt("{b}hello{b} {blue}world{c}!"))
return return
} }
@ -115,11 +115,3 @@ func Example_commands() {
log.Fatalf("an error occurred while attempting to connect to %s: %s", client.Server(), err) log.Fatalf("an error occurred while attempting to connect to %s: %s", client.Server(), err)
} }
} }
func ExampleGlob() {
fmt.Println(girc.Glob("The quick brown fox jumps over the lazy dog", "*brown fox*")) // True.
fmt.Println(girc.Glob("The quick brown fox jumps over the lazy dog", "*yellow dog*")) // False.
// Output:
// true
// false
}