Skip to content

Commit

Permalink
Make package update check interval a config value
Browse files Browse the repository at this point in the history
  • Loading branch information
FloatingMilkshake committed Dec 9, 2024
1 parent f035a2d commit e839114
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions ConfigJson.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public class BaseConfig
[JsonProperty("authorizedUsers")] public string[] AuthorizedUsers { get; private set; }

[JsonProperty("sshHosts")] public string[] SshHosts { get; private set; }

[JsonProperty("packageUpdateCheckIntervalDays")] public int PackageUpdateCheckIntervalDays { get; private set; }

[JsonProperty("useServerSpecificFeatures")] public bool UseServerSpecificFeatures { get; private set; }

Expand Down
4 changes: 3 additions & 1 deletion Tasks/PackageUpdateTasks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ public static async Task ExecuteAsync()
{
while (true)
{
if (Program.ConfigJson.Base.PackageUpdateCheckIntervalDays == 0) return;

var (_, _, checkResult) = await CheckPackageUpdatesAsync();
var ownerMention =
Program.Discord.CurrentApplication.Owners.Aggregate("", (current, user) => current + user.Mention + " ");
if (checkResult != "")
await Program.HomeChannel.SendMessageAsync($"{ownerMention.Trim()}\n{checkResult}");

await Task.Delay(TimeSpan.FromDays(3));
await Task.Delay(TimeSpan.FromDays(Program.ConfigJson.Base.PackageUpdateCheckIntervalDays));
}
// ReSharper disable once FunctionNeverReturns
}
Expand Down
1 change: 1 addition & 0 deletions config.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"",
""
],
"packageUpdateCheckIntervalDays": 0,
"useServerSpecificFeatures": false,
"uptimeKumaHeartbeatUrl": ""
},
Expand Down

0 comments on commit e839114

Please sign in to comment.