mirror of
https://github.com/Bubuni-Team/telegram-bot.git
synced 2026-07-31 00:29:24 +03:00
27ddfd39cc
- Get rid of attribute crap. Now only interface is required - Rename canUse to isAdmin in `Bot.IsUserAdminAsync` to match the actual meaning of variable - Made `AnswerQuery` reusable by moving it from ContentStore to Core's CommonHandler - Chat Settings edit frontend (inline keyboard) - Rename NsfwOption to AllowNsfw and move it to ContentStore module - Remove option backend testing commands - Add KarmaMode option as an example of Select option type
34 lines
1.0 KiB
C#
34 lines
1.0 KiB
C#
using Kruzya.TelegramBot.Core;
|
|
using Kruzya.TelegramBot.Core.Options;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using West.TelegramBot.ContentStore.Option;
|
|
using West.TelegramBot.ContentStore.Service;
|
|
|
|
namespace West.TelegramBot.ContentStore;
|
|
|
|
public class ContentStore : Module
|
|
{
|
|
public readonly List<Type> MediaServiceTypes = new();
|
|
|
|
public ContentStore(Core core) : base(core)
|
|
{
|
|
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
|
|
{
|
|
foreach (var exportedType in assembly.GetExportedTypes()
|
|
.Where(t => !t.IsAbstract && t.GetInterface(nameof(IRandomMediaService)) != null))
|
|
{
|
|
MediaServiceTypes.Add(exportedType);
|
|
}
|
|
}
|
|
}
|
|
|
|
public override void ConfigureServices(IServiceCollection services)
|
|
{
|
|
services.AddScoped<IOption, AllowNsfw>();
|
|
|
|
foreach (var serviceType in MediaServiceTypes)
|
|
{
|
|
services.AddScoped(typeof(IRandomMediaService), serviceType);
|
|
}
|
|
}
|
|
} |