public static async Task SendUserStats(this TelegramBotClient bot, Message message, User userInfo, RegistrationRepository registrationRepository, int savedCups) { var totalSubmitCount = userInfo.TotalSubmitCount; string registrationInfo = null; var registrations = registrationRepository.GetRegistrations(userInfo.Id).ToList(); if (registrations.Any()) { var firstRegistration = registrations.First(); var lastRegistration = registrations.Last(); registrationInfo = $"First registration: {firstRegistration.Timestamp}\n" + $"Last registration: {lastRegistration.Timestamp}"; } await bot.Send(message, $"Total submitted: {totalSubmitCount} of total: {savedCups}.\n\n" + $"{registrationInfo}", false); }
private async Task HandleOptions(string text, Message message, User userInfo) { var isAdmin = userInfo.IsAdmin; if (isAdmin) { AdminOptions(text, message); } switch (text) { case "start": case "/start": await bot.Send(message, "Enter number of cups saved"); break; case "users" when isAdmin: case "/users" when isAdmin: { foreach (var user in Users) { await bot.SendTextMessageAsync(message.Chat.Id, $"Authenticate: {user.Value}", replyMarkup : Keyboards.AuthenticationKb(user.Key)); return; } await bot.Send(message, "No users to authenticate"); break; } case "stats": case "/stats": await bot.Send(message, Helpers.TotalSavedText(_savedCups)); break; case "stats_extended": case "/stats_extended": await bot.SendStatsExtended(message, _registrationRepository, _savedCups); break; case "user_stats": case "/user_stats": await bot.SendUserStats(message, userInfo, _registrationRepository, _savedCups); break; case "undo": case "/undo": await bot.SendTextMessageAsync(message.Chat.Id, "Cups", replyMarkup : Keyboards.Undo); break; default: await bot.Send(message, "/start - Start saving\n" + "/undo - Enter number of cups to undo\n" + "/stats - Get basic statistics\n" + "/stats_extended - Get extended statistics!\n" + "/user_stats - See your own stats\n" + (isAdmin ? "\n/users - show users to authenticate" : null)); break; } }