new telegram bot

This commit is contained in:
Artem Tsyrulnikov
2025-12-28 15:50:06 +03:00
parent 69179c64be
commit 2fb8c83041
75 changed files with 3719 additions and 1046 deletions

47
telegram_bot/main.go Normal file
View File

@@ -0,0 +1,47 @@
package main
import (
"time"
"example.com/m/adapter/backend"
"example.com/m/bot"
"example.com/m/handlers"
"example.com/m/pkg/logger"
"example.com/m/screens"
"github.com/NicoNex/echotron/v3"
"github.com/rs/zerolog/log"
)
const botToken = "8134938541:AAFcZhIGfYynQ9axyuA35R1nd7sPQZodrrQ"
func main() {
logger.Init(logger.Config{
AppName: "tgex-bot",
AppVersion: "v0.0.1",
PrettyConsole: true,
})
// Инициализация backend client
backendClient := backend.New(backend.Config{
BaseURL: "http://localhost:8000",
LoginURL: "https://unstabilising-lora-unframable.ngrok-free.dev/api/v1/auth/complete?token=",
})
var mainMenu = func() bot.State { return &screens.MainMenu{} }
newBot := func(chatID int64) echotron.Bot {
return bot.NewBot(chatID, botToken, mainMenu, backendClient, handlers.HandleGlobalCallback)
}
dsp := echotron.NewDispatcher(botToken, newBot)
log.Info().Msg("bot starting...")
for {
if err := dsp.Poll(); err != nil {
log.Error().Err(err).Msg("dsp.Poll failed, retrying in 5 seconds...")
time.Sleep(5 * time.Second)
continue
}
break
}
}