init code
This commit is contained in:
49
internal/services/tele/commands/token.go
Normal file
49
internal/services/tele/commands/token.go
Normal file
@@ -0,0 +1,49 @@
|
||||
package commands
|
||||
|
||||
import (
|
||||
"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"
|
||||
)
|
||||
|
||||
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])
|
||||
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))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func OnTokenInfo(context telebot.Context) error {
|
||||
text := strings.ToLower(context.Text())
|
||||
|
||||
return OnTokenInfoByToken(context, text)
|
||||
}
|
||||
Reference in New Issue
Block a user