diff --git a/bot/helpers.go b/bot/helpers.go index 6ac9409..a153654 100644 --- a/bot/helpers.go +++ b/bot/helpers.go @@ -17,7 +17,7 @@ import ( "github.com/arachnist/gorepost/irc" ) -var elementNotFound = errors.New("Element not found in document") +var errElementNotFound = errors.New("element not found in document") func httpGet(l string) ([]byte, error) { var buf []byte @@ -71,9 +71,9 @@ func httpGetXpath(l, x string) (string, error) { if len(sr) > 0 { return sr[0].InnerHtml(), nil - } else { - return "", elementNotFound } + + return "", errElementNotFound } func reply(msg irc.Message, text string) irc.Message { @@ -83,11 +83,11 @@ func reply(msg irc.Message, text string) irc.Message { Params: []string{msg.Prefix.Name}, Trailing: text, } - } else { - return irc.Message{ - Command: "PRIVMSG", - Params: msg.Params, - Trailing: text, - } + } + + return irc.Message{ + Command: "PRIVMSG", + Params: msg.Params, + Trailing: text, } } diff --git a/bot/kotki.go b/bot/kotki.go index ce2419c..e4d1163 100644 --- a/bot/kotki.go +++ b/bot/kotki.go @@ -13,10 +13,10 @@ import ( "github.com/arachnist/gorepost/irc" ) -var notAnError = errors.New("Not an error") +var errNotReally = errors.New("not an error") func redirectError(*http.Request, []*http.Request) error { - return notAnError + return errNotReally } func kotki(output chan irc.Message, msg irc.Message) { diff --git a/bot/urltitle.go b/bot/urltitle.go index 34fb0c1..39e7c34 100644 --- a/bot/urltitle.go +++ b/bot/urltitle.go @@ -17,12 +17,12 @@ import ( var trimTitle *regexp.Regexp -func getUrlTitle(l string) string { +func getURLTitle(l string) string { title, err := httpGetXpath(l, "//head/title") - if err == elementNotFound { + if err == errElementNotFound { return "no title" } else if err != nil { - return fmt.Sprintf("error:", err) + return fmt.Sprint("error:", err) } return string(trimTitle.ReplaceAll([]byte(title), []byte{' '})[:]) @@ -42,9 +42,9 @@ func linktitle(output chan irc.Message, msg irc.Message) { } if b { - t := getUrlTitle(s) + t := getURLTitle(s) if t != "no title" { - r = append(r, getUrlTitle(s)) + r = append(r, t) } } }