refactor(service/binance): remove singaporeTZ and use local time

This commit is contained in:
wood chen 2024-10-31 01:31:20 +08:00
parent af013336ce
commit dcf24b0c76

View File

@ -14,12 +14,11 @@ import (
) )
var ( var (
botToken string botToken string
chatID int64 chatID int64
symbols []string symbols []string
bot *tgbotapi.BotAPI bot *tgbotapi.BotAPI
lastMsgID int lastMsgID int
singaporeTZ *time.Location
) )
var logger = log.New(log.Writer(), "Binance: ", log.Ldate|log.Ltime|log.Lshortfile) var logger = log.New(log.Writer(), "Binance: ", log.Ldate|log.Ltime|log.Lshortfile)
@ -74,7 +73,7 @@ func formatChange(changePercent float64) string {
} }
func sendPriceUpdate() { func sendPriceUpdate() {
now := time.Now().In(singaporeTZ) now := time.Now()
message := fmt.Sprintf("市场更新 - %s (SGT)\n\n", now.Format("2006-01-02 15:04:05")) message := fmt.Sprintf("市场更新 - %s (SGT)\n\n", now.Format("2006-01-02 15:04:05"))
for _, symbol := range symbols { for _, symbol := range symbols {
@ -118,7 +117,6 @@ func RunBinance() {
bot = core.Bot bot = core.Bot
chatID = core.ChatID chatID = core.ChatID
symbols = core.Symbols symbols = core.Symbols
singaporeTZ = core.SingaporeTZ
// 初始化并加载所有交易对 // 初始化并加载所有交易对
if err := LoadAllSymbols(); err != nil { if err := LoadAllSymbols(); err != nil {
@ -136,7 +134,7 @@ func RunBinance() {
defer ticker.Stop() defer ticker.Stop()
for range ticker.C { for range ticker.C {
now := time.Now().In(singaporeTZ) now := time.Now()
if now.Minute() == 0 { if now.Minute() == 0 {
logger.Println("发送每小时价格更新...") logger.Println("发送每小时价格更新...")
sendPriceUpdate() sendPriceUpdate()