From a50237304d95ef6b0ceda04fffbff69e4eeaea12 Mon Sep 17 00:00:00 2001 From: Zontreck Date: Mon, 1 Jun 2020 02:40:09 -0700 Subject: [PATCH] Update bot to use new versioning scheme and add a automatic relog trigger after a number of hours --- Assembly/ASMInfo.cs | 4 ++-- BotSession.cs | 3 +++ ConfigSystem/MainConfiguration.cs | 4 ++++ Program.cs | 21 +++++++++++++++++++-- 4 files changed, 28 insertions(+), 4 deletions(-) diff --git a/Assembly/ASMInfo.cs b/Assembly/ASMInfo.cs index 7ac8cfd..a849111 100644 --- a/Assembly/ASMInfo.cs +++ b/Assembly/ASMInfo.cs @@ -6,7 +6,7 @@ using System.Reflection; [assembly: AssemblyCompany("ZNI")] [assembly: AssemblyAlgorithmId(System.Configuration.Assemblies.AssemblyHashAlgorithm.MD5)] [assembly: AssemblyCopyright("© 2020 Tara Piccari")] -[assembly: AssemblyFileVersion("5.819")] +[assembly: AssemblyFileVersion("5.1.931")] [assembly: AssemblyDescription("Second Life Bot - BotCore5")] @@ -15,7 +15,7 @@ namespace Bot.Assemble public class ASMInfo { public static string BotName = "ZBotCore"; - public static double BotVer = 5.724; + public static string BotVer = "5.1.931"; public static string GitPassword { get diff --git a/BotSession.cs b/BotSession.cs index 19f0954..90c761e 100644 --- a/BotSession.cs +++ b/BotSession.cs @@ -43,5 +43,8 @@ namespace Bot return MainConfiguration.Instance; } } + + + public DateTime LaunchTime { get; set; } = DateTime.Now; } } diff --git a/ConfigSystem/MainConfiguration.cs b/ConfigSystem/MainConfiguration.cs index 4c191ff..fb804f1 100644 --- a/ConfigSystem/MainConfiguration.cs +++ b/ConfigSystem/MainConfiguration.cs @@ -5,6 +5,7 @@ using System.Text; using System.Threading.Tasks; using System.IO; using OpenMetaverse; +using Newtonsoft.Json; namespace Bot { @@ -55,6 +56,9 @@ namespace Bot public string GitPassword { get; set; } = "NOT_SET"; + [JsonProperty(PropertyName = "RelogAfter")] + public double AutoRelogAfterHours = 12; + public int WebServerPort { get; set; } = 35591; public Dictionary BotAdmins { get; set; } = new Dictionary(); diff --git a/Program.cs b/Program.cs index 7d2efd4..b1c533a 100644 --- a/Program.cs +++ b/Program.cs @@ -19,7 +19,7 @@ namespace Bot public class Program { public static Logger Log; - public static double BotVer = ASMInfo.BotVer; + public static string BotVer = ASMInfo.BotVer; public static string BotStr = ASMInfo.BotName; // internal identifier for linden public static MainConfiguration conf; public static string Flavor = "Bot"; // inworld identification - must be customized @@ -52,6 +52,7 @@ namespace Bot Console.WriteLine("Setting up Main Configuration"); Log = new Logger("BotCore5"); BotSession.Instance.Logger = Log; + BotSession.Instance.LaunchTime = DateTime.Now; ZHash.Instance.NewKey(); ZHash.Instance.Key = "Test"; Console.WriteLine("ZHash (Test): " + ZHash.Instance.Key); @@ -450,6 +451,8 @@ namespace Bot plugin.getTick(); // Trigger a tick event!!! } + + string jsonReply = MH.CheckActions(); @@ -547,7 +550,21 @@ namespace Bot if (startupSeq) startupSeq = false; - + if(BotSession.Instance.LaunchTime.AddHours(MainConfiguration.Instance.AutoRelogAfterHours) < DateTime.Now) + { + // Initiate a relog + try + { + prompter.Interrupt(); + prompter.Abort(); + }catch(Exception e) + { + client.Self.Chat(e.Message, 0, ChatType.Normal); + } + client.Self.Chat("Automatic relog in progress", 0, ChatType.Whisper); + g_iIsRunning = false; + client.Network.Logout(); + } //if (MasterObjectCaches.RegionPrims.Count == 0 && client.Network.Connected) //{