From e59bb880b58f52a17995f5d7d0f353f0f6c48caf Mon Sep 17 00:00:00 2001 From: barelyprofessional <150058423+barelyprofessional@users.noreply.github.com> Date: Sun, 23 Mar 2025 19:49:45 +0800 Subject: [PATCH] New setting to control the initial state of the almanac shill --- KfChatDotNetBot/Services/BotServices.cs | 6 ++++++ KfChatDotNetBot/Settings/BuiltIn.cs | 11 +++++++++++ 2 files changed, 17 insertions(+) diff --git a/KfChatDotNetBot/Services/BotServices.cs b/KfChatDotNetBot/Services/BotServices.cs index 6ec80aa..961fb39 100644 --- a/KfChatDotNetBot/Services/BotServices.cs +++ b/KfChatDotNetBot/Services/BotServices.cs @@ -245,6 +245,12 @@ public class BotServices private async Task BuildAlmanacShill() { AlmanacShill = new AlmanacShill(_chatBot); + var initialState = await Helpers.GetValue(BuiltIn.Keys.BotAlmanacInitialState); + if (!initialState.ToBoolean()) + { + _logger.Info("Built the almanac service but not enabling as initial state is false"); + return; + } AlmanacShill.StartShillTask(); _logger.Info("Built the almanac shill task"); } diff --git a/KfChatDotNetBot/Settings/BuiltIn.cs b/KfChatDotNetBot/Settings/BuiltIn.cs index 8d15b55..a982f50 100644 --- a/KfChatDotNetBot/Settings/BuiltIn.cs +++ b/KfChatDotNetBot/Settings/BuiltIn.cs @@ -910,6 +910,16 @@ public static class BuiltIn IsSecret = false, CacheDuration = TimeSpan.FromHours(1), ValueType = SettingValueType.Text + }, + new BuiltInSettingsModel + { + Key = Keys.BotAlmanacInitialState, + Regex = "(true|false)", + Description = "Initial state of the Almanac reminder", + Default = "false", + IsSecret = false, + CacheDuration = TimeSpan.FromHours(1), + ValueType = SettingValueType.Boolean } ]; @@ -986,5 +996,6 @@ public static class BuiltIn public static string ClashggBmjIds = "Clashgg.BmjIds"; public static string BotAlmanacText = "Bot.Almanac.Text"; public static string BotAlmanacInterval = "Bot.Almanac.Interval"; + public static string BotAlmanacInitialState = "Bot.Almanac.InitialState"; } } \ No newline at end of file