From 80e4c260174d4be7cb136f45fac10a9b7dddb7f8 Mon Sep 17 00:00:00 2001 From: GardenHumster Date: Tue, 9 Jan 2024 13:53:40 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Theresa3rd-Bot/TheresaBot.GoCqHttp/TheresaBot.GoCqHttp.csproj | 2 +- Theresa3rd-Bot/TheresaBot.Main/Common/BotConfig.cs | 2 +- .../TheresaBot.MiraiHttpApi/TheresaBot.MiraiHttpApi.csproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Theresa3rd-Bot/TheresaBot.GoCqHttp/TheresaBot.GoCqHttp.csproj b/Theresa3rd-Bot/TheresaBot.GoCqHttp/TheresaBot.GoCqHttp.csproj index 89dcb304..9174c7ee 100644 --- a/Theresa3rd-Bot/TheresaBot.GoCqHttp/TheresaBot.GoCqHttp.csproj +++ b/Theresa3rd-Bot/TheresaBot.GoCqHttp/TheresaBot.GoCqHttp.csproj @@ -5,7 +5,7 @@ TheresaBot.GoCqHttp - 0.11.2 + 0.11.3 disable enable 3 diff --git a/Theresa3rd-Bot/TheresaBot.Main/Common/BotConfig.cs b/Theresa3rd-Bot/TheresaBot.Main/Common/BotConfig.cs index feecc473..38c4462f 100644 --- a/Theresa3rd-Bot/TheresaBot.Main/Common/BotConfig.cs +++ b/Theresa3rd-Bot/TheresaBot.Main/Common/BotConfig.cs @@ -6,7 +6,7 @@ namespace TheresaBot.Main.Common { public static class BotConfig { - public const string BotVersion = "0.11.2"; + public const string BotVersion = "0.11.3"; public const string BotHomepage = "https://www.theresa3rd.cn"; public static BotInfos BotInfos = new BotInfos(0, "Bot"); public static List AcceptGroups = new(); diff --git a/Theresa3rd-Bot/TheresaBot.MiraiHttpApi/TheresaBot.MiraiHttpApi.csproj b/Theresa3rd-Bot/TheresaBot.MiraiHttpApi/TheresaBot.MiraiHttpApi.csproj index 61740da2..9fd164fd 100644 --- a/Theresa3rd-Bot/TheresaBot.MiraiHttpApi/TheresaBot.MiraiHttpApi.csproj +++ b/Theresa3rd-Bot/TheresaBot.MiraiHttpApi/TheresaBot.MiraiHttpApi.csproj @@ -6,7 +6,7 @@ TheresaBot.MiraiHttpApi - 0.11.2 + 0.11.3 disable enable 3 From 44177f9f4b456c328722f89de52ddab3f3ac27b4 Mon Sep 17 00:00:00 2001 From: GardenHumster Date: Tue, 27 Feb 2024 16:20:46 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dwebui=E4=B8=AD=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E9=85=8D=E7=BD=AE=E5=90=8E=E6=97=A0=E6=B3=95=E9=87=8D?= =?UTF-8?q?=E5=90=AF=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Timers/SchedulerManager.cs | 45 ++++++++++++++----- 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/Theresa3rd-Bot/TheresaBot.Main/Timers/SchedulerManager.cs b/Theresa3rd-Bot/TheresaBot.Main/Timers/SchedulerManager.cs index 46acd963..7063eca7 100644 --- a/Theresa3rd-Bot/TheresaBot.Main/Timers/SchedulerManager.cs +++ b/Theresa3rd-Bot/TheresaBot.Main/Timers/SchedulerManager.cs @@ -45,8 +45,9 @@ public static async Task InitTempClearJobAsync(BaseSession session, BaseReporter { try { - await TempClearSchedulers.DestroyAndClearAsync(); string tempClearCron = "0 0 4 * * ?"; + await TempClearSchedulers.DestroyAndClearAsync(); + LogHelper.Info("定时清理任务已停止..."); ICronTrigger trigger = (ICronTrigger)TriggerBuilder.Create().WithCronSchedule(tempClearCron).Build(); IJobDetail jobDetail = JobBuilder.Create().WithIdentity("TempClearJob", "TempClearJob").Build(); IScheduler scheduler = await StdSchedulerFactory.GetDefaultScheduler(); @@ -71,6 +72,7 @@ public static async Task InitDownClearJobAsync(BaseSession session, BaseReporter try { await DownClearSchedulers.DestroyAndClearAsync(); + LogHelper.Info("定时清理任务已停止..."); string downloadClearCron = BotConfig.GeneralConfig.ClearCron; if (string.IsNullOrWhiteSpace(downloadClearCron)) return; ICronTrigger trigger = (ICronTrigger)TriggerBuilder.Create().WithCronSchedule(downloadClearCron).Build(); @@ -99,8 +101,9 @@ public static async Task InitCookieJobAsync(BaseSession session, BaseReporter re { try { - await CookieJobSchedulers.DestroyAndClearAsync(); string cookieCron = "0 0 9 * * ?"; + await CookieJobSchedulers.DestroyAndClearAsync(); + LogHelper.Info("Cookie检查定时器已停止..."); ICronTrigger trigger = (ICronTrigger)TriggerBuilder.Create().WithCronSchedule(cookieCron).Build(); IJobDetail jobDetail = JobBuilder.Create().WithIdentity("CookieJob", "CookieJob").Build(); IScheduler scheduler = await StdSchedulerFactory.GetDefaultScheduler(); @@ -126,12 +129,17 @@ public static async Task InitReminderJobAsync(BaseSession session, BaseReporter try { await ReminderSchedulers.DestroyAndClearAsync(); + LogHelper.Info("定时提醒任务已停止..."); var reminderConfig = BotConfig.ReminderConfig; if (reminderConfig is null) return; if (reminderConfig.Enable == false) return; - foreach (var item in reminderConfig.Timers) + var timers = reminderConfig.Timers; + foreach (var timer in timers) { - IScheduler scheduler = await CreateReminderJobAsync(item, session, reporter); + if (timer is null) continue; + if (timer.Enable == false) continue; + var scheduler = await CreateReminderJobAsync(timer, session, reporter); + if (scheduler is null) continue; ReminderSchedulers.Add(scheduler); } } @@ -175,15 +183,19 @@ public static async Task InitTimingSetuJobAsync(BaseSession session, BaseReporte try { await TimingSetuSchedulers.DestroyAndClearAsync(); + LogHelper.Info("涩图定时推送任务已停止..."); var timingSetuConfig = BotConfig.TimingSetuConfig; if (timingSetuConfig is null) return; if (timingSetuConfig.Enable == false) return; if (timingSetuConfig.Timers is null) return; if (timingSetuConfig.Timers.Count == 0) return; - List timers = timingSetuConfig.Timers.Take(10).ToList(); - foreach (var item in timers) + var timers = timingSetuConfig.Timers.Take(10).ToList(); + foreach (var timer in timers) { - IScheduler scheduler = await CreateTimingSetuJobAsync(item, session, reporter); + if (timer is null) continue; + if (timer.Enable == false) continue; + var scheduler = await CreateTimingSetuJobAsync(timer, session, reporter); + if (scheduler is null) continue; TimingSetuSchedulers.Add(scheduler); } } @@ -223,15 +235,19 @@ public static async Task InitPixivRankingJobAsync(BaseSession session, BaseRepor try { await TimingRankingSchedulers.DestroyAndClearAsync(); + LogHelper.Info("Pixiv榜单定时推送任务已停止..."); var rankingConfig = BotConfig.PixivRankingConfig; if (rankingConfig is null) return; if (rankingConfig.Enable == false) return; if (rankingConfig.Subscribes is null) return; if (rankingConfig.Subscribes.Count == 0) return; - List timers = rankingConfig.Subscribes; - foreach (var item in timers) + var subscribes = rankingConfig.Subscribes; + foreach (var subscribe in subscribes) { - IScheduler scheduler = await CreateTimingRankingJobAsync(item, session, reporter); + if (subscribe is null) continue; + if (subscribe.Enable == false) continue; + var scheduler = await CreateTimingRankingJobAsync(subscribe, session, reporter); + if (scheduler is null) continue; TimingRankingSchedulers.Add(scheduler); } } @@ -275,13 +291,18 @@ public static async Task InitWordCloudJobAsync(BaseSession session, BaseReporter try { await WordCloudSchedulers.DestroyAndClearAsync(); + LogHelper.Info("词云定时推送任务已停止..."); var wordCloudConfig = BotConfig.WordCloudConfig; + if (wordCloudConfig is null) return; + if (wordCloudConfig.Enable == false) return; var subscribes = wordCloudConfig?.Subscribes; if (subscribes is null || subscribes.Count == 0) return; foreach (var subscribe in subscribes) { + if (subscribe is null) continue; if (subscribe.Enable == false) continue; - IScheduler scheduler = await CreateWordCloudJobAsync(subscribe, session, reporter); + var scheduler = await CreateWordCloudJobAsync(subscribe, session, reporter); + if (scheduler is null) continue; WordCloudSchedulers.Add(scheduler); } } @@ -336,8 +357,8 @@ private static async Task DestroyAsync(this IScheduler scheduler) try { if (scheduler is null) return; + if (scheduler.IsShutdown) return; await scheduler.Shutdown(false); - await scheduler.Clear(); } catch (Exception ex) {