diff --git a/plugins/leftpad/leftpad.go b/plugins/leftpad/leftpad.go index 533f6a8..0a5a190 100644 --- a/plugins/leftpad/leftpad.go +++ b/plugins/leftpad/leftpad.go @@ -5,10 +5,10 @@ package leftpad import ( "encoding/json" - "fmt" "io/ioutil" "log" "net/http" + "net/url" "strings" "github.com/velour/catbase/bot" @@ -39,14 +39,16 @@ func (p *LeftpadPlugin) Message(message bot.Message) bool { if len(parts) > 3 && parts[0] == "leftpad" { padchar := parts[1] length := parts[2] - text := parts[3:][0] - url := fmt.Sprintf("https://api.left-pad.io/?str=%s&len=%s&ch=%s", - text, - length, - padchar, - ) + text := strings.Join(parts[3:], " ") + url, _ := url.Parse("https://api.left-pad.io") + q := url.Query() + q.Set("str", text) + q.Set("len", length) + q.Set("ch", padchar) + url.RawQuery = q.Encode() + log.Printf("Requesting leftpad url: %s", url) - resp, err := http.Get(url) + resp, err := http.Get(url.String()) if err != nil { p.bot.SendMessage(message.Channel, err.Error()) return true