102 lines
2.6 KiB
Go
102 lines
2.6 KiB
Go
package commands
|
|
|
|
import (
|
|
"golang.org/x/text/language"
|
|
"golang.org/x/text/message"
|
|
"gopkg.in/telebot.v3"
|
|
"me.thuanle/bbot/internal/configs/tele"
|
|
"me.thuanle/bbot/internal/data"
|
|
"me.thuanle/bbot/internal/helper/binancex"
|
|
"me.thuanle/bbot/internal/services/tele/chat"
|
|
"me.thuanle/bbot/internal/services/tele/view"
|
|
"strings"
|
|
)
|
|
|
|
var lastEthPrice float64
|
|
|
|
func showStickerMode(context telebot.Context, token string) {
|
|
token = strings.ToUpper(token)
|
|
stickerIdx, ok := tele.Token2StickerIdxMap[token]
|
|
if !ok {
|
|
return
|
|
}
|
|
stickers, err := context.Bot().StickerSet(tele.StickerSet)
|
|
if err == nil && stickers != nil {
|
|
_ = context.Reply(&stickers.Stickers[stickerIdx])
|
|
}
|
|
}
|
|
|
|
func OnTokenInfoByToken(context telebot.Context, token string) error {
|
|
symbols := binancex.Token2Symbols(token)
|
|
if len(symbols) == 0 {
|
|
return nil
|
|
}
|
|
|
|
showStickerMode(context, token)
|
|
|
|
fp, fundRate, fundTime, ok := data.Market.GetFuturePrice(symbols[0])
|
|
marginRates := data.Market.GetMarginInterestRates()
|
|
tokenInterestRate := marginRates[strings.ToUpper(token)]
|
|
if !ok {
|
|
return nil
|
|
}
|
|
sSymbol := binancex.Future2SpotSymbol(symbols[0])
|
|
sp, _ := data.Market.GetSpotPrice(sSymbol)
|
|
|
|
_ = chat.ReplyMessage(context, view.RenderOnPriceMessage(symbols[0], sp, fp, fundRate, fundTime, tokenInterestRate))
|
|
if strings.ToUpper(token) == "ETH" {
|
|
mFmt := message.NewPrinter(language.AmericanEnglish)
|
|
realAmount := 35.
|
|
trangBucAmount := 14.
|
|
basePrice := 2500.0
|
|
baseTotal := realAmount * basePrice
|
|
trangBucTotal := trangBucAmount * basePrice
|
|
realCurTotal := realAmount * sp
|
|
trangBucCurTotal := trangBucAmount * sp
|
|
|
|
lastDelta := ""
|
|
if lastEthPrice == 0 {
|
|
lastEthPrice = sp
|
|
} else {
|
|
lastDelta = mFmt.Sprintf(
|
|
"Δ price: $%+.0f\n"+
|
|
"Δ Usdt: $%+.0f\n",
|
|
sp-lastEthPrice,
|
|
(sp-lastEthPrice)*realAmount,
|
|
)
|
|
lastEthPrice = sp
|
|
}
|
|
|
|
msg := mFmt.Sprintf(
|
|
"🎉🎊🎊🦈🦈🦈 @th13vn Real 🦈🦈🦈🎊🎊🎉\n"+
|
|
"∑ USDT: $%.0f\n"+
|
|
"Lợi nhuận: $%.0f\n"+
|
|
"%s\n"+
|
|
"\n"+
|
|
"🚀🚀🚀🚀🚀 Road to 5k 🚀🚀🚀🚀🚀: \n"+
|
|
"- Δ Price: $%0.0f\n"+
|
|
"- Δ Vol: $%0.0f\n"+
|
|
"\n"+
|
|
"💸💸💸💸💸 Trang Bức balance 💸💸💸💸💸\n"+
|
|
"∑ USDT: $%.0f\n"+
|
|
"Lợi nhuận: $%.0f\n",
|
|
realCurTotal,
|
|
realCurTotal-baseTotal,
|
|
lastDelta,
|
|
5000-sp,
|
|
5000*realAmount-realCurTotal,
|
|
trangBucCurTotal,
|
|
trangBucCurTotal-trangBucTotal,
|
|
)
|
|
|
|
_ = chat.ReplyMessage(context, msg)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func OnTokenInfo(context telebot.Context) error {
|
|
text := strings.ToLower(context.Text())
|
|
|
|
return OnTokenInfoByToken(context, text)
|
|
}
|