Let's try something
This commit is contained in:
parent
3670cafaac
commit
da60c15f44
1 changed files with 47 additions and 49 deletions
96
main.go
96
main.go
|
@ -51,56 +51,54 @@ func webhook(update tg.APIUpdate) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
go func() {
|
query := update.Inline.Query
|
||||||
query := update.Inline.Query
|
offset, _ := strconv.Atoi(update.Inline.Offset)
|
||||||
offset, _ := strconv.Atoi(update.Inline.Offset)
|
results, err := scryfallSearch(query, offset)
|
||||||
results, err := scryfallSearch(query, offset)
|
if err != nil {
|
||||||
if err != nil {
|
fmt.Println(err)
|
||||||
fmt.Println(err)
|
// DO SOMETHING
|
||||||
// DO SOMETHING
|
return
|
||||||
return
|
}
|
||||||
}
|
|
||||||
|
|
||||||
nextcard := ""
|
nextcard := ""
|
||||||
if results.HasMore {
|
if results.HasMore {
|
||||||
nextcard = strconv.Itoa(offset + len(results.Data))
|
nextcard = strconv.Itoa(offset + len(results.Data))
|
||||||
}
|
}
|
||||||
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("EDHREC rank: #%d - cardmarket: € %s", card.EdhrecRank, card.Eur)
|
caption := fmt.Sprintf("EDHREC rank: #%d - cardmarket: € %s", card.EdhrecRank, 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,
|
Caption: caption,
|
||||||
ReplyMarkup: &tg.APIInlineKeyboardMarkup{
|
ReplyMarkup: &tg.APIInlineKeyboardMarkup{
|
||||||
InlineKeyboard: [][]tg.APIInlineKeyboardButton{{
|
InlineKeyboard: [][]tg.APIInlineKeyboardButton{{
|
||||||
{
|
{
|
||||||
Text: "Scryfall",
|
Text: "Scryfall",
|
||||||
URL: card.ScryfallURI,
|
URL: card.ScryfallURI,
|
||||||
}, {
|
}, {
|
||||||
Text: "EDHREC",
|
Text: "EDHREC",
|
||||||
URL: card.RelatedUris.Edhrec,
|
URL: card.RelatedUris.Edhrec,
|
||||||
}, {
|
}, {
|
||||||
Text: "MCM",
|
Text: "MCM",
|
||||||
URL: card.PurchaseUris.Magiccardmarket,
|
URL: card.PurchaseUris.Magiccardmarket,
|
||||||
},
|
},
|
||||||
}},
|
}},
|
||||||
},
|
},
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
err = api.AnswerInlineQuery(tg.InlineQueryResponse{
|
err = api.AnswerInlineQuery(tg.InlineQueryResponse{
|
||||||
QueryID: update.Inline.QueryID,
|
QueryID: update.Inline.QueryID,
|
||||||
Results: photos,
|
Results: photos,
|
||||||
NextOffset: nextcard,
|
NextOffset: nextcard,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
// DO SOMETHING
|
// DO SOMETHING
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}()
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue