diff --git a/src/Infrastructure/BotSharp.Core.Crontab/Services/CrontabWatcher.cs b/src/Infrastructure/BotSharp.Core.Crontab/Services/CrontabWatcher.cs index 1546cb7c..f6ce7a26 100644 --- a/src/Infrastructure/BotSharp.Core.Crontab/Services/CrontabWatcher.cs +++ b/src/Infrastructure/BotSharp.Core.Crontab/Services/CrontabWatcher.cs @@ -45,6 +45,7 @@ public class CrontabWatcher : BackgroundService { var cron = services.GetRequiredService(); var crons = await cron.GetCrontable(); + var settings = services.GetRequiredService(); var publisher = services.GetService(); foreach (var item in crons) @@ -87,7 +88,7 @@ public class CrontabWatcher : BackgroundService { _logger.LogInformation($"The current time matches the cron expression {item}"); - if (publisher != null) + if (publisher != null && settings.EventSubscriber.Enabled) { await publisher.PublishAsync($"Crontab:{item.Title}", item.Cron); }