Fix for double face cards
This commit is contained in:
parent
a2d2189585
commit
7f97c3144b
2 changed files with 43 additions and 23 deletions
17
main.go
17
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,
|
||||
|
@ -140,6 +144,14 @@ func webhook(update tg.APIUpdate) {
|
|||
card, err := scryfallGetCard(cardname)
|
||||
if err != nil {
|
||||
errlist = append(errlist, cardname)
|
||||
} else {
|
||||
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",
|
||||
|
@ -147,6 +159,7 @@ func webhook(update tg.APIUpdate) {
|
|||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
if len(cardmedia) > 0 {
|
||||
api.SendAlbum(tg.ClientAlbumData{
|
||||
ChatID: update.Message.Chat.ChatID,
|
||||
|
|
23
scryfall.go
23
scryfall.go
|
@ -15,6 +15,19 @@ 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"`
|
||||
|
@ -22,14 +35,8 @@ type CardData struct {
|
|||
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"`
|
||||
ImageUris CardImage `json:"image_uris"`
|
||||
CardFaces []CardFaces `json:"card_faces"`
|
||||
Eur string `json:"eur"`
|
||||
EdhrecRank *int `json:"edhrec_rank"`
|
||||
RelatedUris struct {
|
||||
|
|
Loading…
Reference in a new issue