diff --git a/main.go b/main.go index c94c146..e053740 100644 --- a/main.go +++ b/main.go @@ -96,11 +96,15 @@ func webhook(update tg.APIUpdate) { if card.Eur != "" { captions = append(captions, fmt.Sprintf("cardmarket: € %s", card.Eur)) } + face := card.ImageUris + if card.CardFaces != nil { + face = card.CardFaces[0].ImageUris + } photos[i] = tg.APIInlineQueryResultPhoto{ Type: "photo", ResultID: card.ID, - PhotoURL: card.ImageUris.Large, - ThumbURL: card.ImageUris.Normal, + PhotoURL: face.Large, + ThumbURL: face.Normal, Title: card.Name, Caption: strings.Join(captions, " - "), Width: 672, @@ -141,10 +145,19 @@ func webhook(update tg.APIUpdate) { if err != nil { errlist = append(errlist, cardname) } else { - cardmedia = append(cardmedia, tg.APIInputMediaPhoto{ - Type: "photo", - Media: card.ImageUris.Large, - }) + if card.CardFaces != nil { + for _, cardface := range card.CardFaces { + cardmedia = append(cardmedia, tg.APIInputMediaPhoto{ + Type: "photo", + Media: cardface.ImageUris.Large, + }) + } + } else { + cardmedia = append(cardmedia, tg.APIInputMediaPhoto{ + Type: "photo", + Media: card.ImageUris.Large, + }) + } } } if len(cardmedia) > 0 { diff --git a/scryfall.go b/scryfall.go index 21a7326..c124931 100644 --- a/scryfall.go +++ b/scryfall.go @@ -15,24 +15,31 @@ type CardSearchResults struct { NextPage string `json:"next_page"` } +type CardImage struct { + Small string `json:"small"` + Normal string `json:"normal"` + Large string `json:"large"` + Png string `json:"png"` + ArtCrop string `json:"art_crop"` + BorderCrop string `json:"border_crop"` +} + +type CardFaces struct { + ImageUris CardImage `json:"image_uris"` +} + type CardData struct { - ID string `json:"id"` - Name string `json:"name"` - URI string `json:"uri"` - ScryfallURI string `json:"scryfall_uri"` - Layout string `json:"layout"` - HighresImage bool `json:"highres_image"` - ImageUris struct { - Small string `json:"small"` - Normal string `json:"normal"` - Large string `json:"large"` - Png string `json:"png"` - ArtCrop string `json:"art_crop"` - BorderCrop string `json:"border_crop"` - } `json:"image_uris"` - Eur string `json:"eur"` - EdhrecRank *int `json:"edhrec_rank"` - RelatedUris struct { + ID string `json:"id"` + Name string `json:"name"` + URI string `json:"uri"` + ScryfallURI string `json:"scryfall_uri"` + Layout string `json:"layout"` + HighresImage bool `json:"highres_image"` + ImageUris CardImage `json:"image_uris"` + CardFaces []CardFaces `json:"card_faces"` + Eur string `json:"eur"` + EdhrecRank *int `json:"edhrec_rank"` + RelatedUris struct { Gatherer string `json:"gatherer"` TcgplayerDecks string `json:"tcgplayer_decks"` Edhrec string `json:"edhrec"`