mirror of
https://github.com/D1GQ/BetterAmongUs.git
synced 2026-10-20 01:46:19 +00:00
59 lines
2.2 KiB
C#
59 lines
2.2 KiB
C#
using BetterAmongUs.Data;
|
|
using BetterAmongUs.Items.Attributes;
|
|
using BetterAmongUs.Modules;
|
|
|
|
namespace BetterAmongUs.Commands;
|
|
|
|
[RegisterCommand]
|
|
internal class DumpCommand : BaseCommand
|
|
{
|
|
internal override string Name => "dump";
|
|
internal override string Description => "Dump the entire log to the user's desktop";
|
|
internal override bool ShowCommand() => !GameState.IsInGamePlay || GameState.IsDev;
|
|
|
|
internal override void Run()
|
|
{
|
|
if (GameState.IsInGamePlay && !GameState.IsDev) return;
|
|
|
|
string logFilePath = Path.Combine(BetterDataManager.filePathFolder, "better-log.txt");
|
|
string log = File.ReadAllText(logFilePath);
|
|
string newLog = string.Empty;
|
|
string[] logArray = log.Split([Environment.NewLine], StringSplitOptions.None);
|
|
foreach (string text in logArray)
|
|
{
|
|
if (text.Contains("[PrivateLog]"))
|
|
{
|
|
newLog += text.Split(':')[0] + ":" + text.Split(':')[1].Replace("[PrivateLog]", "") + ": " + Encryptor.Decrypt(text.Split(':')[2][1..]) + "\n";
|
|
}
|
|
else
|
|
{
|
|
newLog += text + "\n";
|
|
}
|
|
}
|
|
|
|
string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
|
|
string logFolderPath = Path.Combine(desktopPath, "BetterLogs");
|
|
if (!Directory.Exists(logFolderPath))
|
|
{
|
|
Directory.CreateDirectory(logFolderPath);
|
|
}
|
|
string logFileName = "log-" + BAUPlugin.GetVersionText().Replace(' ', '-').ToLower() + "-" + DateTime.Now.ToString("yyyy.MM.dd-HH.mm.ss") + ".log";
|
|
string newLogFilePath = Path.Combine(logFolderPath, logFileName);
|
|
File.WriteAllText(newLogFilePath, newLog);
|
|
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo()
|
|
{
|
|
FileName = logFolderPath,
|
|
UseShellExecute = true,
|
|
Verb = "open"
|
|
});
|
|
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo()
|
|
{
|
|
FileName = newLogFilePath,
|
|
UseShellExecute = true,
|
|
Verb = "open"
|
|
});
|
|
|
|
CommandResultText($"Dump logs at <color=#b1b1b1>'{newLogFilePath}'</color>");
|
|
}
|
|
}
|