Files
nadekobot/src/NadekoBot/Modules/Xp/Services/XpConfigService.cs
Kwoth a09be96200 Added DmHelpTextKeywords to data/bot.yml
- Bot now sends dm help text ONLY if the message contains one of the keywords specified
  - If no keywords are specified, bot will reply to every DM (like before)
- Fixed several commands which used error color for success confirmation messages
2021-09-16 22:52:04 +02:00

43 lines
1.5 KiB
C#

using NadekoBot.Common;
using NadekoBot.Common.Configs;
using NadekoBot.Services;
namespace NadekoBot.Modules.Xp.Services
{
public sealed class XpConfigService : ConfigServiceBase<XpConfig>
{
public override string Name { get; } = "xp";
private const string FilePath = "data/xp.yml";
private static TypedKey<XpConfig> changeKey = new TypedKey<XpConfig>("config.xp.updated");
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;
});
}
}
}
}