giph: add not found message

This commit is contained in:
Chris Sexton 2021-02-28 23:16:38 -05:00 committed by Chris Sexton
parent 5a7544d828
commit 67c88190ab
1 changed files with 5 additions and 0 deletions

View File

@ -40,6 +40,11 @@ func (p *GiphyPlugin) register() {
HelpText: "search for a giph",
Handler: func(r bot.Request) bool {
u, w, h := p.query(r.Values["search"])
if u == "" {
msg := fmt.Sprintf("Hey %v, I couldn't download that image you asked for.", r.Msg.User.Name)
p.b.Send(r.Conn, bot.Ephemeral, r.Msg.Channel, r.Msg.User.ID, msg)
return true
}
p.b.Send(r.Conn, bot.Message, r.Msg.Channel, "", bot.ImageAttachment{
URL: u,
AltTxt: fmt.Sprintf("%s: %s\nPowered by Giphy", r.Msg.User.Name, r.Values["search"]),