Added href parsing

This commit is contained in:
Artyom Belousov 2019-05-11 19:00:58 +03:00
parent 738142f27f
commit c0f781fc7a
6 changed files with 78 additions and 7 deletions

View file

@ -6,6 +6,8 @@ import (
"net/http"
)
const CARDSLIMIT = 8
func HandleMessage(c *gin.Context) {
var req MessageRequest
c.BindJSON(&req)
@ -13,10 +15,17 @@ func HandleMessage(c *gin.Context) {
c.String(http.StatusOK, CONFIRMATION_STRING)
return
}
defer c.String(http.StatusOK, "ok")
if req.Secret != SECRET_KEY {
return
}
cardName := cardsinfo.GetOriginalName(req.Object.Body)
Message(req.Object.UserId, cardName)
c.String(http.StatusOK, "ok")
if cardName == "" {
Message(req.Object.UserId, "Карта не найдена")
} else {
prices, _ := cardsinfo.GetSCGPrices(cardName)
prices = prices[:CARDSLIMIT]
priceInfo := cardsinfo.FormatCardPrices(cardName, prices)
Message(req.Object.UserId, priceInfo)
}
}