diff --git a/Assembly/ASMInfo.cs b/Assembly/ASMInfo.cs
index 108c8b4..b9e1967 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.2.018")]
+[assembly: AssemblyFileVersion("5.2.109")]
[assembly: AssemblyDescription("Second Life Bot - BotCore5")]
@@ -15,7 +15,7 @@ namespace Bot.Assemble
public class ASMInfo
{
public static string BotName = "ZBotCore";
- public static string BotVer = "5.2.018";
+ public static string BotVer = "5.2.109";
public static string GitPassword
{
get
diff --git a/ChatLogger.cs b/ChatLogger.cs
new file mode 100644
index 0000000..5fc77f2
--- /dev/null
+++ b/ChatLogger.cs
@@ -0,0 +1,58 @@
+using Bot.CommandSystem;
+using OpenMetaverse;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Bot
+{
+ public sealed class ChatLogger
+ {
+ private static readonly object writelock = new object();
+ private static ChatLogger inst = null;
+ static ChatLogger() { }
+ public static ChatLogger Instance
+ {
+ get
+ {
+ if (inst != null) return inst;
+ else
+ {
+ if (inst == null)
+ {
+ inst = new ChatLogger();
+ }
+
+ return inst;
+ }
+ }
+ }
+
+
+
+ ///
+ /// Debug function to log chat and IMs incase of errors.
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ [CommandGroup("log_chat", 5, 0, "log_chat - Toggles chat and IM logging", MessageHandler.Destinations.DEST_AGENT | MessageHandler.Destinations.DEST_LOCAL | MessageHandler.Destinations.DEST_CONSOLE_INFO)]
+ public void toggleChatLog(UUID client, int level, GridClient grid, string[] additionalArgs, MessageHandler.MessageHandleEvent MHE, MessageHandler.Destinations source, CommandRegistry registry, UUID agentKey, string agentName)
+ {
+ MHE(source, client, "Toggling");
+
+ MainConfiguration.Instance.LogChatAndIMs = !MainConfiguration.Instance.LogChatAndIMs;
+ MainConfiguration.Instance.Save();
+
+ MHE(source, client, "Logging is now set to: " + MainConfiguration.Instance.LogChatAndIMs.ToString());
+ }
+
+
+ }
+}
diff --git a/CommandSystem/CommandManager.cs b/CommandSystem/CommandManager.cs
index 272f18e..666f077 100644
--- a/CommandSystem/CommandManager.cs
+++ b/CommandSystem/CommandManager.cs
@@ -69,6 +69,15 @@ namespace Bot.CommandSystem
else sourceLoc = MessageHandler.Destinations.DEST_LOCAL;
string agentName = parameters.fromName;
+ if(sourceLoc == MessageHandler.Destinations.DEST_LOCAL)
+ {
+ GroupLog.Instance.WriteLogEntry(true, false, agentName, agentKey, request);
+ }else if (sourceLoc == MessageHandler.Destinations.DEST_AGENT)
+ {
+ GroupLog.Instance.WriteLogEntry(false, true, agentName, agentKey, request);
+ }
+
+
if (sourceLoc == MessageHandler.Destinations.DEST_GROUP)
{
agentKey = fromID;
diff --git a/ConfigSystem/MainConfiguration.cs b/ConfigSystem/MainConfiguration.cs
index 7b92b42..2479df6 100644
--- a/ConfigSystem/MainConfiguration.cs
+++ b/ConfigSystem/MainConfiguration.cs
@@ -65,6 +65,9 @@ namespace Bot
public string SSLCertificatePFX { get; set; } = "certificate.pfx";
public string SSLCertificatePWD { get; set; } = "";
+ public bool LogChatAndIMs { get; set; } = false;
+ public string IMAndChatFormat { get; set; } = "[%TIME%] (%NAME%): %MESSAGE%";
+
public Dictionary BotAdmins { get; set; } = new Dictionary();
public List AuthedGithubUsers { get; set; } = new List();
diff --git a/GroupLog.cs b/GroupLog.cs
index cd9224b..5c55f98 100644
--- a/GroupLog.cs
+++ b/GroupLog.cs
@@ -51,6 +51,33 @@ namespace Bot
catch (Exception e) { }
}
+ public void WriteLogEntry(bool isLocal, bool isIM, string SenderName, UUID SenderID, string Message)
+ {
+ string filename = "";
+ if (isLocal) filename = DateTime.Now.ToString("M-d-yyyy")+"-LocalChat.log";
+ else filename = DateTime.Now.ToString("M-d-yyyy") + "-"+SenderName + ".log";
+
+ string LogFormat = MainConfiguration.Instance.IMAndChatFormat;
+ LogFormat=LogFormat.Replace("%TIME%", DateTime.Now.ToString("hh:mm:ss"));
+ LogFormat = LogFormat.Replace("%NAME%", SenderName);
+ LogFormat = LogFormat.Replace("%MESSAGE%", Message);
+ LogFormat = LogFormat.Replace("%UUID%", SenderID.ToString());
+
+
+ try
+ {
+ lock (_writeLock)
+ {
+ if (!Directory.Exists("GroupChatLogs")) Directory.CreateDirectory("GroupChatLogs");
+ File.AppendAllText(filename, LogFormat + "\n");
+ }
+ }catch(Exception e)
+ {
+ Console.WriteLine("Could not write a log using overload1 (chat or IM)\nError code: " + e.Message + "\nStack: " + e.StackTrace);
+ }
+
+ }
+
private static readonly object _fileRead = new object();
[CommandGroupMaster("Logging")]
[CommandGroup("search_log", 5, 2, "search_log [groupName] [search_term] - Searches for the search term in all logs relating to the group name (Use a underscore to show where spaces are!). The search term may also include the pipe (|) delimiter to include more than 1 word.", Bot.MessageHandler.Destinations.DEST_AGENT | Bot.MessageHandler.Destinations.DEST_LOCAL | MessageHandler.Destinations.DEST_GROUP | MessageHandler.Destinations.DEST_DISCORD)]
diff --git a/Program.cs b/Program.cs
index 9e87637..81a04d4 100644
--- a/Program.cs
+++ b/Program.cs
@@ -47,6 +47,7 @@ namespace Bot
public static unsafe void Main(string[] args)
{
+ Console.SetOut(new StreamWriter(new FileStream("Console.log", FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite)));
Console.WriteLine("Setting up Main Configuration");
Log = new Logger("BotCore5");
BotSession.Instance.Logger = Log;
@@ -57,7 +58,6 @@ namespace Bot
MainConfiguration.Instance.Load();
MainConfiguration conf = MainConfiguration.Instance;
//MasterObjectCaches = ObjectCaches.Instance;
- AppDomain.CurrentDomain.ProcessExit += CurrentDomain_ProcessExit;
if (args.Length == 2)
{
@@ -493,12 +493,6 @@ namespace Bot
//System.Console.ReadKey();
}
- private static void CurrentDomain_ProcessExit(object sender, EventArgs e)
- {
- // Exit the process
- if (File.Exists("Bot.lockfile")) File.Delete("Bot.lockfile");
- }
-
private static void onJoinGroupChat(object sender, GroupChatJoinedEventArgs e)
{
if (e.Success)
@@ -817,7 +811,7 @@ namespace Bot
newCache.GroupID = e.GroupID;
newCache.Save(e.GroupID.ToString());
RoleReply.Set();
- FileInfo fi = new FileInfo("GroupCache/" + e.GroupID.ToString() + ".bdf");
+ FileInfo fi = new FileInfo("GroupCache/" + e.GroupID.ToString() + ".json");
//MHE(MessageHandler.Destinations.DEST_LOCAL, UUID.Zero, "[debug] Roles for secondlife:///app/group/" + e.GroupID.ToString() + "/about have been saved to: GroupCache/" + e.GroupID.ToString() + ".bdf\nFileSize: "+fi.Length.ToString(), 55);