Fixed bug with price slice size
This commit is contained in:
parent
c0f781fc7a
commit
f7a703769f
2 changed files with 10 additions and 2 deletions
|
|
@ -8,6 +8,13 @@ import (
|
|||
|
||||
const CARDSLIMIT = 8
|
||||
|
||||
func min(a, b int) int {
|
||||
if a < b {
|
||||
return a
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
func HandleMessage(c *gin.Context) {
|
||||
var req MessageRequest
|
||||
c.BindJSON(&req)
|
||||
|
|
@ -24,7 +31,8 @@ func HandleMessage(c *gin.Context) {
|
|||
Message(req.Object.UserId, "Карта не найдена")
|
||||
} else {
|
||||
prices, _ := cardsinfo.GetSCGPrices(cardName)
|
||||
prices = prices[:CARDSLIMIT]
|
||||
elements := min(CARDSLIMIT, len(prices))
|
||||
prices = prices[:elements]
|
||||
priceInfo := cardsinfo.FormatCardPrices(cardName, prices)
|
||||
Message(req.Object.UserId, priceInfo)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue