package stateManager import ( "fmt" "penahub.gitlab.yandexcloud.net/backend/quiz/telegram/client" "penahub.gitlab.yandexcloud.net/backend/quiz/telegram/models" ) type StateManager struct { Questions map[string]models.Question State string client *client.Client } type Deps struct { Questions map[string]models.Question State string Client *client.Client } func NewStateManager(deps Deps) *StateManager { return &StateManager{ Questions: deps.Questions, State: deps.State, client: deps.Client, } } func (sm *StateManager) Listener(state string) { sm.State = state sm.SendQuestion() } func (sm *StateManager) SendQuestion() { question := sm.Questions[sm.State] message := fmt.Sprintf("%s\n%s", question.Title, question.Description) for _, button := range question.Buttons { message += fmt.Sprintf("\n%s", button.Text) } sm.client.SendMessage(message) }