Поправил отображение победившего пользователя
All checks were successful
Local Deploy with Docker / build-and-deploy (push) Successful in 17s

This commit is contained in:
Dmitrii Prokudin 2024-12-26 04:48:14 +03:00
parent 9c1e1d32bf
commit 809a1feac7

View File

@ -93,10 +93,10 @@ public class BotService
var selectedUser = await SelectUserOfTheDayAsync(chatId, today, type);
if (selectedUser.HasValue)
if (selectedUser.userId is not null)
{
var responseMessage = type == UserOfTheDayType.UserOfTheDay ? "Пользователь дня" : "Неудачник дня";
await _botClient.SendTextMessageAsync(chatId, $"{responseMessage}: {selectedUser.Value}", cancellationToken: cancellationToken);
await _botClient.SendTextMessageAsync(chatId, $"{responseMessage}: {selectedUser.userName}", cancellationToken: cancellationToken);
}
else
{
@ -110,7 +110,7 @@ public class BotService
}
}
private async Task<long?> SelectUserOfTheDayAsync(long chatId, DateTime date, UserOfTheDayType type)
private async Task<(long? userId, string userName)> SelectUserOfTheDayAsync(long chatId, DateTime date, UserOfTheDayType type)
{
var users = (await _userRepository.GetUsersWithNamesAsync(chatId)).ToList();
@ -126,7 +126,7 @@ public class BotService
if (!await _userOfTheDayRepository.IsUserAlreadySelectedAsync(chatId, date, selectedUser.userId))
{
await _userOfTheDayRepository.RecordUserOfTheDayAsync(chatId, selectedUser.userId, date, type);
return selectedUser.userId;
return (selectedUser.userId, selectedUser.userName);
}
users.RemoveAt(randomIndex);
@ -134,7 +134,7 @@ public class BotService
}
}
return null;
return default;
}
private async Task HandleStatCommandAsync(Message message, CancellationToken cancellationToken)