From d4d0f46b998716a7235a7223d4d713f75e6bebdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B0=D0=B7=D0=B0=D1=80=20=D0=93=D0=BE=D0=BB=D1=8C?= =?UTF-8?q?=D1=87=D0=B5=D0=BD=D0=BA=D0=BE?= Date: Thu, 16 Oct 2025 11:33:10 +0300 Subject: [PATCH] impr: Improved the logic of the bot's text handlers. --- internal/application/constants/botContent.go | 3 ++- .../handlers/profile/universalTextHandler.go | 11 +++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/internal/application/constants/botContent.go b/internal/application/constants/botContent.go index ec72bba..c7dccfe 100644 --- a/internal/application/constants/botContent.go +++ b/internal/application/constants/botContent.go @@ -49,5 +49,6 @@ const ( ErrorResetBotMessage = "Возникли проблемки при сбросе твоего профиля. Пожалуйста, попробуй позже..." CanNotShowProfileBotMessage = "Чтобы посмотреть профиль, необходимо полностью его заполнить." CanNotShowVacanciesBotMessage = "Чтобы посмотреть вакансии, необходимо полностью заполнить профиль." - GetVacanciesError = "При вычислении подходящих вакансий возникли технические шоколадки 😅 Попробуй позже..." + GetVacanciesErrorBotMessage = "При вычислении подходящих вакансий возникли технические шоколадки 😅 Попробуй позже..." + UnknownCommandBotMessage = "Ты ввёл невалидное значение или неизвестную команду. Давай попробуем ещё раз..." ) diff --git a/internal/infrastructure/botService/handlers/profile/universalTextHandler.go b/internal/infrastructure/botService/handlers/profile/universalTextHandler.go index 3c86ee7..b7be3e1 100644 --- a/internal/infrastructure/botService/handlers/profile/universalTextHandler.go +++ b/internal/infrastructure/botService/handlers/profile/universalTextHandler.go @@ -127,7 +127,7 @@ func (t *handler) universalTextHandler(ctx tele.Context) error { ) msg = constants.StartAnswerQuestionsBotMessage - } else if user.ActiveStatus == constants.WaitWorkFormatStatus { + } else if user.ActiveStatus == constants.WaitWorkFormatStatus && constants.WorkFormat(val).Valid() { wf := constants.WorkFormat(val) user.WorkFormat = &wf user.ActiveStatus = constants.WaitTargetRoleStatus @@ -154,7 +154,7 @@ func (t *handler) universalTextHandler(ctx tele.Context) error { ) msg = constants.AcceptTargetRoleBotMessage - } else if user.ActiveStatus == constants.WaitSalaryRangeStatus { + } else if user.ActiveStatus == constants.WaitSalaryRangeStatus && constants.SalaryRange(val).Valid() { sr := constants.SalaryRange(val) user.SalaryRange = &sr user.ActiveStatus = constants.WaitWorkExperienceStatus @@ -192,7 +192,7 @@ func (t *handler) universalTextHandler(ctx tele.Context) error { } msg = fmt.Sprintf( - "Резюме: %v\nЗарплатная вилка: %v\nДолжность: %v\nОпыт работы: %v\nФормат работы: %v\n", + "Резюме: %v\nЗарплатная вилка: %v\nДолжность: %v\nОпыт работы: %v\nФормат работы: %v\n", resume, user.SalaryRange, *user.TargetRole, *user.WorkExperience, user.WorkFormat, ) } else if val == constants.ShowVacanciesBotCommand && !utils.CheckProfileCompletion(user) { @@ -206,7 +206,7 @@ func (t *handler) universalTextHandler(ctx tele.Context) error { if err != nil { t.logger.Error(fmt.Sprintf("%v: %v", op, err.Error())) - return ctx.Send(constants.GetVacanciesError) + return ctx.Send(constants.GetVacanciesErrorBotMessage) } else if len(vacancies) == 0 { return ctx.Send(constants.NoVacanciesBotMessage) } @@ -215,6 +215,9 @@ func (t *handler) universalTextHandler(ctx tele.Context) error { mainKeys = &tele.ReplyMarkup{RemoveKeyboard: true} msg = strings.Join(vacancies, "\n") + } else { + needUpdateUser = false + msg = constants.UnknownCommandBotMessage } // Set new user data if needUpdateUser {