From 51a2ae66d8fc445db4104d47562272120ffff8e1 Mon Sep 17 00:00:00 2001 From: Ege Bilecen Date: Fri, 19 Jul 2024 04:09:47 +0100 Subject: [PATCH 1/4] PostAsync() - added more logging info --- src/Bot/Util/WebRequest.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Bot/Util/WebRequest.cs b/src/Bot/Util/WebRequest.cs index db557db..c242e1a 100644 --- a/src/Bot/Util/WebRequest.cs +++ b/src/Bot/Util/WebRequest.cs @@ -48,11 +48,12 @@ public static async Task PostAsync(HttpClient httpClient, string url, Li { var content = new FormUrlEncodedContent(paramList); HttpResponseMessage response = await httpClient.PostAsync(url, content); + string responseContent = await response.Content.ReadAsStringAsync(); if(response.IsSuccessStatusCode) - return await response.Content.ReadAsStringAsync(); + return responseContent; - Logger.WriteLog($"WebRequest.PostAsync() - Response status code is not 200. Status code: {response.StatusCode} | URL: {url}"); + Logger.WriteLog($"WebRequest.PostAsync() - Response status code is not 200. Status code: {response.StatusCode} | URL: {url} | Body: {responseContent}"); return null; } } From 24d20555b922d2833672a6f9d71480086f07ebb4 Mon Sep 17 00:00:00 2001 From: Ege Bilecen Date: Fri, 19 Jul 2024 04:28:03 +0100 Subject: [PATCH 2/4] WorkshopItemUpdateChecker() - added extra logging --- src/Bot/Schedules/WorkshopItemUpdateChecker.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Bot/Schedules/WorkshopItemUpdateChecker.cs b/src/Bot/Schedules/WorkshopItemUpdateChecker.cs index 21d521d..64abd9c 100644 --- a/src/Bot/Schedules/WorkshopItemUpdateChecker.cs +++ b/src/Bot/Schedules/WorkshopItemUpdateChecker.cs @@ -49,6 +49,12 @@ public static void WorkshopItemUpdateChecker(List args) } string[] workshopIdList = iniData.GetValue("WorkshopItems").Split(';'); + if(workshopIdList.Length < 1) + { + Logger.WriteLog($"[Workshop Item Update Checker Schedule] Couldn't find any workshop items in iniData. configFilePath: {configFilePath}"); + return; + } + var fetchDetails = Task.Run(async () => await SteamWebAPI.GetWorkshopItemDetails(workshopIdList)); var itemDetails = fetchDetails.Result; From 44fbbbbe9118468d1d9ed5a5af792289f61b9a6b Mon Sep 17 00:00:00 2001 From: Ege Bilecen Date: Mon, 22 Jul 2024 15:01:19 +0100 Subject: [PATCH 3/4] fix: !abort_restart ignoring timed restarts --- src/Bot/Commands/PZServerCommands.cs | 6 +++++- src/Bot/Scheduler.cs | 2 +- src/Bot/Schedules/ServerRestart.cs | 9 +++++++++ src/Bot/Schedules/ServerRestartAnnouncer.cs | 4 ++++ src/PZServer/Util/ServerUtility.cs | 1 + 5 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/Bot/Commands/PZServerCommands.cs b/src/Bot/Commands/PZServerCommands.cs index 00fafa5..9e8ad38 100644 --- a/src/Bot/Commands/PZServerCommands.cs +++ b/src/Bot/Commands/PZServerCommands.cs @@ -140,7 +140,11 @@ public async Task AbortRestart() { Logger.WriteLog(string.Format("[PZServerCommand - abort_restart] Caller: {0}", Context.User.ToString())); - ServerUtility.ResetServerRestartInterval(); + if(Application.BotSettings.ServerScheduleSettings.ServerRestartScheduleType.ToLower() == "time") + ServerUtility.AbortNextTimedServerRestart = true; + else + ServerUtility.ResetServerRestartInterval(); + ServerUtility.Commands.ServerMsg(Localization.Get("disc_cmd_abort_restart_ok_server").KeyFormat(("minutes", Scheduler.GetItem("ServerRestart").NextExecuteTime.Subtract(DateTime.Now).TotalMinutes))); await Context.Message.AddReactionAsync(EmojiList.GreenCheck); diff --git a/src/Bot/Scheduler.cs b/src/Bot/Scheduler.cs index fa3c01c..1719104 100644 --- a/src/Bot/Scheduler.cs +++ b/src/Bot/Scheduler.cs @@ -152,7 +152,7 @@ public static uint GetIntervalFromTimes(List scheduleTimes) interval = nextRestartTimeDT - DateTime.Parse(nowString); } - Logger.WriteLog(string.Format("[GetIntervalFromTimes] - Next Restart Time: {0}", nextRestartTime)); + Logger.WriteLog(string.Format("[Scheduler.GetIntervalFromTimes] - Next Restart Time: {0}", nextRestartTime)); return Convert.ToUInt32(interval.TotalMilliseconds); } catch (Exception) diff --git a/src/Bot/Schedules/ServerRestart.cs b/src/Bot/Schedules/ServerRestart.cs index c4b823b..8604031 100644 --- a/src/Bot/Schedules/ServerRestart.cs +++ b/src/Bot/Schedules/ServerRestart.cs @@ -4,6 +4,15 @@ public static partial class Schedules { public static void ServerRestart(List args) { + if(Application.BotSettings.ServerScheduleSettings.ServerRestartScheduleType.ToLower() == "time" + && ServerUtility.AbortNextTimedServerRestart) + { + ServerUtility.AbortNextTimedServerRestart = false; + ServerUtility.ResetServerRestartInterval(); + + return; + } + bool isServerRunning = ServerUtility.IsServerRunning(); var publicChannel = DiscordUtility.GetTextChannelById(Application.BotSettings.PublicChannelId); var logChannel = DiscordUtility.GetTextChannelById(Application.BotSettings.LogChannelId); diff --git a/src/Bot/Schedules/ServerRestartAnnouncer.cs b/src/Bot/Schedules/ServerRestartAnnouncer.cs index 3585f3a..54802e4 100644 --- a/src/Bot/Schedules/ServerRestartAnnouncer.cs +++ b/src/Bot/Schedules/ServerRestartAnnouncer.cs @@ -11,6 +11,10 @@ public static void ServerRestartAnnouncer(List args) { if(!ServerUtility.IsServerRunning()) return; + if(Application.BotSettings.ServerScheduleSettings.ServerRestartScheduleType.ToLower() == "time" + && ServerUtility.AbortNextTimedServerRestart) + return; + ScheduleItem serverRestartSchedule = Scheduler.GetItem("ServerRestart"); ScheduleItem self = Scheduler.GetItem("ServerRestartAnnouncer"); diff --git a/src/PZServer/Util/ServerUtility.cs b/src/PZServer/Util/ServerUtility.cs index 2ee6a6c..fa0be68 100644 --- a/src/PZServer/Util/ServerUtility.cs +++ b/src/PZServer/Util/ServerUtility.cs @@ -7,6 +7,7 @@ public static class ServerUtility { private const string serverFile = ".\\server.bat"; public static Process ServerProcess = null; + public static bool AbortNextTimedServerRestart = false; public static bool CanStartServer() { From 9e0cf87544b0b7c544fa92fc37c367784fa34eb2 Mon Sep 17 00:00:00 2001 From: Ege Bilecen Date: Mon, 22 Jul 2024 15:01:39 +0100 Subject: [PATCH 4/4] v1.11.3 --- src/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Program.cs b/src/Program.cs index 0d179c0..2d2b55b 100644 --- a/src/Program.cs +++ b/src/Program.cs @@ -11,7 +11,7 @@ public static class Application { public const string BotRepoURL = "https://github.com/egebilecen/PZServerDiscordBot"; - public static readonly SemanticVersion BotVersion = new SemanticVersion(1, 11, 2, DevelopmentStage.Release); + public static readonly SemanticVersion BotVersion = new SemanticVersion(1, 11, 3, DevelopmentStage.Release); public static Settings.BotSettings BotSettings; public static DiscordSocketClient Client;