From c66e5c19d31b17cf8c2aa8b6619565a69ad2508a Mon Sep 17 00:00:00 2001 From: Hamcha Date: Mon, 17 Sep 2018 14:42:07 +0200 Subject: [PATCH] Use inline buttons instead of caption --- main.go | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index 99cfe65..ce051d7 100644 --- a/main.go +++ b/main.go @@ -57,24 +57,40 @@ func webhook(update tg.APIUpdate) { if err != nil { fmt.Println(err) // DO SOMETHING + return } photos := make([]tg.APIInlineQueryResultPhoto, len(results.Data)) for i, card := range results.Data { - caption := fmt.Sprintf("Scryfall - EDHREC (#%d) - cardmarket (%s €)", card.ScryfallURI, card.RelatedUris.Edhrec, card.EdhrecRank, card.PurchaseUris.Magiccardmarket, card.Eur) photos[i] = tg.APIInlineQueryResultPhoto{ Type: "photo", ResultID: card.ID, PhotoURL: card.ImageUris.Large, ThumbURL: card.ImageUris.Normal, Title: card.Name, - Caption: caption, + ReplyMarkup: []tg.APIInlineKeyboardButton{ + { + Text: "Scryfall", + URL: card.ScryfallURI, + }, { + Text: fmt.Sprintf("EDHREC (#%d)", card.EdhrecRank), + URL: card.RelatedUris.Edhrec, + }, { + Text: fmt.Sprintf("Cardmarket (%s €)", card.ScryfallURI), + URL: card.PurchaseUris.Magiccardmarket, + }, + }, } } - api.AnswerInlineQuery(tg.InlineQueryResponse{ + err = api.AnswerInlineQuery(tg.InlineQueryResponse{ QueryID: update.Inline.QueryID, Results: photos, }) + if err != nil { + fmt.Println(err) + // DO SOMETHING + return + } }() }