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:
West14
2022-01-04 17:45:06 +02:00
parent 8717ef9db9
commit 740527d827
7 changed files with 144 additions and 12 deletions
+31
View File
@@ -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);
}
}
}
+3
View File
@@ -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);
}