vegapokerbot/internal/handler/fsmwizard/keyboard_chooser_state.go

57 lines
1.8 KiB
Go
Raw Normal View History

package fsmwizard
import (
"gitea.neur0tx.site/Neur0toxine/vegapokerbot/internal/db/model"
"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 KeyboardChooserStateID fsm.StateID = "keyboard_chooser"
type KeyboardChooserState struct {
State
}
func NewKeyboardChooserState(app iface.App) fsm.IState[Wizard] {
return &KeyboardChooserState{newBase(app)}
}
func (s *KeyboardChooserState) Enter(pl *Wizard, _ fsm.MachineControls[*Wizard]) error {
_, err := s.App.TG().SendMessage(&telego.SendMessageParams{
ChatID: tu.ID(pl.User.ChatID),
Text: s.Localizer().Template("choose_keyboard", map[string]interface{}{"Name": pl.TGChat.Title}),
ParseMode: telego.ModeMarkdown,
ReplyMarkup: &telego.InlineKeyboardMarkup{
InlineKeyboard: [][]telego.InlineKeyboardButton{
{
{
Text: s.Localizer().Message("standard_vote_keyboard"),
CallbackData: util.NewKeyboardChooserPayload(
pl.User.TelegramID, pl.TGChat.ID, uint8(model.StandardKeyboard)).String(),
},
},
{
{
Text: s.Localizer().Message("sp_vote_keyboard"),
CallbackData: util.NewKeyboardChooserPayload(
pl.User.TelegramID, pl.TGChat.ID, uint8(model.StoryPointsKeyboard)).String(),
},
},
},
},
})
s.LogError(err)
return err
}
func (s *KeyboardChooserState) Handle(pl *Wizard, _ fsm.MachineControls[*Wizard]) {
// todo: implement this using func (h *CallbackQueryHandler) handleChooseKeyboard(pl util.Payload, msgID int, user *model.User) error
}
func (s *KeyboardChooserState) ID() fsm.StateID {
return KeyboardChooserStateID
}