init code

This commit is contained in:
thuanle
2024-10-24 09:53:23 +07:00
parent a7559b3f9d
commit 92a63c7885
43 changed files with 1115 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
package tele
import (
"github.com/rs/zerolog/log"
"gopkg.in/telebot.v3"
"me.thuanle/bbot/internal/services/tele/commands"
"me.thuanle/bbot/internal/services/tele/middlewares"
)
var commandList = []telebot.Command{
{
Text: "p",
Description: "(p) - Get mark price",
},
{
Text: "fee",
Description: "(f) - show top funding fee",
},
}
func setupCommands(b *telebot.Bot) error {
if err := b.SetCommands(commandList); err != nil {
log.Fatal().Err(err).Msg("setup telebot commands")
return err
}
b.Use(middlewares.IgnoreBot)
b.Use(middlewares.SendErrorMiddleware)
//welcome
b.Handle("/start", commands.OnStart)
//general
b.Handle("/ip", commands.OnGetIp)
//info
b.Handle("/p", commands.OnGetTopPrices)
b.Handle("/fee", commands.OnGetTopFundingFee)
//any text
b.Handle(telebot.OnText, commands.OnChatHandler)
b.Handle(telebot.OnSticker, commands.OnStickerHandler)
return nil
}