mirror of
https://github.com/Bubuni-Team/telegram-bot.git
synced 2026-07-31 00:29:24 +03:00
feat(store): code cleanup, make some fund with "unlucky" members
This commit is contained in:
@@ -15,8 +15,9 @@ namespace Kruzya.TelegramBot.Core.Service;
|
||||
|
||||
public class UserService
|
||||
{
|
||||
private readonly List<long> _superUsers;
|
||||
private readonly Dictionary<long, string> _statusMap;
|
||||
private readonly IEnumerable<long> _superUsers;
|
||||
private readonly IEnumerable<long> _badLuckUsers;
|
||||
private readonly Dictionary<long, string?> _statusMap;
|
||||
private readonly ICacheStorage<long, User> _userCache;
|
||||
private readonly ITelegramBotClient _bot;
|
||||
private readonly ILogger<UserService> _logger;
|
||||
@@ -28,15 +29,13 @@ public class UserService
|
||||
ICacheStorage<long, User> userCache,
|
||||
ILogger<UserService> logger)
|
||||
{
|
||||
_superUsers = configuration.GetSection("SuperUsers")
|
||||
.GetChildren()
|
||||
.Select(q => Convert.ToInt64(q.Value))
|
||||
.ToList();
|
||||
_superUsers = configuration.GetSection("SuperUsers").Get<List<long>>() ?? new List<long>();
|
||||
_badLuckUsers = configuration.GetSection("BadLuckUsers").Get<List<long>>() ?? new List<long>();
|
||||
|
||||
_statusMap = configuration.GetSection("CustomMemberStatus")
|
||||
.GetChildren()
|
||||
.ToDictionary(x => Convert.ToInt64(x.Key), x => x.Value);
|
||||
|
||||
|
||||
_userCache = userCache;
|
||||
_bot = bot.BotClient;
|
||||
_logger = logger;
|
||||
@@ -83,6 +82,11 @@ public class UserService
|
||||
return _superUsers.Contains(userId);
|
||||
}
|
||||
|
||||
public bool IsUserUnlucky(long userId)
|
||||
{
|
||||
return _badLuckUsers.Contains(userId);
|
||||
}
|
||||
|
||||
public string? GetUserCustomStatus(long userId)
|
||||
{
|
||||
return _statusMap.ContainsKey(userId) ? _statusMap[userId] : null;
|
||||
|
||||
Reference in New Issue
Block a user