package nechotron import ( "log" echo "github.com/NicoNex/echotron/v3" ) type Nechotron struct { Token string DefaultState Runnable ApiServer string } func NewTron(token string, defaultState *State) *Nechotron { state := defaultState if state == nil { state = &EchoState } return &Nechotron{ Token: token, DefaultState: state, } } func (n *Nechotron) newBot(chatID int64) echo.Bot { a := echo.NewAPI(n.Token) // a := echo.NewAPI(n.Token) me, _ := a.GetMe() // log.Println("New bot active: ", chatID, me.Result) b := &bot{ chatID: chatID, me: me.Result, API: a, state: n.DefaultState, data: make(StateData), } b.state = n.DefaultState return b } func (n *Nechotron) DispatchPoll() error { dispatcher := echo.NewDispatcher(n.Token, n.newBot) log.Println("Nechotron poll dispatcher started") return dispatcher.Poll() }