Files
crypto-price-bot/internal/services/tele/commands/chat.go
2024-10-24 09:53:23 +07:00

44 lines
917 B
Go

package commands
import (
"github.com/rs/zerolog/log"
"gopkg.in/telebot.v3"
"me.thuanle/bbot/internal/configs/tele"
"me.thuanle/bbot/internal/helper/binancex"
"strings"
)
func OnChatHandler(context telebot.Context) error {
text := strings.ToLower(context.Text())
switch {
case text == "p":
return OnGetTopPrices(context)
case text == "f" || text == "fee":
return OnGetTopFundingFee(context)
case binancex.IsToken(text):
return OnTokenInfo(context)
default:
//ignore it
}
return nil
}
func OnStickerHandler(context telebot.Context) error {
stickerId := context.Message().Sticker.UniqueID
switch stickerId {
case tele.StickerTop:
return OnGetTopPrices(context)
default:
token, ok := tele.Sticker2TokenMap[stickerId]
if !ok {
log.Debug().
Any("sticker", context.Message().Sticker).
Msg("Sticker received")
return nil
}
return OnTokenInfoByToken(context, token)
}
}