mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-10 17:28:27 -04:00
49 lines
1.3 KiB
C#
49 lines
1.3 KiB
C#
using NadekoBot.Common.Configs;
|
|
|
|
namespace Nadeko.Medusa;
|
|
|
|
public sealed class MedusaConfigService : ConfigServiceBase<MedusaConfig>, IMedusaConfigService
|
|
{
|
|
private const string FILE_PATH = "data/medusae/medusa.yml";
|
|
private static readonly TypedKey<MedusaConfig> _changeKey = new("config.medusa.updated");
|
|
|
|
public override string Name
|
|
=> "medusa";
|
|
|
|
public MedusaConfigService(
|
|
IConfigSeria serializer,
|
|
IPubSub pubSub)
|
|
: base(FILE_PATH, serializer, pubSub, _changeKey)
|
|
{
|
|
}
|
|
|
|
public IReadOnlyCollection<string> GetLoadedMedusae()
|
|
=> Data.Loaded?.ToList() ?? new List<string>();
|
|
|
|
public void AddLoadedMedusa(string name)
|
|
{
|
|
name = name.Trim().ToLowerInvariant();
|
|
|
|
ModifyConfig(conf =>
|
|
{
|
|
if (conf.Loaded is null)
|
|
conf.Loaded = new();
|
|
|
|
if(!conf.Loaded.Contains(name))
|
|
conf.Loaded.Add(name);
|
|
});
|
|
}
|
|
|
|
public void RemoveLoadedMedusa(string name)
|
|
{
|
|
name = name.Trim().ToLowerInvariant();
|
|
|
|
ModifyConfig(conf =>
|
|
{
|
|
if (conf.Loaded is null)
|
|
conf.Loaded = new();
|
|
|
|
conf.Loaded.Remove(name);
|
|
});
|
|
}
|
|
} |