Fix for tg api change AND scryfall api change
This commit is contained in:
parent
e09a2b473a
commit
a2d2189585
2 changed files with 37 additions and 23 deletions
42
main.go
42
main.go
|
@ -70,29 +70,43 @@ func webhook(update tg.APIUpdate) {
|
|||
}
|
||||
photos := make([]tg.APIInlineQueryResultPhoto, len(results.Data))
|
||||
for i, card := range results.Data {
|
||||
caption := fmt.Sprintf("EDHREC rank: #%d - cardmarket: € %s", card.EdhrecRank, card.Eur)
|
||||
buttons := []tg.APIInlineKeyboardButton{
|
||||
{
|
||||
Text: "Scryfall",
|
||||
URL: card.ScryfallURI,
|
||||
},
|
||||
}
|
||||
if card.RelatedUris.Edhrec != "" {
|
||||
buttons = append(buttons, tg.APIInlineKeyboardButton{
|
||||
Text: "EDHREC",
|
||||
URL: card.RelatedUris.Edhrec,
|
||||
})
|
||||
}
|
||||
if card.PurchaseUris.Cardmarket != "" {
|
||||
buttons = append(buttons, tg.APIInlineKeyboardButton{
|
||||
Text: "MCM",
|
||||
URL: card.PurchaseUris.Cardmarket,
|
||||
})
|
||||
}
|
||||
|
||||
captions := []string{}
|
||||
if card.EdhrecRank != nil {
|
||||
captions = append(captions, fmt.Sprintf("EDHREC rank: #%d", *card.EdhrecRank))
|
||||
}
|
||||
if card.Eur != "" {
|
||||
captions = append(captions, fmt.Sprintf("cardmarket: € %s", card.Eur))
|
||||
}
|
||||
photos[i] = tg.APIInlineQueryResultPhoto{
|
||||
Type: "photo",
|
||||
ResultID: card.ID,
|
||||
PhotoURL: card.ImageUris.Large,
|
||||
ThumbURL: card.ImageUris.Normal,
|
||||
Title: card.Name,
|
||||
Caption: caption,
|
||||
Caption: strings.Join(captions, " - "),
|
||||
Width: 672,
|
||||
Height: 936,
|
||||
ReplyMarkup: &tg.APIInlineKeyboardMarkup{
|
||||
InlineKeyboard: [][]tg.APIInlineKeyboardButton{{
|
||||
{
|
||||
Text: "Scryfall",
|
||||
URL: card.ScryfallURI,
|
||||
}, {
|
||||
Text: "EDHREC",
|
||||
URL: card.RelatedUris.Edhrec,
|
||||
}, {
|
||||
Text: "MCM",
|
||||
URL: card.PurchaseUris.Magiccardmarket,
|
||||
},
|
||||
}},
|
||||
InlineKeyboard: [][]tg.APIInlineKeyboardButton{buttons},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ type CardData struct {
|
|||
BorderCrop string `json:"border_crop"`
|
||||
} `json:"image_uris"`
|
||||
Eur string `json:"eur"`
|
||||
EdhrecRank int `json:"edhrec_rank"`
|
||||
EdhrecRank *int `json:"edhrec_rank"`
|
||||
RelatedUris struct {
|
||||
Gatherer string `json:"gatherer"`
|
||||
TcgplayerDecks string `json:"tcgplayer_decks"`
|
||||
|
@ -42,7 +42,7 @@ type CardData struct {
|
|||
Amazon string `json:"amazon"`
|
||||
Ebay string `json:"ebay"`
|
||||
Tcgplayer string `json:"tcgplayer"`
|
||||
Magiccardmarket string `json:"magiccardmarket"`
|
||||
Cardmarket string `json:"cardmarket"`
|
||||
Cardhoarder string `json:"cardhoarder"`
|
||||
CardKingdom string `json:"card_kingdom"`
|
||||
MtgoTraders string `json:"mtgo_traders"`
|
||||
|
|
Loading…
Reference in a new issue