This commit is contained in:
Zontreck 2020-09-04 13:24:43 -07:00
parent 8835e0cf8b
commit 1c6a08a4d7
9 changed files with 25 additions and 23 deletions

View file

@ -6,6 +6,7 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<SignAssembly>false</SignAssembly> <SignAssembly>false</SignAssembly>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo> <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences>
<Configurations>Debug;Release</Configurations> <Configurations>Debug;Release</Configurations>
</PropertyGroup> </PropertyGroup>

View file

@ -39,9 +39,10 @@ namespace Bot.Charts
{ {
lock (FileHandler) lock (FileHandler)
{ {
if (File.Exists("Charts.json")) File.Move("Charts.json", Path.Combine("BotData", "Charts.json"));
// Read json file // Read json file
if (!File.Exists("Charts.json")) return new ChartMemory(); if (!File.Exists("BotData/Charts.json")) return new ChartMemory();
return JsonConvert.DeserializeObject<ChartMemory>(File.ReadAllText("Charts.json")); return JsonConvert.DeserializeObject<ChartMemory>(File.ReadAllText("BotData/Charts.json"));
} }
} }
@ -57,7 +58,7 @@ namespace Bot.Charts
{ {
lock (FileHandler) lock (FileHandler)
{ {
File.WriteAllText("Charts.json", JsonConvert.SerializeObject(Instance, Formatting.Indented)); File.WriteAllText("BotData/Charts.json", JsonConvert.SerializeObject(Instance, Formatting.Indented));
} }
} }

View file

@ -87,6 +87,7 @@ namespace Bot
public void Load() public void Load()
{ {
if (File.Exists("Main.json")) File.Move("Main.json", Path.Combine("BotData", "Main.json"));
inst = new MainConfiguration(); inst = new MainConfiguration();
SerialManager sm = new SerialManager(); SerialManager sm = new SerialManager();
try try

View file

@ -48,7 +48,7 @@ namespace Bot
private static void CacheGroupRoles(object sender, GroupRolesDataReplyEventArgs e) private static void CacheGroupRoles(object sender, GroupRolesDataReplyEventArgs e)
{ {
//MHE(MessageHandler.Destinations.DEST_LOCAL, UUID.Zero, "[debug] role_reply"); //MHE(MessageHandler.Destinations.DEST_LOCAL, UUID.Zero, "[debug] role_reply");
if (!Directory.Exists("zGroupCache")) Directory.CreateDirectory("zGroupCache"); // this should be purged at every bot restart!!! if (!Directory.Exists("BotData/zGroupCache")) Directory.CreateDirectory("BotData/zGroupCache"); // this should be purged at every bot restart!!!
//MHE(MessageHandler.Destinations.DEST_LOCAL, UUID.Zero, "[debug] generating groupcache file"); //MHE(MessageHandler.Destinations.DEST_LOCAL, UUID.Zero, "[debug] generating groupcache file");
zGroupCaches newCache = new zGroupCaches(); zGroupCaches newCache = new zGroupCaches();
@ -67,7 +67,7 @@ namespace Bot
newCache.GroupID = e.GroupID; newCache.GroupID = e.GroupID;
newCache.Save(e.GroupID.ToString()); newCache.Save(e.GroupID.ToString());
RoleReply.Set(); RoleReply.Set();
FileInfo fi = new FileInfo("GroupCache/" + e.GroupID.ToString() + ".json"); FileInfo fi = new FileInfo("BotData/zGroupCache/" + 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); //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);

View file

@ -41,9 +41,9 @@ namespace Bot
string date = DateTime.Now.ToString("M-d-yyyy"); string date = DateTime.Now.ToString("M-d-yyyy");
date += " " + LogName + ".log"; date += " " + LogName + ".log";
if (!Directory.Exists("GroupChatLogs")) Directory.CreateDirectory("GroupChatLogs"); if (!Directory.Exists("BotData/GroupChatLogs")) Directory.CreateDirectory("BotData/GroupChatLogs");
date = "GroupChatLogs/" + date; date = "BotData/GroupChatLogs/" + date;
File.AppendAllText(date, "[" + DateTime.Now.ToString("hh:mm:ss") + "]: " + ToAppend + "\n"); File.AppendAllText(date, "[" + DateTime.Now.ToString("hh:mm:ss") + "]: " + ToAppend + "\n");
} }
@ -63,12 +63,12 @@ namespace Bot
LogFormat = LogFormat.Replace("%MESSAGE%", Message); LogFormat = LogFormat.Replace("%MESSAGE%", Message);
LogFormat = LogFormat.Replace("%UUID%", SenderID.ToString()); LogFormat = LogFormat.Replace("%UUID%", SenderID.ToString());
filename = "GroupChatLogs/" + filename; filename = "BotData/GroupChatLogs/" + filename;
try try
{ {
lock (_writeLock) lock (_writeLock)
{ {
if (!Directory.Exists("GroupChatLogs")) Directory.CreateDirectory("GroupChatLogs"); if (!Directory.Exists("BotData/GroupChatLogs")) Directory.CreateDirectory("BotData/GroupChatLogs");
File.AppendAllText(filename, LogFormat + "\n"); File.AppendAllText(filename, LogFormat + "\n");
} }
}catch(Exception e) }catch(Exception e)
@ -88,7 +88,7 @@ namespace Bot
string GrpName = additionalArgs[0].Replace('_', ' '); string GrpName = additionalArgs[0].Replace('_', ' ');
string[] search = additionalArgs[1].Split('|'); string[] search = additionalArgs[1].Split('|');
DirectoryInfo di = new DirectoryInfo("GroupChatLogs"); DirectoryInfo di = new DirectoryInfo("BotData/GroupChatLogs");
foreach (FileInfo fi in di.GetFiles()) foreach (FileInfo fi in di.GetFiles())
{ {
// check if filename contains the group name // check if filename contains the group name
@ -99,7 +99,7 @@ namespace Bot
// read file // read file
lock (_fileRead) lock (_fileRead)
{ {
foreach (string S in File.ReadLines("GroupChatLogs/" + onlyName + ".log")) foreach (string S in File.ReadLines("BotData/GroupChatLogs/" + onlyName + ".log"))
{ {
foreach (string V in search) foreach (string V in search)
{ {
@ -133,7 +133,7 @@ namespace Bot
try try
{ {
foreach (string s in File.ReadLines("GroupChatLogs/" + Uri.UnescapeDataString(arguments[0]) + ".log")) foreach (string s in File.ReadLines("BotData/GroupChatLogs/" + Uri.UnescapeDataString(arguments[0]) + ".log"))
{ {
string tmp = s; string tmp = s;
string[] Ltmp = tmp.Split(' '); string[] Ltmp = tmp.Split(' ');
@ -173,7 +173,7 @@ namespace Bot
WebhookRegistry.HTTPResponseData hrd = new WebhookRegistry.HTTPResponseData(); WebhookRegistry.HTTPResponseData hrd = new WebhookRegistry.HTTPResponseData();
hrd.Status = 200; hrd.Status = 200;
hrd.ReplyString = "<center><h2>Group Chat Logs</h2></center>"; hrd.ReplyString = "<center><h2>Group Chat Logs</h2></center>";
DirectoryInfo di = new DirectoryInfo("GroupChatLogs"); DirectoryInfo di = new DirectoryInfo("BotData/GroupChatLogs");
foreach (FileInfo fi in di.GetFiles()) foreach (FileInfo fi in di.GetFiles())
{ {
hrd.ReplyString += "<br/><a href='/viewlog/" + Path.GetFileNameWithoutExtension(fi.Name) + "'> " + fi.Name + "</a>"; hrd.ReplyString += "<br/><a href='/viewlog/" + Path.GetFileNameWithoutExtension(fi.Name) + "'> " + fi.Name + "</a>";

View file

@ -48,9 +48,8 @@ namespace Bot
public static unsafe void Main(string[] args) public static unsafe void Main(string[] args)
{ {
File.WriteAllText("PID.lock", Process.GetCurrentProcess().Id.ToString()); File.WriteAllText("PID.lock", Process.GetCurrentProcess().Id.ToString());
if (!Directory.Exists("BotData")) Directory.CreateDirectory("BotData");
Directory.SetCurrentDirectory("BotData");
if (!Directory.Exists("BotData")) Directory.CreateDirectory("BotData");
Console.WriteLine("Setting up Main Configuration"); Console.WriteLine("Setting up Main Configuration");

View file

@ -71,7 +71,7 @@ namespace Bot
try try
{ {
File.WriteAllText(Name + ".json", Json); File.WriteAllText("BotData/"+Name + ".json", Json);
} catch(Exception E) } catch(Exception E)
{ {
BotSession.Instance.Logger.info(true, E.Message); BotSession.Instance.Logger.info(true, E.Message);
@ -89,7 +89,7 @@ namespace Bot
{ {
T obj = default(T); T obj = default(T);
string serial = File.ReadAllText(Name + ".json"); string serial = File.ReadAllText("BotData/"+Name + ".json");
obj = (T)JsonConvert.DeserializeObject<T>(serial); obj = (T)JsonConvert.DeserializeObject<T>(serial);
BotSession.Instance.Logger.info(true, "Returning class object"); BotSession.Instance.Logger.info(true, "Returning class object");

View file

@ -35,8 +35,8 @@ namespace Bot.Visitors
{ {
lock (fileLock) lock (fileLock)
{ {
if (File.Exists("VisitorLog.json")) if (File.Exists("BotData/VisitorLog.json"))
return JsonConvert.DeserializeObject<VisitorLog>(File.ReadAllText("VisitorLog.json")); return JsonConvert.DeserializeObject<VisitorLog>(File.ReadAllText("BotData/VisitorLog.json"));
else return new VisitorLog(); else return new VisitorLog();
} }
} }
@ -45,7 +45,7 @@ namespace Bot.Visitors
{ {
lock (fileLock) lock (fileLock)
{ {
File.WriteAllText("VisitorLog.json", JsonConvert.SerializeObject(l, Formatting.Indented)); File.WriteAllText("BotData/VisitorLog.json", JsonConvert.SerializeObject(l, Formatting.Indented));
} }
} }

View file

@ -49,15 +49,15 @@ namespace Bot
//if (!File.Exists("OpenCollarBot.bdf")) return; //if (!File.Exists("OpenCollarBot.bdf")) return;
SerialManager sm = new SerialManager(); SerialManager sm = new SerialManager();
sm.Write<zGroupCaches>("zGroupCache/" + CustomName, this); sm.Write<zGroupCaches>("BotData/zGroupCache/" + CustomName, this);
sm = null; sm = null;
} }
public static zGroupCaches Reload(string CustomName) public static zGroupCaches Reload(string CustomName)
{ {
if (!File.Exists("zGroupCache/" + CustomName + ".json")) return new zGroupCaches(); if (!File.Exists("BotData/zGroupCache/" + CustomName + ".json")) return new zGroupCaches();
SerialManager sm = new SerialManager(); SerialManager sm = new SerialManager();
zGroupCaches ocb = sm.Read<zGroupCaches>("GroupCache/" + CustomName); zGroupCaches ocb = sm.Read<zGroupCaches>("zGroupCache/" + CustomName);
if (ocb == null) if (ocb == null)
{ {
return new zGroupCaches(); return new zGroupCaches();