vegapokerbot/internal/handler/fsmwizard/configure_redmine_query_state.go
2024-05-14 14:48:42 +03:00

48 lines
1.3 KiB
Go

package fsmwizard
import (
"gitea.neur0tx.site/Neur0toxine/vegapokerbot/internal/handler/iface"
"gitea.neur0tx.site/Neur0toxine/vegapokerbot/internal/handler/util"
"gitea.neur0tx.site/Neur0toxine/vegapokerbot/pkg/fsm"
"github.com/mymmrac/telego"
tu "github.com/mymmrac/telego/telegoutil"
)
const ConfigureRedmineQueryStateID fsm.StateID = "configure_redmine_query"
type ConfigureRedmineQueryState struct {
State
}
func NewConfigureRedmineQueryState(app iface.App) fsm.IState[Wizard] {
return &ConfigureRedmineQueryState{newBase(app)}
}
func (s *ConfigureRedmineQueryState) Enter(pl *Wizard, _ fsm.MachineControls[Wizard]) error {
_, err := s.App.TG().SendMessage(&telego.SendMessageParams{
ChatID: tu.ID(pl.User.ChatID),
Text: pl.Loc.Message("ask_for_redmine"),
ParseMode: telego.ModeMarkdown,
ReplyMarkup: &telego.InlineKeyboardMarkup{InlineKeyboard: [][]telego.InlineKeyboardButton{
{
{
Text: pl.Loc.Message("yes"),
CallbackData: util.NewRedmineQuestionPayload(
pl.User.TelegramID, pl.Chat.TelegramID, true).String(),
},
{
Text: pl.Loc.Message("no"),
CallbackData: util.NewRedmineQuestionPayload(
pl.User.TelegramID, pl.Chat.TelegramID, false).String(),
},
},
}},
})
s.LogError(err)
return err
}
func (s *ConfigureRedmineQueryState) ID() fsm.StateID {
return ConfigureRedmineQueryStateID
}