Skip to content

Commit

Permalink
Merge branch 'v0.11.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
GardenHamster committed Feb 27, 2024
2 parents 7ad431b + 44177f9 commit 5361b8b
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<RootNamespace>TheresaBot.GoCqHttp</RootNamespace>
<StartupObject></StartupObject>
<BaseOutputPath></BaseOutputPath>
<Version>0.11.2</Version>
<Version>0.11.3</Version>
<Nullable>disable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<WarningLevel>3</WarningLevel>
Expand Down
2 changes: 1 addition & 1 deletion Theresa3rd-Bot/TheresaBot.Main/Common/BotConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<long> AcceptGroups = new();
Expand Down
45 changes: 33 additions & 12 deletions Theresa3rd-Bot/TheresaBot.Main/Timers/SchedulerManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<TempClearJob>().WithIdentity("TempClearJob", "TempClearJob").Build();
IScheduler scheduler = await StdSchedulerFactory.GetDefaultScheduler();
Expand All @@ -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();
Expand Down Expand Up @@ -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<CookieJob>().WithIdentity("CookieJob", "CookieJob").Build();
IScheduler scheduler = await StdSchedulerFactory.GetDefaultScheduler();
Expand All @@ -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);
}
}
Expand Down Expand Up @@ -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<TimingSetuTimer> 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);
}
}
Expand Down Expand Up @@ -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<PixivRankingTimer> 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);
}
}
Expand Down Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<RootNamespace>TheresaBot.MiraiHttpApi</RootNamespace>
<StartupObject></StartupObject>
<BaseOutputPath></BaseOutputPath>
<Version>0.11.2</Version>
<Version>0.11.3</Version>
<Nullable>disable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<WarningLevel>3</WarningLevel>
Expand Down

0 comments on commit 5361b8b

Please sign in to comment.