package handler import ( "gitea.neur0tx.site/Neur0toxine/vegapokerbot/internal/handler/group" "gitea.neur0tx.site/Neur0toxine/vegapokerbot/internal/handler/iface" "gitea.neur0tx.site/Neur0toxine/vegapokerbot/internal/handler/store" "gitea.neur0tx.site/Neur0toxine/vegapokerbot/internal/handler/util" "gitea.neur0tx.site/Neur0toxine/vegapokerbot/internal/handler/wizard" "github.com/mymmrac/telego" ) type MessageHandler struct { iface.Base } func NewMessageHandler(app iface.App) Handler { return &MessageHandler{iface.NewBase(app, 0, 0)} } func (h *MessageHandler) Handle(wh telego.Update) error { if wh.Message.From == nil { 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) }