vegapokerbot/internal/handler/fsmwizard/unknown_command_state.go
Neur0toxine 4fdc64c03b
All checks were successful
continuous-integration/drone/push Build is passing
change fsm behavior, unknown command state
2024-05-13 21:46:05 +03:00

33 lines
911 B
Go

package fsmwizard
import (
"gitea.neur0tx.site/Neur0toxine/vegapokerbot/internal/handler/iface"
"gitea.neur0tx.site/Neur0toxine/vegapokerbot/pkg/fsm"
"github.com/mymmrac/telego"
tu "github.com/mymmrac/telego/telegoutil"
)
const UnknownCommandStateID fsm.StateID = "unknown_command"
type UnknownCommandState struct {
State
}
func NewUnknownCommandState(app iface.App) fsm.IState[Wizard] {
return &UnknownCommandState{newBase(app)}
}
func (s *UnknownCommandState) Enter(pl *Wizard, _ fsm.MachineControls[*Wizard]) error {
_, err := s.App.TG().SendMessage(&telego.SendMessageParams{
ChatID: tu.ID(s.Payload.Data.Message.Chat.ID),
Text: s.Localizer(s.Payload.Data.Message.From.LanguageCode).Message("unknown_command"),
ParseMode: telego.ModeMarkdown,
})
s.LogError(err)
return fsm.ErrPreventTransition
}
func (s *UnknownCommandState) ID() fsm.StateID {
return UnknownCommandStateID
}