using JOBot.TClient.Services; using Telegram.Bot.Types; using User = JOBot.Proto.User; namespace JOBot.TClient.Statements; public class PrepareUserState(PrepareUserService prepareUserService, MenuService menuService) { /// /// Try to prepare user if is not registered /// /// Update telegram object /// Cancellation token public async Task TryToPrepareUser(Update update, CancellationToken ct = default) { var user = await prepareUserService.GetUser(update, ct) ?? await prepareUserService.RegisterUser(update, ct); if (!user.Eula) { await prepareUserService.AskForEulaAgreement(update, ct); return; //interrupt while eula isn't accepted } await OnUserEulaValidStage(update, ct); } /// /// Signal for accepted eula /// /// /// public async Task AcceptEula(Update update, CancellationToken ct = default) { await prepareUserService.AcceptEula(update, ct: ct); await OnUserEulaValidStage(update, ct); } /// /// Continue prepare stage /// /// /// private async Task OnUserEulaValidStage(Update update, CancellationToken ct = default) { await menuService.RenderMenu(update, ct); //boilerplate } }