Use inline buttons instead of caption
This commit is contained in:
parent
a4471f449c
commit
c66e5c19d3
1 changed files with 19 additions and 3 deletions
22
main.go
22
main.go
|
@ -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
|
||||||
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue