Use inline buttons instead of caption

This commit is contained in:
Hamcha 2018-09-17 14:42:07 +02:00
parent a4471f449c
commit c66e5c19d3
Signed by: hamcha
GPG key ID: A40413D21021EAEE

22
main.go
View file

@ -57,24 +57,40 @@ func webhook(update tg.APIUpdate) {
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
// DO SOMETHING // DO SOMETHING
return
} }
photos := make([]tg.APIInlineQueryResultPhoto, len(results.Data)) photos := make([]tg.APIInlineQueryResultPhoto, len(results.Data))
for i, card := range results.Data { for i, card := range results.Data {
caption := fmt.Sprintf("<a href=\"%s\">Scryfall</a> - <a href=\"%s\">EDHREC</a> (#%d) - <a href=\"%s\">cardmarket</a> (%s €)", card.ScryfallURI, card.RelatedUris.Edhrec, card.EdhrecRank, card.PurchaseUris.Magiccardmarket, card.Eur)
photos[i] = tg.APIInlineQueryResultPhoto{ photos[i] = tg.APIInlineQueryResultPhoto{
Type: "photo", Type: "photo",
ResultID: card.ID, ResultID: card.ID,
PhotoURL: card.ImageUris.Large, PhotoURL: card.ImageUris.Large,
ThumbURL: card.ImageUris.Normal, ThumbURL: card.ImageUris.Normal,
Title: card.Name, 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, QueryID: update.Inline.QueryID,
Results: photos, Results: photos,
}) })
if err != nil {
fmt.Println(err)
// DO SOMETHING
return
}
}() }()
} }