meme: fix a crash

This commit is contained in:
Chris Sexton 2020-05-01 09:11:34 -04:00 committed by Chris Sexton
parent cee267dbb8
commit 699532d789
1 changed files with 8 additions and 2 deletions

View File

@ -83,13 +83,19 @@ func (p *MemePlugin) registerWeb(c bot.Connector) {
channel := r.PostForm.Get("channel_id") channel := r.PostForm.Get("channel_id")
channelName := r.PostForm.Get("channel_name") channelName := r.PostForm.Get("channel_name")
from := r.PostForm.Get("user_name") from := r.PostForm.Get("user_name")
text := r.PostForm.Get("text")
log.Debug().Msgf("channel: %s", channel) log.Debug().Msgf("channel: %s", channel)
parts := strings.SplitN(r.PostForm.Get("text"), " ", 2) parts := strings.SplitN(text, " ", 2)
if len(parts) != 2 {
log.Debug().Msgf("Bad meme request: %s, %s", from, text)
p.bot.Send(c, bot.Message, channel, fmt.Sprintf("%s tried to send me a bad meme request.", from))
return
}
isCmd, message := bot.IsCmd(p.c, parts[1]) isCmd, message := bot.IsCmd(p.c, parts[1])
format := parts[0] format := parts[0]
log.Debug().Strs("parts", parts).Msgf("Meme:\n%+v", r.PostForm.Get("text")) log.Debug().Strs("parts", parts).Msgf("Meme:\n%+v", text)
w.WriteHeader(200) w.WriteHeader(200)
w.Write(nil) w.Write(nil)