黄金价格
continuous-integration/drone/push Build is passing Details

master
dustoair 3 years ago
parent 2818784c9f
commit 35cb021adf

@ -22,3 +22,17 @@ func GetBinanceLatestPrice(symbol string) float64 {
global.DB.Where("symbol = ?", symbol).Last(&binancePrice)
return binancePrice.Price
}
type CMBGold struct {
gorm.Model
Variety string
CurPrice float64
UpDown float64
GoldNo string
}
func GetCMBGoldLatestPrice(goldNo string) float64 {
var cmbGold CMBGold
global.DB.Where("gold_no = ?", goldNo).Last(&cmbGold)
return cmbGold.CurPrice
}

@ -39,11 +39,13 @@ func cmdExec(msgContent MsgContent) (replyContent string) {
case "eth", "btc", "虚拟货币":
priceBTC := api.GetBinanceLatestPrice("BTCUSDT")
priceETH := api.GetBinanceLatestPrice("ETHUSDT")
replyContent = fmt.Sprintf("BTC: %f \n ETH: %f", priceBTC, priceETH)
replyContent = fmt.Sprintf("BTC价格: %f \n ETH价格: %f", priceBTC, priceETH)
return
case "gold", "黄金":
replyContent = "黄金黄金黄金黄金黄金"
goldPrice := api.GetCMBGoldLatestPrice("AU100G")
replyContent = fmt.Sprintf("黄金价格: %f", goldPrice)
return
default:
cmdString = msgContent.Content
}

Loading…
Cancel
Save