vegapokerbot/internal/handler/new_message_handler.go

50 lines
1.3 KiB
Go
Raw Normal View History

2024-05-07 22:07:53 +03:00
package handler
import (
"gitea.neur0tx.site/Neur0toxine/vegapokerbot/internal/handler/fsmwizard"
"gitea.neur0tx.site/Neur0toxine/vegapokerbot/internal/handler/iface"
2024-05-07 22:07:53 +03:00
"github.com/mymmrac/telego"
)
type MessageHandler struct {
2024-05-10 11:46:43 +03:00
iface.Base
2024-05-07 22:07:53 +03:00
}
func NewMessageHandler(app iface.App) Handler {
2024-05-10 11:46:43 +03:00
return &MessageHandler{iface.NewBase(app, 0, 0)}
2024-05-07 22:07:53 +03:00
}
2024-05-09 17:42:42 +03:00
func (h *MessageHandler) Handle(wh telego.Update) error {
2024-05-10 11:46:43 +03:00
if wh.Message.From == nil {
return nil
}
2024-05-10 12:10:25 +03:00
2024-05-14 15:39:55 +03:00
fsmwizard.Get(wh.Message.From.ID).Enqueue(func(w *fsmwizard.Wizard) *fsmwizard.Wizard {
if w == nil {
return &fsmwizard.Wizard{Data: wh}
}
w.Data = wh
return w
})
2024-05-14 15:39:55 +03:00
return nil
// if util.MatchCommand("start", wh.Message) {
// return wizard.NewRegister(h.App, wh.Message.From.ID, wh.Message.Chat.ID).Handle(wh)
// }
//
// if util.MatchCommand("poll", wh.Message) {
// return group.NewPoll(h.App, wh.Message.From.ID, wh.Message.Chat.ID).Handle(wh)
// }
//
// setup, found := store.RedmineSetups.Get(wh.Message.Chat.ID)
// if found {
// return wizard.NewRedmineSetup(h.App, wh.Message.From.ID, wh.Message.Chat.ID, setup).Handle(wh)
// }
//
// if util.MatchCommand("help", wh.Message) {
// return wizard.NewHelpCommand(h.App, wh.Message.From.ID, wh.Message.Chat.ID).Handle(wh)
// }
//
// return wizard.NewUnknownCommand(h.App, wh.Message.From.ID, wh.Message.Chat.ID).Handle(wh)
2024-05-07 22:07:53 +03:00
}