Files
telegram-bot/modules/ContentStore/ContentStore.cs
T
Andriy 27ddfd39cc [core] Massive setting system update
- 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
2023-07-21 17:14:11 +03:00

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);
}
}
}