Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding configurable event log interval #12

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions TebexOxide/TebexOxide/TebexDonate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -409,6 +409,8 @@ 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;

#endregion
Expand Down Expand Up @@ -448,6 +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();
Expand Down Expand Up @@ -716,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);
Expand Down Expand Up @@ -1025,7 +1036,7 @@ private void FetchStoreInformation(bool command, string secretKey)
logEvents = jObject["account"]["log_events"].ToObject<bool>();

if (logEvents)
StartEventTimer(60f);
StartEventTimer(eventLogInterval);
else if (eventTimer != null && !eventTimer.Destroyed)
eventTimer.Destroy();

Expand Down Expand Up @@ -1058,7 +1069,7 @@ private void LogEvents()
eventTimer.Destroy();

Queue<Event> events = new Queue<Event>(this.events);
eventTimer = timer.In(60f, () => LogEvents());
eventTimer = timer.In(eventLogInterval, () => LogEvents());

if (events.Count < 1)
return;
Expand Down