From 0ec089d673910067815582f9be5f4b81c7dbd984 Mon Sep 17 00:00:00 2001 From: Naaathan Date: Mon, 2 Mar 2020 14:53:45 +0000 Subject: [PATCH 1/2] Adding configurable event log interval --- TebexOxide/TebexOxide/TebexDonate.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/TebexOxide/TebexOxide/TebexDonate.cs b/TebexOxide/TebexOxide/TebexDonate.cs index eb1d29a..863eca9 100644 --- a/TebexOxide/TebexOxide/TebexDonate.cs +++ b/TebexOxide/TebexOxide/TebexDonate.cs @@ -23,7 +23,7 @@ namespace Oxide.Plugins { - [Info("Tebex Donate", "Tebex", "1.6.3")] + [Info("Tebex Donate", "Tebex", "1.6.4")] [Description("Official Plugin for the Tebex Server Monetization Platform.")] public class TebexDonate : CovalencePlugin { @@ -409,6 +409,7 @@ private static string HexToRust(string hex, float alpha = 1f) private bool debugLogActions; private bool debugLogResponseErrors; private bool debugLogStackTraces; + private float eventLogInterval; private string secretKey; #endregion @@ -448,6 +449,7 @@ protected override void LoadDefaultConfig() Config["Debug", "Log Actions"] = debugLogActions = GetConfig("Debug", "Log Actions", true); Config["Debug", "Log Stack Traces"] = debugLogStackTraces = GetConfig("Debug", "Log Stack Traces", true); Config["Debug", "Log Response Errors"] = debugLogResponseErrors = GetConfig("Debug", "Log Response Errors", true); + Config["Event Log Interval"] = eventLogInterval = GetConfig("Event Log Interval", 60f); Config["Secret key of your shop (do not tell it anyone)"] = secretKey = GetConfig("Secret key of your shop (do not tell it anyone)", ""); SaveConfig(); @@ -1025,7 +1027,7 @@ private void FetchStoreInformation(bool command, string secretKey) logEvents = jObject["account"]["log_events"].ToObject(); if (logEvents) - StartEventTimer(60f); + StartEventTimer(eventLogInterval); else if (eventTimer != null && !eventTimer.Destroyed) eventTimer.Destroy(); @@ -1058,7 +1060,7 @@ private void LogEvents() eventTimer.Destroy(); Queue events = new Queue(this.events); - eventTimer = timer.In(60f, () => LogEvents()); + eventTimer = timer.In(eventLogInterval, () => LogEvents()); if (events.Count < 1) return; From f23315d2ef0a785551a5698783ee9995e0c8c026 Mon Sep 17 00:00:00 2001 From: Naaathan Date: Tue, 3 Mar 2020 10:53:58 +0000 Subject: [PATCH 2/2] Adding configurable command check interval --- TebexOxide/TebexOxide/TebexDonate.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/TebexOxide/TebexOxide/TebexDonate.cs b/TebexOxide/TebexOxide/TebexDonate.cs index 863eca9..79421e8 100644 --- a/TebexOxide/TebexOxide/TebexDonate.cs +++ b/TebexOxide/TebexOxide/TebexDonate.cs @@ -409,6 +409,7 @@ private static string HexToRust(string hex, float alpha = 1f) private bool debugLogActions; private bool debugLogResponseErrors; private bool debugLogStackTraces; + private float commandCheckInterval; private float eventLogInterval; private string secretKey; @@ -449,7 +450,12 @@ protected override void LoadDefaultConfig() Config["Debug", "Log Actions"] = debugLogActions = GetConfig("Debug", "Log Actions", true); Config["Debug", "Log Stack Traces"] = debugLogStackTraces = GetConfig("Debug", "Log Stack Traces", true); Config["Debug", "Log Response Errors"] = debugLogResponseErrors = GetConfig("Debug", "Log Response Errors", true); + Config["Command Check Interval"] = commandCheckInterval = GetConfig("Command Check Interval", 225f); Config["Event Log Interval"] = eventLogInterval = GetConfig("Event Log Interval", 60f); + + if (eventLogInterval < 60f) + eventLogInterval = 60f; + Config["Secret key of your shop (do not tell it anyone)"] = secretKey = GetConfig("Secret key of your shop (do not tell it anyone)", ""); SaveConfig(); @@ -718,6 +724,9 @@ private void CheckCommandQueue(bool first) return; } + if (commandCheckInterval > secondsUntilNextCheck) + secondsUntilNextCheck = commandCheckInterval; + checkTimer = timer.In(secondsUntilNextCheck, () => CheckCommandQueue(false)); PrintError($"An unhandled error occurred whilst checking the command queue (response code: {code})."); }, this, RequestMethod.GET, AddToHeaders(secretKey), 3000f);