mirror of
https://github.com/Bubuni-Team/telegram-bot.git
synced 2026-07-31 00:29:24 +03:00
Assorted improvements.
- Add UserService. - Add "setrep" command. - Rename confusing methods and variables in AbstractAnimationHandler. - Change Bayan cooldown to Zero. - Add crappy "cooldowns" command.
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ using BotFramework;
|
||||
using Kruzya.TelegramBot.Core.Cache;
|
||||
using Kruzya.TelegramBot.Core.Data;
|
||||
using Kruzya.TelegramBot.Core.Extensions;
|
||||
using Kruzya.TelegramBot.Core.Service;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
@@ -41,6 +42,8 @@ namespace Kruzya.TelegramBot.Core
|
||||
// Cache for users.
|
||||
services.AddSingleton<ICacheStorage<long, User>, MemoryCache<long, User>>();
|
||||
|
||||
services.AddSingleton<UserService>();
|
||||
|
||||
// Trigger module handlers.
|
||||
_core.Modules.ConfigureServices(services);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user