Files
telegram-bot/Core/Service/UserService.cs
T

31 lines
757 B
C#
Raw Normal View History

2022-01-04 17:45:06 +02:00
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Extensions.Configuration;
using Telegram.Bot.Types;
namespace Kruzya.TelegramBot.Core.Service
{
public class UserService
{
private List<long> _superUsers;
public UserService(IConfiguration configuration)
{
_superUsers = configuration.GetSection("SuperUsers")
.GetChildren()
.Select(q => Convert.ToInt64(q.Value))
.ToList();
}
public bool IsUserSuper(User user)
{
return IsUserSuper(user.Id);
}
public bool IsUserSuper(long userId)
{
return _superUsers.Contains(userId);
}
}
}