Fixed some crashes in response strings source generator, reorganized more submodules into their folders

This commit is contained in:
Kwoth
2022-01-02 03:49:54 +01:00
parent 9c590668df
commit 4b6af0e4ef
191 changed files with 120 additions and 80 deletions

View File

@@ -0,0 +1,46 @@
#nullable disable
using NadekoBot.Common.Configs;
namespace NadekoBot.Modules.Xp.Services;
public sealed class XpConfigService : ConfigServiceBase<XpConfig>
{
private const string FilePath = "data/xp.yml";
private static readonly TypedKey<XpConfig> changeKey = new("config.xp.updated");
public override string Name { get; } = "xp";
public XpConfigService(IConfigSeria serializer, IPubSub pubSub)
: base(FilePath, serializer, pubSub, changeKey)
{
AddParsedProp("txt.cooldown",
conf => conf.MessageXpCooldown,
int.TryParse,
ConfigPrinters.ToString,
x => x > 0);
AddParsedProp("txt.per_msg", conf => conf.XpPerMessage, int.TryParse, ConfigPrinters.ToString, x => x >= 0);
AddParsedProp("txt.per_image", conf => conf.XpFromImage, int.TryParse, ConfigPrinters.ToString, x => x > 0);
AddParsedProp("voice.per_minute",
conf => conf.VoiceXpPerMinute,
double.TryParse,
ConfigPrinters.ToString,
x => x >= 0);
AddParsedProp("voice.max_minutes",
conf => conf.VoiceMaxMinutes,
int.TryParse,
ConfigPrinters.ToString,
x => x > 0);
Migrate();
}
private void Migrate()
{
if (data.Version < 2)
ModifyConfig(c =>
{
c.Version = 2;
c.XpFromImage = 0;
});
}
}