2024-05-13 19:21:34 +03:00
|
|
|
package fsmwizard
|
2024-05-13 19:08:46 +03:00
|
|
|
|
|
|
|
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
|
|
|
|
}
|